if(compressedImageFilePath.exists()){
final String ie = Integer.toString(i);
JFrame mboxFrame1 = new JFrame("Optimized Image");
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
ImageIcon image1 = new ImageIcon(compressedImageFile);
JLabel reader1 = new JLabel(image1);
mboxFrame1.setContentPane(reader1);
controlPanel2 = new JPanel();
JButton saveButton = new JButton("SAVE");
saveButton.setVisible(true);
mboxFrame1.setSize(screenSize.width, screenSize.height-30);
mboxFrame1.setResizable(true);
mboxFrame1.setVisible(true);
mboxFrame1.add(headerLabel);
mboxFrame1.add(controlPanel2);
controlPanel2.add(saveButton);
mboxFrame1.add(controlPanel2, BorderLayout.WEST);
}
Here i am checking for a particular file. If that file exists i am creating a new Jrame and adding the Save Button to it. But the save button is not getting displayed.Where am i going wrong?
Please add your panel to frame. Hope that will solve the problem
You can try
mboxFrame1.getContentPane().add(reader1,BorderLayout.NORTH);
instead of
mboxFrame1.setContentPane(reader1);
you don't add the JPanel you added the button to to the Jframe in any way. use a layout on your jframe and add the JPanel to the layout. easy to use is BorderLayout
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.