Search in sources :

Example 61 with JComponent

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

the class AbstractNetworkConnectionConfig method showAdvancedItems.

@Override
protected void showAdvancedItems() {
    _details.removeAll();
    cL.anchor = GridBagConstraints.WEST;
    cL.insets = new Insets(2, 5, 0, 5);
    cR.insets = new Insets(2, 0, 0, 5);
    cR.anchor = GridBagConstraints.WEST;
    cR.gridx = 1;
    cL.gridx = 0;
    int i = 0;
    int stdrows = 0;
    boolean incAdvancedOptions = true;
    if (!isPortAdvanced()) {
        stdrows++;
    }
    if (!isHostNameAdvanced()) {
        stdrows++;
    }
    for (String item : options.keySet()) {
        if (!options.get(item).isAdvanced()) {
            stdrows++;
        }
    }
    if (adapter.getSystemConnectionMemo() != null) {
        stdrows = stdrows + 2;
    }
    if (stdrows == NUMOPTIONS) {
        incAdvancedOptions = false;
    }
    _details.setLayout(gbLayout);
    i = addStandardDetails(incAdvancedOptions, i);
    if (showAdvanced.isSelected()) {
        if (isHostNameAdvanced()) {
            cR.gridy = i;
            cL.gridy = i;
            gbLayout.setConstraints(hostNameFieldLabel, cL);
            gbLayout.setConstraints(hostNameField, cR);
            _details.add(hostNameFieldLabel);
            _details.add(hostNameField);
            i++;
        }
        if (isPortAdvanced()) {
            cR.gridy = i;
            cL.gridy = i;
            gbLayout.setConstraints(portFieldLabel, cL);
            gbLayout.setConstraints(portField, cR);
            _details.add(portFieldLabel);
            _details.add(portField);
            i++;
        }
        if (showAutoConfig.isSelected()) {
            cR.gridy = i;
            cL.gridy = i;
            gbLayout.setConstraints(adNameFieldLabel, cL);
            gbLayout.setConstraints(adNameField, cR);
            _details.add(adNameFieldLabel);
            _details.add(adNameField);
            i++;
            cR.gridy = i;
            cL.gridy = i;
            gbLayout.setConstraints(serviceTypeFieldLabel, cL);
            gbLayout.setConstraints(serviceTypeField, cR);
            _details.add(serviceTypeFieldLabel);
            _details.add(serviceTypeField);
            i++;
        }
        for (String item : options.keySet()) {
            if (options.get(item).isAdvanced()) {
                cR.gridy = i;
                cL.gridy = i;
                gbLayout.setConstraints(options.get(item).getLabel(), cL);
                gbLayout.setConstraints(options.get(item).getComponent(), cR);
                _details.add(options.get(item).getLabel());
                _details.add(options.get(item).getComponent());
                i++;
            }
        }
    }
    cL.gridwidth = 2;
    for (JComponent item : additionalItems) {
        cL.gridy = i;
        gbLayout.setConstraints(item, cL);
        _details.add(item);
        i++;
    }
    cL.gridwidth = 1;
    if (_details.getParent() != null && _details.getParent() instanceof javax.swing.JViewport) {
        javax.swing.JViewport vp = (javax.swing.JViewport) _details.getParent();
        vp.revalidate();
        vp.repaint();
    }
}
Also used : Insets(java.awt.Insets) JComponent(javax.swing.JComponent)

Example 62 with JComponent

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

the class AbstractSimulatorConnectionConfig method showAdvancedItems.

@Override
protected void showAdvancedItems() {
    _details.removeAll();
    cL.anchor = GridBagConstraints.WEST;
    cL.insets = new Insets(2, 5, 0, 5);
    cR.insets = new Insets(2, 0, 0, 5);
    cR.anchor = GridBagConstraints.WEST;
    cR.gridx = 1;
    cL.gridx = 0;
    _details.setLayout(gbLayout);
    int i = 0;
    boolean incAdvancedOptions = false;
    for (String item : options.keySet()) {
        if (options.get(item).isAdvanced()) {
            incAdvancedOptions = true;
        }
    }
    i = addStandardDetails(adapter, incAdvancedOptions, i);
    if (showAdvanced.isSelected()) {
        for (String item : options.keySet()) {
            if (options.get(item).isAdvanced()) {
                cR.gridy = i;
                cL.gridy = i;
                gbLayout.setConstraints(options.get(item).getLabel(), cL);
                gbLayout.setConstraints(options.get(item).getComponent(), cR);
                _details.add(options.get(item).getLabel());
                _details.add(options.get(item).getComponent());
                i++;
            }
        }
    }
    cL.gridwidth = 2;
    for (JComponent item : additionalItems) {
        cL.gridy = i;
        gbLayout.setConstraints(item, cL);
        _details.add(item);
        i++;
    }
    cL.gridwidth = 1;
    if (_details.getParent() != null && _details.getParent() instanceof javax.swing.JViewport) {
        javax.swing.JViewport vp = (javax.swing.JViewport) _details.getParent();
        vp.revalidate();
        vp.repaint();
    }
}
Also used : Insets(java.awt.Insets) JComponent(javax.swing.JComponent)

Example 63 with JComponent

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

the class AbstractStreamConnectionConfig method showAdvancedItems.

