Search in sources :

Example 26 with JInternalFrame

use of javax.swing.JInternalFrame in project JMRI by JMRI.

the class TableFrames method internalFrameIconified.

@Override
public void internalFrameIconified(InternalFrameEvent e) {
    JInternalFrame frame = (JInternalFrame) e.getSource();
    String name = frame.getName();
    if (log.isDebugEnabled()) {
        log.debug("Internal frame Iconified: " + frame.getTitle() + ", name= " + name + " size (" + frame.getSize().getWidth() + ", " + frame.getSize().getHeight() + ")");
    }
    if (name != null && name.startsWith("OB")) {
        WarrantTableAction.initPathPortalCheck();
        WarrantTableAction.checkPathPortals(((BlockPathFrame) frame).getModel().getBlock());
        if (_showWarnings) {
            WarrantTableAction.showPathPortalErrors();
        }
    }
}
Also used : JInternalFrame(javax.swing.JInternalFrame)

Example 27 with JInternalFrame

use of javax.swing.JInternalFrame in project JMRI by JMRI.

the class ThrottleFrame method setXml.

/**
     * Set the preferences based on the XML Element.
     * <ul>
     * <li> Window prefs
     * <li> Frame title
     * <li> ControlPanel
     * <li> FunctionPanel
     * <li> AddressPanel
     * </ul>
     *
     *
     * @param e The Element for this object.
     */
@SuppressWarnings("unchecked")
public void setXml(Element e) {
    if (e == null) {
        return;
    }
    String sfile = e.getAttributeValue("ThrottleXMLFile");
    if (sfile != null) {
        loadThrottle(FileUtil.getExternalFilename(sfile));
        return;
    }
    boolean switchAfter = false;
    if (!isEditMode) {
        switchMode();
        switchAfter = true;
    }
    int bSize = 23;
    // Get InternalFrame border size
    if (e.getAttribute("border") != null) {
        bSize = Integer.parseInt((e.getAttribute("border").getValue()));
    }
    if (// Old format
    e.getChild("window") != null) {
        throttleWindow.setXml(e);
    }
    Element controlPanelElement = e.getChild("ControlPanel");
    controlPanel.setXml(controlPanelElement);
    if (((javax.swing.plaf.basic.BasicInternalFrameUI) controlPanel.getUI()).getNorthPane() != null) {
        ((javax.swing.plaf.basic.BasicInternalFrameUI) controlPanel.getUI()).getNorthPane().setPreferredSize(new Dimension(0, bSize));
    }
    Element functionPanelElement = e.getChild("FunctionPanel");
    functionPanel.setXml(functionPanelElement);
    if (((javax.swing.plaf.basic.BasicInternalFrameUI) controlPanel.getUI()).getNorthPane() != null) {
        ((javax.swing.plaf.basic.BasicInternalFrameUI) functionPanel.getUI()).getNorthPane().setPreferredSize(new Dimension(0, bSize));
    }
    Element addressPanelElement = e.getChild("AddressPanel");
    addressPanel.setXml(addressPanelElement);
    if (((javax.swing.plaf.basic.BasicInternalFrameUI) controlPanel.getUI()).getNorthPane() != null) {
        ((javax.swing.plaf.basic.BasicInternalFrameUI) addressPanel.getUI()).getNorthPane().setPreferredSize(new Dimension(0, bSize));
    }
    List<Element> jinsts = e.getChildren("Jynstrument");
    if ((jinsts != null) && (jinsts.size() > 0)) {
        for (int i = 0; i < jinsts.size(); i++) {
            JInternalFrame jif = ynstrument(FileUtil.getExternalFilename(jinsts.get(i).getAttributeValue("JynstrumentFolder")));
            Element window = jinsts.get(i).getChild("window");
            if (jif != null) {
                if (window != null) {
                    WindowPreferences.setPreferences(jif, window);
                }
                Component[] cmps2 = jif.getContentPane().getComponents();
                int j = 0;
                while ((j < cmps2.length) && (!(cmps2[j] instanceof Jynstrument))) {
                    j++;
                }
                if ((j < cmps2.length) && (cmps2[j] instanceof Jynstrument) && (jinsts.get(i) != null)) {
                    ((Jynstrument) cmps2[j]).setXml(jinsts.get(i));
                }
                jif.repaint();
            }
        }
    }
    setFrameTitle();
    if (switchAfter) {
        switchMode();
    }
}
Also used : Jynstrument(jmri.jmrit.jython.Jynstrument) Element(org.jdom2.Element) Dimension(java.awt.Dimension) JComponent(javax.swing.JComponent) Component(java.awt.Component) JInternalFrame(javax.swing.JInternalFrame) Point(java.awt.Point)

Example 28 with JInternalFrame

use of javax.swing.JInternalFrame in project JMRI by JMRI.

the class ThrottleFrame method editRendering.

