1
我正在嘗試爲自定義Swing JComponent實現脫離效果。默認情況下,該組件與其他組件一起用於表單中。我希望能夠最大化該組件以使用整個屏幕,然後再次停靠。到目前爲止,我已經測試JComponent脫離效果
public void showDialog() {
JFrame mainFrame = App.getApplication().getMainFrame();
JDialog dialog = new JDialog(mainFrame);
dialog.setModal(true);
dialog.setSize(800, 600); //Set to 80x660 for now
dialog.add(this); //This is my JComponent
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
dialog.setVisible(true);
}
這給了我想要的效果,但在關閉對話框時,我的組件不沒有更多的接收事件。我怎樣才能防止這一點?
或者是否有更好的方法來實現這個目標?