@Override
protected void showAdvancedItems() {
    _details.removeAll();
    cL.anchor = GridBagConstraints.WEST;
    cL.insets = new Insets(2, 5, 0, 5);
    cR.insets = new Insets(2, 0, 0, 5);
    cR.anchor = GridBagConstraints.WEST;
    cR.gridx = 1;
    cL.gridx = 0;
    _details.setLayout(gbLayout);
    int i = 0;
    boolean incAdvancedOptions = false;
    for (String item : options.keySet()) {
        if (options.get(item).isAdvanced()) {
            incAdvancedOptions = true;
        }
    }
    i = addStandardDetails(adapter, incAdvancedOptions, i);
    if (showAdvanced.isSelected()) {
        for (String item : options.keySet()) {
            if (options.get(item).isAdvanced()) {
                cR.gridy = i;
                cL.gridy = i;
                gbLayout.setConstraints(options.get(item).getLabel(), cL);
                gbLayout.setConstraints(options.get(item).getComponent(), cR);
                _details.add(options.get(item).getLabel());
                _details.add(options.get(item).getComponent());
                i++;
            }
        }
    }
    cL.gridwidth = 2;
    for (JComponent item : additionalItems) {
        cL.gridy = i;
        gbLayout.setConstraints(item, cL);
        _details.add(item);
        i++;
    }
    cL.gridwidth = 1;
    if (_details.getParent() != null && _details.getParent() instanceof javax.swing.JViewport) {
        javax.swing.JViewport vp = (javax.swing.JViewport) _details.getParent();
        vp.revalidate();
        vp.repaint();
    }
}
Also used : Insets(java.awt.Insets) JComponent(javax.swing.JComponent)

Example 64 with JComponent

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

the class Editor method addToTarget.

protected void addToTarget(Positionable l) {
    JComponent c = (JComponent) l;
    c.invalidate();
    _targetPanel.remove(c);
    _targetPanel.add(c, Integer.valueOf(l.getDisplayLevel()));
    _targetPanel.moveToFront(c);
    c.repaint();
    _targetPanel.revalidate();
}
Also used : JComponent(javax.swing.JComponent)

Example 65 with JComponent

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

the class PanelEditor method pasteItem.

protected void pasteItem(MouseEvent e) {
    pasteItemFlag = true;
    XmlAdapter adapter;
    String className;
    int x;
    int y;
    int xOrig;
    int yOrig;
    if (_multiItemCopyGroup != null) {
        JComponent copied;
        int xoffset;
        int yoffset;
        x = _multiItemCopyGroup.get(0).getX();
        y = _multiItemCopyGroup.get(0).getY();
        xoffset = e.getX() - x;
        yoffset = e.getY() - y;
        /*We make a copy of the selected items and work off of that copy
             as amendments are made to the multiItemCopyGroup during this process
             which can result in a loop*/
        ArrayList<Positionable> _copyOfMultiItemCopyGroup = new ArrayList<Positionable>(_multiItemCopyGroup);
        Collections.copy(_copyOfMultiItemCopyGroup, _multiItemCopyGroup);
        for (Positionable comp : _copyOfMultiItemCopyGroup) {
            copied = (JComponent) comp;
            xOrig = copied.getX();
            yOrig = copied.getY();
            x = xOrig + xoffset;
            y = yOrig + yoffset;
            if (x < 0) {
                x = 1;
            }
            if (y < 0) {
                y = 1;
            }
            className = ConfigXmlManager.adapterName(copied);
            copied.setLocation(x, y);
            try {
                adapter = (XmlAdapter) Class.forName(className).newInstance();
                Element el = adapter.store(copied);
                adapter.load(el, this);
            } catch (Exception ex) {
                log.debug(ex.getLocalizedMessage(), ex);
            }
            /*We remove the original item from the list, so we end up with
                 just the new items selected and allow the items to be moved around */
            amendSelectionGroup(comp);
            copied.setLocation(xOrig, yOrig);
        }
        _selectionGroup = null;
    }
    pasteItemFlag = false;
    _targetPanel.repaint();
}
Also used : Element(org.jdom2.Element) JComponent(javax.swing.JComponent) ArrayList(java.util.ArrayList) Positionable(jmri.jmrit.display.Positionable) XmlAdapter(jmri.configurexml.XmlAdapter)

Aggregations

JComponent (javax.swing.JComponent)225 Component (java.awt.Component)44 JPanel (javax.swing.JPanel)37 JLabel (javax.swing.JLabel)34 JButton (javax.swing.JButton)28 BorderLayout (java.awt.BorderLayout)27 Dimension (java.awt.Dimension)23 Insets (java.awt.Insets)20 ActionEvent (java.awt.event.ActionEvent)16 ArrayList (java.util.ArrayList)16 ActionListener (java.awt.event.ActionListener)15 Color (java.awt.Color)13 GridBagConstraints (java.awt.GridBagConstraints)13 Point (java.awt.Point)13 GridBagLayout (java.awt.GridBagLayout)12 JScrollPane (javax.swing.JScrollPane)12 JTextField (javax.swing.JTextField)12 JFrame (javax.swing.JFrame)11 Container (java.awt.Container)8 FlowLayout (java.awt.FlowLayout)8