private void editRendering() {
    Component[] cmps = getComponentsInLayer(PANEL_LAYER_PANEL);
    for (int i = 0; i < cmps.length; i++) {
        if (cmps[i] instanceof JPanel) {
            JPanel pane = (JPanel) cmps[i];
            JInternalFrame jif = contentPanes.get(pane);
            jif.setContentPane((Container) pane.getComponent(0));
            setTransparent(jif, false);
            jif.setVisible(true);
            remove(pane);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) JComponent(javax.swing.JComponent) Component(java.awt.Component) JInternalFrame(javax.swing.JInternalFrame) Point(java.awt.Point)

Example 29 with JInternalFrame

use of javax.swing.JInternalFrame in project JMRI by JMRI.

the class ThrottleFrame method playRendering.

private void playRendering() {
    Component[] cmps = getComponentsInLayer(PANEL_LAYER_FRAME);
    contentPanes = new HashMap<Container, JInternalFrame>();
    for (int i = 0; i < cmps.length; i++) {
        if ((cmps[i] instanceof JInternalFrame) && (cmps[i].isVisible())) {
            JInternalFrame jif = (JInternalFrame) cmps[i];
            Dimension cpSize = jif.getContentPane().getSize();
            Point cpLoc = jif.getContentPane().getLocationOnScreen();
            TranslucentJPanel pane = new TranslucentJPanel();
            pane.setLayout(new BorderLayout());
            contentPanes.put(pane, jif);
            pane.add(jif.getContentPane(), BorderLayout.CENTER);
            setTransparent(pane, true);
            jif.setContentPane(new JPanel());
            jif.setVisible(false);
            Point loc = new Point(cpLoc.x - this.getLocationOnScreen().x, cpLoc.y - this.getLocationOnScreen().y);
            add(pane, PANEL_LAYER_PANEL);
            pane.setLocation(loc);
            pane.setSize(cpSize);
        }
    }
}
Also used : JPanel(javax.swing.JPanel) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) Dimension(java.awt.Dimension) Point(java.awt.Point) JComponent(javax.swing.JComponent) Component(java.awt.Component) JInternalFrame(javax.swing.JInternalFrame) Point(java.awt.Point)

Example 30 with JInternalFrame

use of javax.swing.JInternalFrame in project JMRI by JMRI.

the class ThrottleFramePropertyEditor method saveProperties.

/**
     * Save the user-modified properties back to the ThrottleFrame.
     */
private void saveProperties() {
    if (isDataValid()) {
        int bSize = Integer.parseInt(Bundle.getMessage("FrameSize"));
        JInternalFrame myFrame;
        frame.setTitleText(titleField.getText());
        frame.setTitleTextType(titleTextTypes[titleType.getSelectedIndex()]);
        frame.getCurrentThrottleFrame().setFrameTitle();
        if (((javax.swing.plaf.basic.BasicInternalFrameUI) frame.getCurrentThrottleFrame().getControlPanel().getUI()).getNorthPane() != null) {
            if (borderOff.isSelected()) {
                bSize = 0;
            }
            myFrame = frame.getCurrentThrottleFrame().getControlPanel();
            ((javax.swing.plaf.basic.BasicInternalFrameUI) myFrame.getUI()).getNorthPane().setPreferredSize(new Dimension(0, bSize));
            if (myFrame.isVisible()) {
                myFrame.setVisible(false);
                myFrame.setVisible(true);
            }
            myFrame = frame.getCurrentThrottleFrame().getFunctionPanel();
            ((javax.swing.plaf.basic.BasicInternalFrameUI) myFrame.getUI()).getNorthPane().setPreferredSize(new Dimension(0, bSize));
            if (myFrame.isVisible()) {
                myFrame.setVisible(false);
                myFrame.setVisible(true);
            }
            myFrame = frame.getCurrentThrottleFrame().getAddressPanel();
            ((javax.swing.plaf.basic.BasicInternalFrameUI) myFrame.getUI()).getNorthPane().setPreferredSize(new Dimension(0, bSize));
            if (myFrame.isVisible()) {
                myFrame.setVisible(false);
                myFrame.setVisible(true);
            }
        }
        finishEdit();
    }
}
Also used : Dimension(java.awt.Dimension) JInternalFrame(javax.swing.JInternalFrame)

Aggregations

JInternalFrame (javax.swing.JInternalFrame)36 Point (java.awt.Point)12 PropertyVetoException (java.beans.PropertyVetoException)12 Dimension (java.awt.Dimension)9 Component (java.awt.Component)7 JPanel (javax.swing.JPanel)7 JScrollPane (javax.swing.JScrollPane)7 JTable (javax.swing.JTable)7 BorderLayout (java.awt.BorderLayout)6 JButton (javax.swing.JButton)6 JLabel (javax.swing.JLabel)6 JComponent (javax.swing.JComponent)5 JMenu (javax.swing.JMenu)4 Jynstrument (jmri.jmrit.jython.Jynstrument)4 Container (java.awt.Container)3 JDesktopPane (javax.swing.JDesktopPane)3 JMenuBar (javax.swing.JMenuBar)3 JMenuItem (javax.swing.JMenuItem)3 TableRowSorter (javax.swing.table.TableRowSorter)3 ButtonEditor (jmri.util.table.ButtonEditor)3