0
            String s;
            JFileChooser jfc = new JFileChooser();
            jfc.showDialog(jfc, "Choose an image file");
            s = jfc.getSelectedFile().getAbsolutePath();
            tx_image.setText(s);

ファイルチューザーを使用して画像の場所を取得します。それから私はそれをデータベースに保存しました。保存する場所のタイプは c:\doucuments\3.jpg です。そして、JLabelでimageiconを使用して、その場所から画像を表示します

 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                Connection con =DriverManager.getConnection("jdbc:odbc:project","sa","123456");
                String s=tx_name.getText();
                Statement stmt= con.createStatement();
                ResultSet rs=stmt.executeQuery("SELECT name,address,email,startdate,enddate,reason,homeph,cellph,hourlyrate,image FROM driver");
                while(rs.next())
                {
                    if(s.equals(rs.getString(1)))
                    {
                        tx_address.setText(rs.getString(2));
                        tx_email.setText(rs.getString(3));
                        tx_startdate.setText(rs.getString(4));
                        tx_enddate.setText(rs.getString(5));
                        txf_reason.setText(rs.getString(6));
                        tx_homeph.setText(Integer.toString(rs.getInt(7)));
                        tx_cellph.setText(Integer.toString(rs.getInt(8)));
                        tx_hourlyrate.setText(Integer.toString(rs.getInt(9)));
                        s=rs.getString(10);
                        ic=new ImageIcon(s);
                        lb_image.setIcon(ic);
                        lb_image.setBounds(350,100,200,200);
                        break;

そのため、問題は、imageicon が必要とする画像の場所が c:\documents\3.jpg タイプであるため、imageicon がエラーを出している画像の場所です。ファイル選択ツールを使用して、単一のスラッシュではなく二重のスラッシュの場所を保存するにはどうすればよいですか。

4

0 に答える 0