【发布时间】:2013-09-04 07:32:06
【问题描述】:
我正在尝试在图像上添加一个按钮。但既看不到按钮也看不到图像。这是为什么 ?我在 IDE 调用 initComponents 方法之后从构造函数调用此方法。
public void initD() {
try {
BufferedImage myPicture = ImageIO.read(new File("C:\\Users\\user\\Documents\\NetBeansProjects\\JavaApplication1\\src\\javaapplication1\\meaning.JPG"));
JLabel picLabel = new JLabel(new ImageIcon(myPicture));
JButton b = new JButton("Press me");
jPanel1.add(picLabel);
jPanel1.add(b);
System.out.println("last statement");
}catch(Exception exc) {
exc.printStackTrace();
}
}
我只将帧视为输出。
【问题讨论】:
标签: java image swing netbeans jbutton