このコードを使用して、画像をjframeに設定します。しかし、今、私のJtableは表示されません、なぜですか?
public class samplepage extends JFrame{
private AllUser userModel;
private JTable uTable;
JButton addUser;
JButton deleteUser;
JButton mainButton;
JTextField tf1;
JButton searchButton;
JLabel resultLbl;
public samplepage(){
userModel=new AllUser();
uTable=new JTable(userModel);
add(new JScrollPane(uTable), BorderLayout.CENTER);
add(buttonPanels() , BorderLayout.PAGE_START);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(800,600);
this.setLocation(300, 60);
this.setResizable(false);
}
public final JPanel buttonPanels(){
JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
setPic(this);
addUser=new JButton("Add New User");
deleteUser=new JButton("delete User");
mainButton= new JButton("Main Page");
tf1 = new JTextField(" ");
searchButton=new JButton("Search");
resultLbl=new JLabel();
buttonsPanel.add(addUser);
buttonsPanel.add(deleteUser);
buttonsPanel.add(mainButton);
buttonsPanel.add(tf1);
buttonsPanel.add(searchButton);
buttonsPanel.add(resultLbl);
return buttonsPanel;
}
public void setPic(JFrame jframe){
try{
File f=new File("pics\\user_group.png");
BufferedImage img=ImageIO.read(f);
jframe.setContentPane(new SetMyImage(img));
}
catch(IOException ioe){
}
}
public static void main(String[] args){
new samplepage().setVisible(true);
}
}
セカンドクラス:
public class SetMyImage extends JPanel{
private Image img;
public SetMyImage(Image img){
this.img=img;
}
@Override
protected void paintComponent(Graphics g){
super.paintComponent(g);
g.drawImage(img, 00, 00, null);
}
}
私の間違いはどこにありますか?