My app has a JWindow that needs to be minimized when the custom minimizer button clicked. Please reply if anyone knows how to minimize a JWindow. I have searched a lot but couldn't find any suitable method to minimize. I know how to minimize a JFrame. So please don't bother answering regarding JFrame. Thanks.
Asked
Active
Viewed 1,425 times
2 Answers
3
I know you don't want to hear this, but the terrible truth is that there is no big difference between undecorated jframes (with setstate methods) and jwindows... :)
JFrame f = new JFrame("Frame");
f.setUndecorated(true);

lbalazscs
- 17,474
- 7
- 42
- 50
-
Thank you too for the info! Didn't know it! – Ahmadul Hoq Oct 19 '12 at 08:48
2
Due to the fact that a JWindow is not decorated with any control icons, no setState
method is provided. One workaround is to allow your custom minimizer button to set the window visible as required:
public class JWindowTest extends JFrame {
JWindow window = new JWindow();
JButton maxMinButton = new JButton("Minimize Window");
public JWindowTest() {
setSize(300, 200);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
maxMinButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (window.isVisible()) {
maxMinButton.setText("Restore Window");
} else {
maxMinButton.setText("Minimize Window");
}
window.setVisible(!window.isVisible());
}
});
add(maxMinButton);
window.setBounds(30, 30, 300, 220);
window.setLocationRelativeTo(this);
window.add(new JLabel("Test JWindow", JLabel.CENTER));
window.setVisible(true);
}
public static void main(String[] args) {
new JWindowTest().setVisible(true);
}
}

Reimeus
- 158,255
- 15
- 216
- 276