JInternalFrame-非法的组件位置

时间:2018-11-10 18:36:34

标签: java swing illegalargumentexception jinternalframe

java 1.7

public class AccountsScroller extends JInternalFrame implements ActionListener, PaginationListener {

...
}

这里是我如何从JFrame打开InternalFrame

    public void openInternalFrame(JInternalFrame newInternalFrame, Boolean isMaximize, Dimension dimension) {
            try {
                currentInternalFrame.setClosed(true);
                currentInternalFrame = newInternalFrame;
                addInternalFrame(currentInternalFrame, isMaximize, dimension);
            } catch (PropertyVetoException ex) {
                logger.error(ex.getMessage(), ex);
            }
        }



 private JDesktopPane desktop;

desktop = new JDesktopPane();
private void addInternalFrame(JInternalFrame internalFrame, Boolean isMaximize, Dimension dimension) {
        desktop.add(internalFrame); // 321 line
        try {
            internalFrame.setSelected(true);
            if (isMaximize != null && isMaximize) {
                internalFrame.setMaximum(true);
            } else {
                internalFrame.setSize(dimension);
            }
        } catch (java.beans.PropertyVetoException e) {
            logger.error(e.getMessage(), e);
        }
    }

但是当我再次打开它时,出现错误:

   [java]     get_all_accounts rows = 2
     [java] Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: illegal component position
     [java]     at java.awt.Container.addImpl(Container.java:1100)
     [java]     at javax.swing.JLayeredPane.addImpl(JLayeredPane.java:231)
     [java]     at javax.swing.JDesktopPane.addImpl(JDesktopPane.java:484)
     [java]     at java.awt.Container.add(Container.java:417)
     [java]     at myproject.com.MainScreenView.addInternalFrame(MainScreenView.java:321)
     [java]     at myproject.com.MainScreenView.openInternalFrame(MainScreenView.java:314)
     [java]     at myproject.com.MainScreenView.openInternalFrame(MainScreenView.java:307)
     [java]     at myproject.com.MainScreenView.actionPerformed(MainScreenView.java:230)
     [java]     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
     [java]     at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
     [java]     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
     [java]     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
     [java]     at javax.swing.AbstractButton.doClick(AbstractButton.java:376)
     [java]     at javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:833)
     [java]     at javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:877)
     [java]     at java.awt.Component.processMouseEvent(Component.java:6533)
     [java]     at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
     [java]     at java.awt.Component.processEvent(Component.java:6298)
     [java]     at java.awt.Container.processEvent(Container.java:2236)
     [java]     at java.awt.Component.dispatchEventImpl(Component.java:4889)
     [java]     at java.awt.Container.dispatchEventImpl(Container.java:2294)
     [java]     at java.awt.Component.dispatchEvent(Component.java:4711)
     [java]     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4888)
     [java]     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4525)
     [java]     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4466)
     [java]     at java.awt.Container.dispatchEventImpl(Container.java:2280)
     [java]     at java.awt.Window.dispatchEventImpl(Window.java:2746)`enter code here`

0 个答案:

没有答案