I have a Java program that I wrote that changes whether or not a JFrame is resizable depending on application state. In Windows this works great, when it is resizable the maximize button is enabled when it's not the button is disabled. However, on my Mac when I change resizable back to true the zoom button does not become enabled but the window DOES become resizable - the resize grabber shows.
开发者_如何学CUnfortunately, I haven't been able to replicate this behavior in a simple application. Only in my complex app does this appear. So I'm wondering other than the resizable state of a JFrame what affects if the zoom button is enabled?
Here's a simple example that shows the expected behavior on Mac OS X; you might compare it to what you're doing for reference.
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JToggleButton;
public class FrameTest extends JPanel implements Runnable {
private JFrame f;
private boolean test;
public static void main(String[] args) {
EventQueue.invokeLater(new FrameTest());
}
@Override
public void run() {
f = new JFrame("Test");
test = f.isResizable();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(this);
f.pack();
f.setLocationRelativeTo(null);
f.setVisible(true);
}
public FrameTest() {
this.add(new JToggleButton(new AbstractAction("Test") {
@Override
public void actionPerformed(ActionEvent e) {
test = !test;
f.setResizable(test);
}
}));
}
}
精彩评论