Search in sources :

Example 11 with JInternalFrame

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

the class ThrottleFrame method getXml.

/**
     * Collect the prefs of this object into XML Element
     * <ul>
     * <li> Window prefs
     * <li> ControlPanel
     * <li> FunctionPanel
     * <li> AddressPanel
     * </ul>
     *
     *
     * @return the XML of this object.
     */
public Element getXml() {
    boolean switchAfter = false;
    if (!isEditMode) {
        switchMode();
        switchAfter = true;
    }
    Element me = new Element("ThrottleFrame");
    if (((javax.swing.plaf.basic.BasicInternalFrameUI) getControlPanel().getUI()).getNorthPane() != null) {
        Dimension bDim = ((javax.swing.plaf.basic.BasicInternalFrameUI) getControlPanel().getUI()).getNorthPane().getPreferredSize();
        me.setAttribute("border", Integer.toString(bDim.height));
    }
    java.util.ArrayList<Element> children = new java.util.ArrayList<Element>(1);
    //        children.add(WindowPreferences.getPreferences(this));  // not required as it is in ThrottleWindow
    children.add(controlPanel.getXml());
    children.add(functionPanel.getXml());
    children.add(addressPanel.getXml());
    // Save Jynstruments
    Component[] cmps = getComponents();
    for (int i = 0; i < cmps.length; i++) {
        try {
            if (cmps[i] instanceof JInternalFrame) {
                Component[] cmps2 = ((JInternalFrame) cmps[i]).getContentPane().getComponents();
                int j = 0;
                while ((j < cmps2.length) && (!(cmps2[j] instanceof Jynstrument))) {
                    j++;
                }
                if ((j < cmps2.length) && (cmps2[j] instanceof Jynstrument)) {
                    Jynstrument jyn = (Jynstrument) cmps2[j];
                    Element elt = new Element("Jynstrument");
                    elt.setAttribute("JynstrumentFolder", FileUtil.getPortableFilename(jyn.getFolder()));
                    java.util.ArrayList<Element> jychildren = new java.util.ArrayList<Element>(1);
                    jychildren.add(WindowPreferences.getPreferences((JInternalFrame) cmps[i]));
                    Element je = jyn.getXml();
                    if (je != null) {
                        jychildren.add(je);
                    }
                    elt.setContent(jychildren);
                    children.add(elt);
                }
            }
        } catch (Exception ex) {
            log.debug("Got exception (no panic) " + ex);
        }
    }
    me.setContent(children);
    if (switchAfter) {
        switchMode();
    }
    return me;
}
Also used : Jynstrument(jmri.jmrit.jython.Jynstrument) Element(org.jdom2.Element) Dimension(java.awt.Dimension) Point(java.awt.Point) JComponent(javax.swing.JComponent) Component(java.awt.Component) JInternalFrame(javax.swing.JInternalFrame)

Example 12 with JInternalFrame

use of javax.swing.JInternalFrame in project jdk8u_jdk by JetBrains.

the class MetalworksFrame method openInBox.

public void openInBox() {
    JInternalFrame doc = new MetalworksInBox();
    desktop.add(doc, DOCLAYER);
    try {
        doc.setVisible(true);
        doc.setSelected(true);
    } catch (java.beans.PropertyVetoException e2) {
    }
}
Also used : JInternalFrame(javax.swing.JInternalFrame)

Example 13 with JInternalFrame

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

the class JmriJInternalFrameInterface method show.

@Override
public void show(final jmri.util.swing.JmriPanel child, jmri.util.swing.JmriAbstractAction act, Hint hint) {
    // create new internal frame
    JInternalFrame frame = new JInternalFrame(child.getTitle(), //resizable
    true, //closable
    true, //maximizable
    true, //iconifiable
    true);
    frame.setLocation(50, 50);
    // add gui object, responsible for own layout
    frame.add(child);
    // add menus if requested
    JMenuBar bar = frame.getJMenuBar();
    if (bar == null) {
        bar = new JMenuBar();
    }
    List<JMenu> list = child.getMenus();
    for (JMenu menu : list) {
        bar.add(menu);
    }
    // to code in JmriJFrame
    if (child.getHelpTarget() != null) {
        // add Help menu
        jmri.util.HelpUtil.helpMenu(bar, child.getHelpTarget(), true);
    }
    frame.setJMenuBar(bar);
    // set title if available
    if (child.getTitle() != null) {
        frame.setTitle(child.getTitle());
    }
    // arrange to run dispose on close
    //frame.addWindowListener( new java.awt.event.WindowAdapter(){
    //    jmri.util.swing.JmriPanel c;
    //    { c = child; }
    //    public void windowClosed(java.awt.event.WindowEvent e) {
    //        c.dispose();
    //    }
    //});
    // add to desktop
    frame.pack();
    frame.setVisible(true);
    desktop.add(frame);
    frame.moveToFront();
}
Also used : JInternalFrame(javax.swing.JInternalFrame) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 14 with JInternalFrame

use of javax.swing.JInternalFrame in project sic by belluccifranco.

the class PrincipalGUI method mnu_CajasActionPerformed.

//GEN-LAST:event_mnuItm_PedidosActionPerformed
private void mnu_CajasActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_mnu_CajasActionPerformed
    JInternalFrame gui = Utilidades.estaEnDesktop(getDesktopPane(), CajasGUI.class);
    if (gui == null) {
        gui = new CajasGUI();
        gui.setLocation(getDesktopPane().getWidth() / 2 - gui.getWidth() / 2, getDesktopPane().getHeight() / 2 - gui.getHeight() / 2);
        getDesktopPane().add(gui);
        gui.setVisible(true);
    } else {
        //selecciona y trae al frente el internalframe
        try {
            gui.setSelected(true);
        } catch (PropertyVetoException ex) {
            String msjError = "No se pudo seleccionar la ventana requerida.";
            LOGGER.error(msjError + " - " + ex.getMessage());
            JOptionPane.showInternalMessageDialog(this.getDesktopPane(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) JInternalFrame(javax.swing.JInternalFrame)

Example 15 with JInternalFrame

use of javax.swing.JInternalFrame in project sic by belluccifranco.

the class PrincipalGUI method mnuItm_FacturasVentaActionPerformed.

//GEN-LAST:event_mnuItm_IrTPVActionPerformed
private void mnuItm_FacturasVentaActionPerformed(java.awt.event.ActionEvent evt) {
    //GEN-FIRST:event_mnuItm_FacturasVentaActionPerformed
    JInternalFrame gui = Utilidades.estaEnDesktop(getDesktopPane(), FacturasVentaGUI.class);
    if (gui == null) {
        gui = new FacturasVentaGUI();
        gui.setLocation(getDesktopPane().getWidth() / 2 - gui.getWidth() / 2, getDesktopPane().getHeight() / 2 - gui.getHeight() / 2);
        getDesktopPane().add(gui);
        gui.setVisible(true);
    } else {
        //selecciona y trae al frente el internalframe
        try {
            gui.setSelected(true);
        } catch (PropertyVetoException ex) {
            String msjError = "No se pudo seleccionar la ventana requerida.";
            LOGGER.error(msjError + " - " + ex.getMessage());
            JOptionPane.showInternalMessageDialog(this.getDesktopPane(), msjError, "Error", JOptionPane.ERROR_MESSAGE);
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) 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