Reputation: 725
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.
Upvotes: 3
Views: 1454
Reputation: 17784
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);
Upvotes: 3
Reputation: 159784
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);
}
}
Upvotes: 2