Example usage for java.awt.event ComponentAdapter ComponentAdapter

List of usage examples for java.awt.event ComponentAdapter ComponentAdapter

Introduction

In this page you can find the example usage for java.awt.event ComponentAdapter ComponentAdapter.

Prototype

ComponentAdapter

Source Link

Usage

From source file:net.schweerelos.parrot.CombinedParrotApp.java

@SuppressWarnings("serial")
private JToggleButton setupNavigatorButton(final String name, final String accelerator,
        final NavigatorComponent navigator) {
    final Component component = navigator.asJComponent();
    AbstractAction showNavigatorAction = new AbstractAction(name) {
        @Override/*from   w  w w.j a  va 2s . c om*/
        public void actionPerformed(ActionEvent e) {
            if (!(e.getSource() instanceof JToggleButton)) {
                return;
            }
            final Window window;
            if (component instanceof Window) {
                window = (Window) component;
            } else {
                window = SwingUtilities.getWindowAncestor(component);
            }
            JToggleButton button = (JToggleButton) e.getSource();
            boolean show = button.isSelected();
            if (show) {
                if (window != CombinedParrotApp.this && preferredFrameLocations.containsKey(window)) {
                    window.setLocation(preferredFrameLocations.get(window));
                }
            }
            if (navigator.tellSelectionWhenShown()) {
                Collection<NodeWrapper> selectedNodes = activeMainView.getSelectedNodes();
                navigator.setSelectedNodes(selectedNodes);
            }
            component.setVisible(show);
            if (show) {
                window.setVisible(true);
            } else if (window != CombinedParrotApp.this) {
                window.setVisible(false);
            }
        }
    };
    showNavigatorAction.putValue(Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke("control " + accelerator));
    final JToggleButton button = new JToggleButton(showNavigatorAction);
    button.setToolTipText("Show " + name.toLowerCase());
    button.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            button.setToolTipText((button.isSelected() ? "Hide " : "Show ") + name.toLowerCase());
        }
    });
    final Window window;
    if (component instanceof Window) {
        window = (Window) component;
    } else {
        window = SwingUtilities.getWindowAncestor(component);
    }
    if (window != null) {
        window.addComponentListener(new ComponentAdapter() {
            @Override
            public void componentHidden(ComponentEvent e) {
                button.setSelected(false);
                if (window != CombinedParrotApp.this) {
                    preferredFrameLocations.put(window, window.getLocation());
                }
            }

            @Override
            public void componentShown(ComponentEvent e) {
                button.setSelected(true);
            }
        });
    }
    return button;
}

From source file:shuffle.fwk.service.teams.EditTeamService.java

@SuppressWarnings("serial")
private Component makeRosterPanel() {
    rosterPanel = new JPanel(new WrapLayout()) {
        // Fix to make it play nice with the scroll bar.
        @Override/*from   w ww  .j  av  a2  s.  com*/
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width = (int) (d.getWidth() - 20);
            return d;
        }
    };
    rosterScrollPane = new JScrollPane(rosterPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    rosterScrollPane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            rosterScrollPane.revalidate();
        }
    });
    rosterScrollPane.getVerticalScrollBar().setUnitIncrement(27);
    return rosterScrollPane;
}

From source file:com.net2plan.gui.utils.topologyPane.TopologyPanel.java

/**
 * Default constructor.//from  w  ww.  j  a  v a2  s.co  m
 *
 * @param callback               Topology callback listening plugin events
 * @param defaultDesignDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/networkTopologies})
 * @param defaultDemandDirectory Default location for design {@code .n2p} files (it may be null, then default is equal to {@code net2planFolder/workspace/data/trafficMatrices})
 * @param canvasType             Canvas type (i.e. JUNG)
 * @param plugins                List of plugins to be included (it may be null)
 */
public TopologyPanel(final IVisualizationCallback callback, File defaultDesignDirectory,
        File defaultDemandDirectory, Class<? extends ITopologyCanvas> canvasType,
        List<ITopologyCanvasPlugin> plugins) {
    File currentDir = SystemUtils.getCurrentDir();

    this.callback = callback;
    this.defaultDesignDirectory = defaultDesignDirectory == null ? new File(
            currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator()
                    + "data" + SystemUtils.getDirectorySeparator() + "networkTopologies")
            : defaultDesignDirectory;
    this.defaultDemandDirectory = defaultDemandDirectory == null ? new File(
            currentDir + SystemUtils.getDirectorySeparator() + "workspace" + SystemUtils.getDirectorySeparator()
                    + "data" + SystemUtils.getDirectorySeparator() + "trafficMatrices")
            : defaultDemandDirectory;
    this.multilayerControlPanel = new MultiLayerControlPanel(callback);

    try {
        canvas = canvasType.getDeclaredConstructor(IVisualizationCallback.class, TopologyPanel.class)
                .newInstance(callback, this);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }

    if (plugins != null)
        for (ITopologyCanvasPlugin plugin : plugins)
            addPlugin(plugin);

    setLayout(new BorderLayout());

    JToolBar toolbar = new JToolBar();
    toolbar.setRollover(true);
    toolbar.setFloatable(false);
    toolbar.setOpaque(false);
    toolbar.setBorderPainted(false);

    JPanel topPanel = new JPanel(new BorderLayout());
    topPanel.add(toolbar, BorderLayout.NORTH);

    add(topPanel, BorderLayout.NORTH);

    JComponent canvasComponent = canvas.getCanvasComponent();

    canvasPanel = new JPanel(new BorderLayout());
    canvasComponent.setBorder(LineBorder.createBlackLineBorder());

    JToolBar multiLayerToolbar = new JToolBar(JToolBar.VERTICAL);
    multiLayerToolbar.setRollover(true);
    multiLayerToolbar.setFloatable(false);
    multiLayerToolbar.setOpaque(false);

    canvasPanel.add(canvasComponent, BorderLayout.CENTER);
    canvasPanel.add(multiLayerToolbar, BorderLayout.WEST);
    add(canvasPanel, BorderLayout.CENTER);

    btn_load = new JButton();
    btn_load.setToolTipText("Load a network design");
    btn_loadDemand = new JButton();
    btn_loadDemand.setToolTipText("Load a traffic demand set");
    btn_save = new JButton();
    btn_save.setToolTipText("Save current state to a file");
    btn_zoomIn = new JButton();
    btn_zoomIn.setToolTipText("Zoom in");
    btn_zoomOut = new JButton();
    btn_zoomOut.setToolTipText("Zoom out");
    btn_zoomAll = new JButton();
    btn_zoomAll.setToolTipText("Zoom all");
    btn_takeSnapshot = new JButton();
    btn_takeSnapshot.setToolTipText("Take a snapshot of the canvas");
    btn_showNodeNames = new JToggleButton();
    btn_showNodeNames.setToolTipText("Show/hide node names");
    btn_showLinkIds = new JToggleButton();
    btn_showLinkIds.setToolTipText(
            "Show/hide link utilization, measured as the ratio between the total traffic in the link (including that in protection segments) and total link capacity (including that reserved by protection segments)");
    btn_showNonConnectedNodes = new JToggleButton();
    btn_showNonConnectedNodes.setToolTipText("Show/hide non-connected nodes");
    btn_increaseNodeSize = new JButton();
    btn_increaseNodeSize.setToolTipText("Increase node size");
    btn_decreaseNodeSize = new JButton();
    btn_decreaseNodeSize.setToolTipText("Decrease node size");
    btn_increaseFontSize = new JButton();
    btn_increaseFontSize.setToolTipText("Increase font size");
    btn_decreaseFontSize = new JButton();
    btn_decreaseFontSize.setToolTipText("Decrease font size");
    /* Multilayer buttons */
    btn_increaseInterLayerDistance = new JButton();
    btn_increaseInterLayerDistance
            .setToolTipText("Increase the distance between layers (when more than one layer is visible)");
    btn_decreaseInterLayerDistance = new JButton();
    btn_decreaseInterLayerDistance
            .setToolTipText("Decrease the distance between layers (when more than one layer is visible)");
    btn_showLowerLayerInfo = new JToggleButton();
    btn_showLowerLayerInfo
            .setToolTipText("Shows the links in lower layers that carry traffic of the picked element");
    btn_showLowerLayerInfo.setSelected(getVisualizationState().isShowInCanvasLowerLayerPropagation());
    btn_showUpperLayerInfo = new JToggleButton();
    btn_showUpperLayerInfo.setToolTipText(
            "Shows the links in upper layers that carry traffic that appears in the picked element");
    btn_showUpperLayerInfo.setSelected(getVisualizationState().isShowInCanvasUpperLayerPropagation());
    btn_showThisLayerInfo = new JToggleButton();
    btn_showThisLayerInfo.setToolTipText(
            "Shows the links in the same layer as the picked element, that carry traffic that appears in the picked element");
    btn_showThisLayerInfo.setSelected(getVisualizationState().isShowInCanvasThisLayerPropagation());
    btn_npChangeUndo = new JButton();
    btn_npChangeUndo.setToolTipText(
            "Navigate back to the previous state of the network (last time the network design was changed)");
    btn_npChangeRedo = new JButton();
    btn_npChangeRedo.setToolTipText(
            "Navigate forward to the next state of the network (when network design was changed");

    btn_osmMap = new JToggleButton();
    btn_osmMap.setToolTipText(
            "Toggle between on/off the OSM support. An internet connection is required in order for this to work.");
    btn_tableControlWindow = new JButton();
    btn_tableControlWindow.setToolTipText("Show the network topology control window.");

    // MultiLayer control window
    JPopupMenu multiLayerPopUp = new JPopupMenu();
    multiLayerPopUp.add(multilayerControlPanel);
    JPopUpButton btn_multilayer = new JPopUpButton("", multiLayerPopUp);

    btn_reset = new JButton("Reset");
    btn_reset.setToolTipText("Reset the user interface");
    btn_reset.setMnemonic(KeyEvent.VK_R);

    btn_load.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDesign.png")));
    btn_loadDemand.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/loadDemand.png")));
    btn_save.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/saveDesign.png")));
    btn_showNodeNames
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNodeName.png")));
    btn_showLinkIds
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLinkUtilization.png")));
    btn_showNonConnectedNodes.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png")));
    //btn_whatIfActivated.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showNonConnectedNodes.png")));
    btn_zoomIn.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomIn.png")));
    btn_zoomOut.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomOut.png")));
    btn_zoomAll.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/zoomAll.png")));
    btn_takeSnapshot.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/takeSnapshot.png")));
    btn_increaseNodeSize
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseNode.png")));
    btn_decreaseNodeSize
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseNode.png")));
    btn_increaseFontSize
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseFont.png")));
    btn_decreaseFontSize
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseFont.png")));
    btn_increaseInterLayerDistance.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/increaseLayerDistance.png")));
    btn_decreaseInterLayerDistance.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/decreaseLayerDistance.png")));
    btn_multilayer
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerControl.png")));
    btn_showThisLayerInfo
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerPropagation.png")));
    btn_showUpperLayerInfo.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerUpperPropagation.png")));
    btn_showLowerLayerInfo.setIcon(
            new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showLayerLowerPropagation.png")));
    btn_tableControlWindow
            .setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showControl.png")));
    btn_osmMap.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/showOSM.png")));
    btn_npChangeUndo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/undoButton.png")));
    btn_npChangeRedo.setIcon(new ImageIcon(TopologyPanel.class.getResource("/resources/gui/redoButton.png")));

    btn_load.addActionListener(this);
    btn_loadDemand.addActionListener(this);
    btn_save.addActionListener(this);
    btn_showNodeNames.addActionListener(this);
    btn_showLinkIds.addActionListener(this);
    btn_showNonConnectedNodes.addActionListener(this);
    btn_zoomIn.addActionListener(this);
    btn_zoomOut.addActionListener(this);
    btn_zoomAll.addActionListener(this);
    btn_takeSnapshot.addActionListener(this);
    btn_reset.addActionListener(this);
    btn_increaseInterLayerDistance.addActionListener(this);
    btn_decreaseInterLayerDistance.addActionListener(this);
    btn_showLowerLayerInfo.addActionListener(this);
    btn_showUpperLayerInfo.addActionListener(this);
    btn_showThisLayerInfo.addActionListener(this);
    btn_increaseNodeSize.addActionListener(this);
    btn_decreaseNodeSize.addActionListener(this);
    btn_increaseFontSize.addActionListener(this);
    btn_decreaseFontSize.addActionListener(this);
    btn_npChangeUndo.addActionListener(this);
    btn_npChangeRedo.addActionListener(this);
    btn_osmMap.addActionListener(this);
    btn_tableControlWindow.addActionListener(this);

    toolbar.add(btn_load);
    toolbar.add(btn_loadDemand);
    toolbar.add(btn_save);
    toolbar.add(new JToolBar.Separator());
    toolbar.add(btn_zoomIn);
    toolbar.add(btn_zoomOut);
    toolbar.add(btn_zoomAll);
    toolbar.add(btn_takeSnapshot);
    toolbar.add(new JToolBar.Separator());
    toolbar.add(btn_showNodeNames);
    toolbar.add(btn_showLinkIds);
    toolbar.add(btn_showNonConnectedNodes);
    toolbar.add(new JToolBar.Separator());
    toolbar.add(btn_increaseNodeSize);
    toolbar.add(btn_decreaseNodeSize);
    toolbar.add(btn_increaseFontSize);
    toolbar.add(btn_decreaseFontSize);
    toolbar.add(new JToolBar.Separator());
    toolbar.add(Box.createHorizontalGlue());
    toolbar.add(btn_osmMap);
    toolbar.add(btn_tableControlWindow);
    toolbar.add(btn_reset);

    multiLayerToolbar.add(new JToolBar.Separator());
    multiLayerToolbar.add(btn_multilayer);
    multiLayerToolbar.add(btn_increaseInterLayerDistance);
    multiLayerToolbar.add(btn_decreaseInterLayerDistance);
    multiLayerToolbar.add(btn_showLowerLayerInfo);
    multiLayerToolbar.add(btn_showUpperLayerInfo);
    multiLayerToolbar.add(btn_showThisLayerInfo);
    multiLayerToolbar.add(Box.createVerticalGlue());
    multiLayerToolbar.add(btn_npChangeUndo);
    multiLayerToolbar.add(btn_npChangeRedo);

    this.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            if (e.getComponent().getSize().getHeight() != 0 && e.getComponent().getSize().getWidth() != 0) {
                canvas.zoomAll();
            }
        }
    });

    List<Component> children = SwingUtils.getAllComponents(this);
    for (Component component : children)
        if (component instanceof AbstractButton)
            component.setFocusable(false);

    if (ErrorHandling.isDebugEnabled()) {
        canvas.getCanvasComponent().addMouseMotionListener(new MouseMotionAdapter() {
            @Override
            public void mouseMoved(MouseEvent e) {
                Point point = e.getPoint();
                position.setText("view = " + point + ", NetPlan coord = "
                        + canvas.getCanvasPointFromNetPlanPoint(point));
            }
        });

        position = new JLabel();
        add(position, BorderLayout.SOUTH);
    } else {
        position = null;
    }

    new FileDrop(canvasComponent, new LineBorder(Color.BLACK), new FileDrop.Listener() {
        @Override
        public void filesDropped(File[] files) {
            for (File file : files) {
                try {
                    if (!file.getName().toLowerCase(Locale.getDefault()).endsWith(".n2p"))
                        return;
                    loadDesignFromFile(file);
                    break;
                } catch (Throwable e) {
                    break;
                }
            }
        }
    });

    btn_showNodeNames.setSelected(getVisualizationState().isCanvasShowNodeNames());
    btn_showLinkIds.setSelected(getVisualizationState().isCanvasShowLinkLabels());
    btn_showNonConnectedNodes.setSelected(getVisualizationState().isCanvasShowNonConnectedNodes());

    final ITopologyCanvasPlugin popupPlugin = new PopupMenuPlugin(callback, this.canvas);
    addPlugin(new PanGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK));
    if (callback.getVisualizationState().isNetPlanEditable() && getCanvas() instanceof JUNGCanvas)
        addPlugin(new AddLinkGraphPlugin(callback, canvas, MouseEvent.BUTTON1_MASK,
                MouseEvent.BUTTON1_MASK | MouseEvent.SHIFT_MASK));
    addPlugin(popupPlugin);
    if (callback.getVisualizationState().isNetPlanEditable())
        addPlugin(new MoveNodePlugin(callback, canvas, MouseEvent.BUTTON1_MASK | MouseEvent.CTRL_MASK));

    setBorder(BorderFactory.createTitledBorder(new LineBorder(Color.BLACK), "Network topology"));
    //        setAllowLoadTrafficDemand(callback.allowLoadTrafficDemands());
}

From source file:op.care.prescription.PnlScheduleDose.java

/**
 * This method is called from within the constructor to
 * initialize the form.//from   ww  w .  j  a va 2  s  . co m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    panelMain = new JPanel();
    splitRegular = new JSplitPane();
    pnlTageszeit = new JPanel();
    lblVeryEarly = new JideLabel();
    lblMorning = new JideLabel();
    lblNoon = new JideLabel();
    lblAfternoon = new JideLabel();
    lblEvening = new JideLabel();
    lblVeryLate = new JideLabel();
    txtVeryEarly = new JTextField();
    txtMorning = new JTextField();
    txtNoon = new JTextField();
    txtAfternoon = new JTextField();
    txtEvening = new JTextField();
    txtVeryLate = new JTextField();
    btnToTime = new JButton();
    pnlUhrzeit = new JPanel();
    lblTimeDose = new JideLabel();
    btnToTimeOfDay = new JButton();
    txtTimeDose = new JTextField();
    cmbUhrzeit = new JComboBox();
    tabWdh = new JideTabbedPane();
    pnlDaily = new JPanel();
    lblEvery1 = new JLabel();
    txtEveryDay = new JTextField();
    lblDays = new JLabel();
    btnEveryDay = new JideButton();
    pnlWeekly = new JPanel();
    panel3 = new JPanel();
    lblEvery2 = new JLabel();
    txtEveryWeek = new JTextField();
    lblWeeksAt = new JLabel();
    btnEveryWeek = new JideButton();
    lblMon = new JideLabel();
    lblTue = new JideLabel();
    lblWed = new JideLabel();
    lblThu = new JideLabel();
    lblFri = new JideLabel();
    lblSat = new JideLabel();
    lblSun = new JideLabel();
    cbMon = new JCheckBox();
    cbTue = new JCheckBox();
    cbWed = new JCheckBox();
    cbThu = new JCheckBox();
    cbFri = new JCheckBox();
    cbSat = new JCheckBox();
    cbSun = new JCheckBox();
    pnlMonthly = new JPanel();
    lblEach = new JLabel();
    txtEveryMonth = new JTextField();
    lblMonth = new JLabel();
    btnEveryMonth = new JideButton();
    lblOnThe = new JLabel();
    txtEveryWDayOfMonth = new JTextField();
    cmbWDay = new JComboBox();
    panel2 = new JPanel();
    lblLDate = new JLabel();
    txtLDate = new JTextField();
    btnSave = new JButton();

    //======== this ========
    setLayout(new BorderLayout());

    //======== panelMain ========
    {
        panelMain.setBorder(new LineBorder(Color.black, 2, true));
        panelMain.addComponentListener(new ComponentAdapter() {
            @Override
            public void componentResized(ComponentEvent e) {
                panelMainComponentResized(e);
            }
        });
        panelMain.setLayout(new FormLayout("$rgap, $lcgap, 223dlu, $lcgap, $rgap",
                "$rgap, 2*($lgap, pref), 2*($lgap, default), $lgap, $rgap"));

        //======== splitRegular ========
        {
            splitRegular.setDividerSize(0);
            splitRegular.setEnabled(false);
            splitRegular.setDividerLocation(300);
            splitRegular.setDoubleBuffered(true);

            //======== pnlTageszeit ========
            {
                pnlTageszeit.setFont(new Font("Arial", Font.PLAIN, 14));
                pnlTageszeit.setBorder(new EtchedBorder());
                pnlTageszeit.setLayout(
                        new FormLayout("6*(28dlu, $lcgap), default", "fill:default, $lgap, fill:default"));

                //---- lblVeryEarly ----
                lblVeryEarly.setText("Nachts, fr\u00fch morgens");
                lblVeryEarly.setOrientation(1);
                lblVeryEarly.setFont(new Font("Arial", Font.PLAIN, 14));
                lblVeryEarly.setClockwise(false);
                lblVeryEarly.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlTageszeit.add(lblVeryEarly, CC.xy(1, 1));

                //---- lblMorning ----
                lblMorning.setForeground(new Color(0, 0, 204));
                lblMorning.setText("Morgens");
                lblMorning.setOrientation(1);
                lblMorning.setFont(new Font("Arial", Font.PLAIN, 14));
                lblMorning.setClockwise(false);
                lblMorning.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlTageszeit.add(lblMorning, CC.xy(3, 1));

                //---- lblNoon ----
                lblNoon.setForeground(new Color(255, 102, 0));
                lblNoon.setText("Mittags");
                lblNoon.setOrientation(1);
                lblNoon.setFont(new Font("Arial", Font.PLAIN, 14));
                lblNoon.setClockwise(false);
                lblNoon.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlTageszeit.add(lblNoon, CC.xy(5, 1));

                //---- lblAfternoon ----
                lblAfternoon.setForeground(new Color(0, 153, 51));
                lblAfternoon.setText("Nachmittag");
                lblAfternoon.setOrientation(1);
                lblAfternoon.setFont(new Font("Arial", Font.PLAIN, 14));
                lblAfternoon.setClockwise(false);
                lblAfternoon.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlTageszeit.add(lblAfternoon, CC.xy(7, 1));

                //---- lblEvening ----
                lblEvening.setForeground(new Color(255, 0, 51));
                lblEvening.setText("Abends");
                lblEvening.setOrientation(1);
                lblEvening.setFont(new Font("Arial", Font.PLAIN, 14));
                lblEvening.setClockwise(false);
                lblEvening.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlTageszeit.add(lblEvening, CC.xy(9, 1));

                //---- lblVeryLate ----
                lblVeryLate.setText("Nacht, sp\u00e4t abends");
                lblVeryLate.setOrientation(1);
                lblVeryLate.setFont(new Font("Arial", Font.PLAIN, 14));
                lblVeryLate.setClockwise(false);
                lblVeryLate.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlTageszeit.add(lblVeryLate, CC.xy(11, 1));

                //---- txtVeryEarly ----
                txtVeryEarly.setHorizontalAlignment(SwingConstants.RIGHT);
                txtVeryEarly.setText("0.0");
                txtVeryEarly.setFont(new Font("Arial", Font.PLAIN, 14));
                txtVeryEarly.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusGained(FocusEvent e) {
                        txtFocusGained(e);
                    }

                    @Override
                    public void focusLost(FocusEvent e) {
                        txtDoubleFocusLost(e);
                    }
                });
                txtVeryEarly.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        txtActionPerformed(e);
                    }
                });
                pnlTageszeit.add(txtVeryEarly, CC.xy(1, 3));

                //---- txtMorning ----
                txtMorning.setHorizontalAlignment(SwingConstants.RIGHT);
                txtMorning.setText("1.0");
                txtMorning.setFont(new Font("Arial", Font.PLAIN, 14));
                txtMorning.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusGained(FocusEvent e) {
                        txtFocusGained(e);
                    }

                    @Override
                    public void focusLost(FocusEvent e) {
                        txtDoubleFocusLost(e);
                    }
                });
                txtMorning.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        txtActionPerformed(e);
                    }
                });
                pnlTageszeit.add(txtMorning, CC.xy(3, 3));

                //---- txtNoon ----
                txtNoon.setHorizontalAlignment(SwingConstants.RIGHT);
                txtNoon.setText("0.0");
                txtNoon.setFont(new Font("Arial", Font.PLAIN, 14));
                txtNoon.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusGained(FocusEvent e) {
                        txtFocusGained(e);
                    }

                    @Override
                    public void focusLost(FocusEvent e) {
                        txtDoubleFocusLost(e);
                    }
                });
                txtNoon.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        txtActionPerformed(e);
                    }
                });
                pnlTageszeit.add(txtNoon, CC.xy(5, 3));

                //---- txtAfternoon ----
                txtAfternoon.setHorizontalAlignment(SwingConstants.RIGHT);
                txtAfternoon.setText("0.0");
                txtAfternoon.setFont(new Font("Arial", Font.PLAIN, 14));
                txtAfternoon.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusGained(FocusEvent e) {
                        txtFocusGained(e);
                    }

                    @Override
                    public void focusLost(FocusEvent e) {
                        txtDoubleFocusLost(e);
                    }
                });
                txtAfternoon.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        txtActionPerformed(e);
                    }
                });
                pnlTageszeit.add(txtAfternoon, CC.xy(7, 3));

                //---- txtEvening ----
                txtEvening.setHorizontalAlignment(SwingConstants.RIGHT);
                txtEvening.setText("0.0");
                txtEvening.setFont(new Font("Arial", Font.PLAIN, 14));
                txtEvening.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusGained(FocusEvent e) {
                        txtFocusGained(e);
                    }

                    @Override
                    public void focusLost(FocusEvent e) {
                        txtDoubleFocusLost(e);
                    }
                });
                txtEvening.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        txtActionPerformed(e);
                    }
                });
                pnlTageszeit.add(txtEvening, CC.xy(9, 3));

                //---- txtVeryLate ----
                txtVeryLate.setHorizontalAlignment(SwingConstants.RIGHT);
                txtVeryLate.setText("0.0");
                txtVeryLate.setFont(new Font("Arial", Font.PLAIN, 14));
                txtVeryLate.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusGained(FocusEvent e) {
                        txtFocusGained(e);
                    }

                    @Override
                    public void focusLost(FocusEvent e) {
                        txtDoubleFocusLost(e);
                    }
                });
                txtVeryLate.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        txtActionPerformed(e);
                    }
                });
                pnlTageszeit.add(txtVeryLate, CC.xy(11, 3));

                //---- btnToTime ----
                btnToTime.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/clock.png")));
                btnToTime.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        btnToTimeActionPerformed(e);
                    }
                });
                pnlTageszeit.add(btnToTime, CC.xy(13, 3));
            }
            splitRegular.setLeftComponent(pnlTageszeit);

            //======== pnlUhrzeit ========
            {
                pnlUhrzeit.setBorder(new EtchedBorder());
                pnlUhrzeit.setLayout(
                        new FormLayout("default, $ugap, 28dlu, $ugap, pref", "default:grow, $rgap, default"));

                //---- lblTimeDose ----
                lblTimeDose.setText("Dosis zur Uhrzeit");
                lblTimeDose.setOrientation(1);
                lblTimeDose.setFont(new Font("Arial", Font.PLAIN, 14));
                lblTimeDose.setClockwise(false);
                lblTimeDose.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlUhrzeit.add(lblTimeDose, CC.xy(3, 1, CC.DEFAULT, CC.BOTTOM));

                //---- btnToTimeOfDay ----
                btnToTimeOfDay
                        .setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/1rightarrow.png")));
                btnToTimeOfDay.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        btnToTimeOfDayActionPerformed(e);
                    }
                });
                pnlUhrzeit.add(btnToTimeOfDay, CC.xy(1, 3));

                //---- txtTimeDose ----
                txtTimeDose.setHorizontalAlignment(SwingConstants.RIGHT);
                txtTimeDose.setText("0.0");
                txtTimeDose.setFont(new Font("Arial", Font.PLAIN, 14));
                txtTimeDose.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusGained(FocusEvent e) {
                        txtFocusGained(e);
                    }

                    @Override
                    public void focusLost(FocusEvent e) {
                        txtDoubleFocusLost(e);
                    }
                });
                pnlUhrzeit.add(txtTimeDose, CC.xy(3, 3));

                //---- cmbUhrzeit ----
                cmbUhrzeit.addItemListener(new ItemListener() {
                    @Override
                    public void itemStateChanged(ItemEvent e) {
                        cmbUhrzeitItemStateChanged(e);
                    }
                });
                pnlUhrzeit.add(cmbUhrzeit, CC.xy(5, 3));
            }
            splitRegular.setRightComponent(pnlUhrzeit);
        }
        panelMain.add(splitRegular, CC.xy(3, 3));

        //======== tabWdh ========
        {

            //======== pnlDaily ========
            {
                pnlDaily.setFont(new Font("Arial", Font.PLAIN, 14));
                pnlDaily.setLayout(new FormLayout("2*(default), $rgap, $lcgap, 40dlu, $rgap, default",
                        "default, $lgap, pref, $lgap, default"));

                //---- lblEvery1 ----
                lblEvery1.setText("alle");
                lblEvery1.setFont(new Font("Arial", Font.PLAIN, 14));
                pnlDaily.add(lblEvery1, CC.xy(2, 3));

                //---- txtEveryDay ----
                txtEveryDay.setFont(new Font("Arial", Font.PLAIN, 14));
                txtEveryDay.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusLost(FocusEvent e) {
                        txtEveryDayFocusLost(e);
                    }
                });
                pnlDaily.add(txtEveryDay, CC.xy(5, 3));

                //---- lblDays ----
                lblDays.setText("Tage");
                lblDays.setFont(new Font("Arial", Font.PLAIN, 14));
                pnlDaily.add(lblDays, CC.xy(7, 3));

                //---- btnEveryDay ----
                btnEveryDay.setText("Jeden Tag");
                btnEveryDay.setButtonStyle(3);
                btnEveryDay.setFont(new Font("Arial", Font.BOLD, 14));
                btnEveryDay.setForeground(Color.blue);
                btnEveryDay.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        btnJedenTagActionPerformed(e);
                    }
                });
                pnlDaily.add(btnEveryDay, CC.xywh(2, 5, 6, 1));
            }
            tabWdh.addTab("T\u00e4glich", pnlDaily);

            //======== pnlWeekly ========
            {
                pnlWeekly.setFont(new Font("Arial", Font.PLAIN, 14));
                pnlWeekly.setLayout(new FormLayout("default, 7*(13dlu), $lcgap, default:grow",
                        "$ugap, $lgap, default, $lgap, pref, $lgap, default:grow, $lgap, $rgap"));

                //======== panel3 ========
                {
                    panel3.setLayout(new FormLayout("default, $rgap, 40dlu, $rgap, 2*(default)",
                            "default:grow, $lgap, default"));

                    //---- lblEvery2 ----
                    lblEvery2.setText("alle");
                    lblEvery2.setFont(new Font("Arial", Font.PLAIN, 14));
                    panel3.add(lblEvery2, CC.xy(1, 1));

                    //---- txtEveryWeek ----
                    txtEveryWeek.addFocusListener(new FocusAdapter() {
                        @Override
                        public void focusLost(FocusEvent e) {
                            txtEveryWeekFocusLost(e);
                        }
                    });
                    panel3.add(txtEveryWeek, CC.xy(3, 1));

                    //---- lblWeeksAt ----
                    lblWeeksAt.setText("Wochen am");
                    lblWeeksAt.setFont(new Font("Arial", Font.PLAIN, 14));
                    panel3.add(lblWeeksAt, CC.xy(5, 1));

                    //---- btnEveryWeek ----
                    btnEveryWeek.setText("Jede Woche");
                    btnEveryWeek.setFont(new Font("Arial", Font.BOLD, 14));
                    btnEveryWeek.setButtonStyle(3);
                    btnEveryWeek.setForeground(Color.blue);
                    btnEveryWeek.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
                            btnJedeWocheActionPerformed(e);
                        }
                    });
                    panel3.add(btnEveryWeek, CC.xywh(1, 3, 5, 1));
                }
                pnlWeekly.add(panel3, CC.xywh(2, 3, 9, 1));

                //---- lblMon ----
                lblMon.setText("montags");
                lblMon.setOrientation(1);
                lblMon.setFont(new Font("Arial", Font.PLAIN, 14));
                lblMon.setClockwise(false);
                lblMon.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlWeekly.add(lblMon, CC.xy(2, 5, CC.CENTER, CC.BOTTOM));

                //---- lblTue ----
                lblTue.setText("dienstags");
                lblTue.setOrientation(1);
                lblTue.setFont(new Font("Arial", Font.PLAIN, 14));
                lblTue.setClockwise(false);
                lblTue.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlWeekly.add(lblTue, CC.xy(3, 5, CC.CENTER, CC.BOTTOM));

                //---- lblWed ----
                lblWed.setText("mittwochs");
                lblWed.setOrientation(1);
                lblWed.setFont(new Font("Arial", Font.PLAIN, 14));
                lblWed.setClockwise(false);
                lblWed.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlWeekly.add(lblWed, CC.xy(4, 5, CC.CENTER, CC.BOTTOM));

                //---- lblThu ----
                lblThu.setText("donnerstags");
                lblThu.setOrientation(1);
                lblThu.setFont(new Font("Arial", Font.PLAIN, 14));
                lblThu.setClockwise(false);
                lblThu.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlWeekly.add(lblThu, CC.xy(5, 5, CC.CENTER, CC.BOTTOM));

                //---- lblFri ----
                lblFri.setText("freitags");
                lblFri.setOrientation(1);
                lblFri.setFont(new Font("Arial", Font.PLAIN, 14));
                lblFri.setClockwise(false);
                lblFri.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlWeekly.add(lblFri, CC.xy(6, 5, CC.CENTER, CC.BOTTOM));

                //---- lblSat ----
                lblSat.setText("samstags");
                lblSat.setOrientation(1);
                lblSat.setFont(new Font("Arial", Font.PLAIN, 14));
                lblSat.setClockwise(false);
                lblSat.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlWeekly.add(lblSat, CC.xy(7, 5, CC.CENTER, CC.BOTTOM));

                //---- lblSun ----
                lblSun.setText("sonntags");
                lblSun.setOrientation(1);
                lblSun.setFont(new Font("Arial", Font.PLAIN, 14));
                lblSun.setClockwise(false);
                lblSun.setHorizontalTextPosition(SwingConstants.LEFT);
                pnlWeekly.add(lblSun, CC.xy(8, 5, CC.CENTER, CC.BOTTOM));

                //---- cbMon ----
                cbMon.setBorder(BorderFactory.createEmptyBorder());
                cbMon.setMargin(new Insets(0, 0, 0, 0));
                cbMon.setSelected(true);
                cbMon.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        cbMonActionPerformed(e);
                    }
                });
                pnlWeekly.add(cbMon, CC.xy(2, 7, CC.CENTER, CC.DEFAULT));

                //---- cbTue ----
                cbTue.setBorder(BorderFactory.createEmptyBorder());
                cbTue.setMargin(new Insets(0, 0, 0, 0));
                cbTue.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        cbTueActionPerformed(e);
                    }
                });
                pnlWeekly.add(cbTue, CC.xy(3, 7, CC.CENTER, CC.DEFAULT));

                //---- cbWed ----
                cbWed.setBorder(BorderFactory.createEmptyBorder());
                cbWed.setMargin(new Insets(0, 0, 0, 0));
                cbWed.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        cbWedActionPerformed(e);
                    }
                });
                pnlWeekly.add(cbWed, CC.xy(4, 7, CC.CENTER, CC.DEFAULT));

                //---- cbThu ----
                cbThu.setBorder(BorderFactory.createEmptyBorder());
                cbThu.setMargin(new Insets(0, 0, 0, 0));
                cbThu.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        cbThuActionPerformed(e);
                    }
                });
                pnlWeekly.add(cbThu, CC.xy(5, 7, CC.CENTER, CC.DEFAULT));

                //---- cbFri ----
                cbFri.setBorder(BorderFactory.createEmptyBorder());
                cbFri.setMargin(new Insets(0, 0, 0, 0));
                cbFri.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        cbFriActionPerformed(e);
                    }
                });
                pnlWeekly.add(cbFri, CC.xy(6, 7, CC.CENTER, CC.DEFAULT));

                //---- cbSat ----
                cbSat.setBorder(BorderFactory.createEmptyBorder());
                cbSat.setMargin(new Insets(0, 0, 0, 0));
                cbSat.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        cbSatActionPerformed(e);
                    }
                });
                pnlWeekly.add(cbSat, CC.xy(7, 7, CC.CENTER, CC.DEFAULT));

                //---- cbSun ----
                cbSun.setBorder(BorderFactory.createEmptyBorder());
                cbSun.setMargin(new Insets(0, 0, 0, 0));
                cbSun.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        cbSunActionPerformed(e);
                    }
                });
                pnlWeekly.add(cbSun, CC.xy(8, 7, CC.CENTER, CC.DEFAULT));
            }
            tabWdh.addTab("W\u00f6chentlich", pnlWeekly);

            //======== pnlMonthly ========
            {
                pnlMonthly.setFont(new Font("Arial", Font.PLAIN, 14));
                pnlMonthly.setLayout(new FormLayout(
                        "default, $lcgap, pref, $lcgap, 40dlu, $lcgap, pref, $lcgap, 61dlu, $lcgap, default",
                        "2*(default, $lgap), default"));

                //---- lblEach ----
                lblEach.setText("jeden");
                lblEach.setFont(new Font("Arial", Font.PLAIN, 14));
                lblEach.setHorizontalAlignment(SwingConstants.TRAILING);
                pnlMonthly.add(lblEach, CC.xy(3, 3));

                //---- txtEveryMonth ----
                txtEveryMonth.setFont(new Font("Arial", Font.PLAIN, 14));
                txtEveryMonth.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusLost(FocusEvent e) {
                        txtEveryMonthFocusLost(e);
                    }
                });
                pnlMonthly.add(txtEveryMonth, CC.xy(5, 3));

                //---- lblMonth ----
                lblMonth.setText("Monat");
                lblMonth.setFont(new Font("Arial", Font.PLAIN, 14));
                pnlMonthly.add(lblMonth, CC.xy(7, 3));

                //---- btnEveryMonth ----
                btnEveryMonth.setText("Jeden Monat");
                btnEveryMonth.setFont(new Font("Arial", Font.BOLD, 14));
                btnEveryMonth.setButtonStyle(3);
                btnEveryMonth.setForeground(Color.blue);
                btnEveryMonth.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        btnJedenMonatActionPerformed(e);
                    }
                });
                pnlMonthly.add(btnEveryMonth, CC.xy(9, 3));

                //---- lblOnThe ----
                lblOnThe.setText("jeweils am");
                lblOnThe.setFont(new Font("Arial", Font.PLAIN, 14));
                lblOnThe.setHorizontalAlignment(SwingConstants.TRAILING);
                pnlMonthly.add(lblOnThe, CC.xy(3, 5));

                //---- txtEveryWDayOfMonth ----
                txtEveryWDayOfMonth.setFont(new Font("Arial", Font.PLAIN, 14));
                txtEveryWDayOfMonth.addFocusListener(new FocusAdapter() {
                    @Override
                    public void focusLost(FocusEvent e) {
                        txtEveryWDayOfMonthFocusLost(e);
                    }
                });
                pnlMonthly.add(txtEveryWDayOfMonth, CC.xy(5, 5));

                //---- cmbWDay ----
                cmbWDay.setFont(new Font("Arial", Font.PLAIN, 14));
                pnlMonthly.add(cmbWDay, CC.xywh(7, 5, 3, 1));
            }
            tabWdh.addTab("Monatlich", pnlMonthly);

        }
        panelMain.add(tabWdh, CC.xy(3, 5, CC.FILL, CC.FILL));

        //======== panel2 ========
        {
            panel2.setLayout(new BoxLayout(panel2, BoxLayout.X_AXIS));

            //---- lblLDate ----
            lblLDate.setText("Erst einplanen ab dem ");
            lblLDate.setFont(new Font("Arial", Font.PLAIN, 14));
            panel2.add(lblLDate);

            //---- txtLDate ----
            txtLDate.setFont(new Font("Arial", Font.PLAIN, 14));
            txtLDate.addFocusListener(new FocusAdapter() {
                @Override
                public void focusLost(FocusEvent e) {
                    txtLDateFocusLost(e);
                }
            });
            panel2.add(txtLDate);
        }
        panelMain.add(panel2, CC.xy(3, 7));

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                btnSaveActionPerformed(e);
            }
        });
        panelMain.add(btnSave, CC.xy(3, 9, CC.RIGHT, CC.DEFAULT));
    }
    add(panelMain, BorderLayout.CENTER);
}

From source file:op.care.nursingprocess.DlgNursingProcess.java

/**
 * This method is called from within the constructor to
 * initialize the form.// w w w .  j  ava 2 s . c  o m
 * WARNING: Do NOT modify this code. The content of this method is
 * always regenerated by the PrinterForm Editor.
 */
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
    jPanel5 = new JPanel();
    lblTopic = new JLabel();
    txtStichwort = new JTextField();
    lblCat = new JLabel();
    cmbKategorie = new JComboBox<>();
    panel4 = new JPanel();
    lblSituation = new JLabel();
    btnPopoutSituation = new JButton();
    jScrollPane3 = new JScrollPane();
    txtSituation = new JTextArea();
    panel5 = new JPanel();
    lblGoal = new JLabel();
    btnPopoutGoal = new JButton();
    jScrollPane1 = new JScrollPane();
    txtZiele = new JTextArea();
    lblFirstRevision = new JLabel();
    jdcKontrolle = new JDateChooser();
    panel2 = new JPanel();
    jspPlanung = new JScrollPane();
    tblPlanung = new JTable();
    panel3 = new JPanel();
    btnAddIntervention = new JButton();
    panel1 = new JPanel();
    btnCancel = new JButton();
    btnSave = new JButton();

    //======== this ========
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("14dlu, $lcgap, 280dlu:grow, $ugap, pref, $lcgap, 14dlu",
            "fill:14dlu, $lgap, fill:default:grow, $rgap, pref, $lgap, 14dlu"));

    //======== jPanel5 ========
    {
        jPanel5.setLayout(new FormLayout("default, $lcgap, default:grow",
                "fill:default, $rgap, default, 2*($lgap, fill:default:grow), $lgap, 70dlu, $lgap, pref"));

        //---- lblTopic ----
        lblTopic.setFont(new Font("Arial", Font.PLAIN, 14));
        lblTopic.setText("Stichwort");
        jPanel5.add(lblTopic, CC.xy(1, 1, CC.DEFAULT, CC.TOP));

        //---- txtStichwort ----
        txtStichwort.setFont(new Font("Arial", Font.BOLD, 20));
        txtStichwort.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                txtStichwortFocusGained(e);
            }
        });
        jPanel5.add(txtStichwort, CC.xy(3, 1));

        //---- lblCat ----
        lblCat.setFont(new Font("Arial", Font.PLAIN, 14));
        lblCat.setText("Kategorie");
        jPanel5.add(lblCat, CC.xy(1, 3));

        //---- cmbKategorie ----
        cmbKategorie
                .setModel(new DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        cmbKategorie.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel5.add(cmbKategorie, CC.xy(3, 3));

        //======== panel4 ========
        {
            panel4.setLayout(new BorderLayout());

            //---- lblSituation ----
            lblSituation.setFont(new Font("Arial", Font.PLAIN, 14));
            lblSituation.setText("Situation");
            panel4.add(lblSituation, BorderLayout.CENTER);

            //---- btnPopoutSituation ----
            btnPopoutSituation.setText(null);
            btnPopoutSituation.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/popup.png")));
            btnPopoutSituation.setBorderPainted(false);
            btnPopoutSituation.setContentAreaFilled(false);
            btnPopoutSituation
                    .setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
            btnPopoutSituation.setBorder(null);
            btnPopoutSituation.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPopoutSituation.addActionListener(e -> btnPopoutSituationActionPerformed(e));
            panel4.add(btnPopoutSituation, BorderLayout.EAST);
        }
        jPanel5.add(panel4, CC.xy(1, 5, CC.DEFAULT, CC.TOP));

        //======== jScrollPane3 ========
        {

            //---- txtSituation ----
            txtSituation.setColumns(20);
            txtSituation.setLineWrap(true);
            txtSituation.setRows(5);
            txtSituation.setWrapStyleWord(true);
            txtSituation.setFont(new Font("Arial", Font.PLAIN, 14));
            txtSituation.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtSituationFocusGained(e);
                }
            });
            jScrollPane3.setViewportView(txtSituation);
        }
        jPanel5.add(jScrollPane3, CC.xy(3, 5));

        //======== panel5 ========
        {
            panel5.setLayout(new BorderLayout());

            //---- lblGoal ----
            lblGoal.setFont(new Font("Arial", Font.PLAIN, 14));
            lblGoal.setText("Ziele");
            panel5.add(lblGoal, BorderLayout.CENTER);

            //---- btnPopoutGoal ----
            btnPopoutGoal.setText(null);
            btnPopoutGoal.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/popup.png")));
            btnPopoutGoal.setBorderPainted(false);
            btnPopoutGoal.setContentAreaFilled(false);
            btnPopoutGoal
                    .setSelectedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/pressed.png")));
            btnPopoutGoal.setBorder(null);
            btnPopoutGoal.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
            btnPopoutGoal.addActionListener(e -> btnPopoutGoalActionPerformed(e));
            panel5.add(btnPopoutGoal, BorderLayout.EAST);
        }
        jPanel5.add(panel5, CC.xy(1, 7, CC.DEFAULT, CC.TOP));

        //======== jScrollPane1 ========
        {

            //---- txtZiele ----
            txtZiele.setColumns(20);
            txtZiele.setLineWrap(true);
            txtZiele.setRows(5);
            txtZiele.setWrapStyleWord(true);
            txtZiele.setFont(new Font("Arial", Font.PLAIN, 14));
            txtZiele.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    txtZieleFocusGained(e);
                }
            });
            jScrollPane1.setViewportView(txtZiele);
        }
        jPanel5.add(jScrollPane1, CC.xy(3, 7));

        //---- lblFirstRevision ----
        lblFirstRevision.setFont(new Font("Arial", Font.PLAIN, 14));
        lblFirstRevision.setText("Erste Kontrolle am");
        jPanel5.add(lblFirstRevision, CC.xy(1, 11));

        //---- jdcKontrolle ----
        jdcKontrolle.setFont(new Font("Arial", Font.PLAIN, 14));
        jPanel5.add(jdcKontrolle, CC.xy(3, 11));
    }
    contentPane.add(jPanel5, CC.xy(3, 3, CC.DEFAULT, CC.FILL));

    //======== panel2 ========
    {
        panel2.setLayout(new FormLayout("default:grow", "default, $lgap, default"));

        //======== jspPlanung ========
        {
            jspPlanung.addComponentListener(new ComponentAdapter() {
                @Override
                public void componentResized(ComponentEvent e) {
                    jspPlanungComponentResized(e);
                }
            });

            //---- tblPlanung ----
            tblPlanung.setModel(new DefaultTableModel(
                    new Object[][] { { null, null, null, null }, { null, null, null, null },
                            { null, null, null, null }, { null, null, null, null }, },
                    new String[] { "Title 1", "Title 2", "Title 3", "Title 4" }));
            tblPlanung.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
            tblPlanung.addMouseListener(new MouseAdapter() {
                @Override
                public void mousePressed(MouseEvent e) {
                    tblPlanungMousePressed(e);
                }
            });
            jspPlanung.setViewportView(tblPlanung);
        }
        panel2.add(jspPlanung, CC.xy(1, 1));

        //======== panel3 ========
        {
            panel3.setLayout(new BoxLayout(panel3, BoxLayout.X_AXIS));

            //---- btnAddIntervention ----
            btnAddIntervention.setText(null);
            btnAddIntervention.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add.png")));
            btnAddIntervention.setContentAreaFilled(false);
            btnAddIntervention.setBorderPainted(false);
            btnAddIntervention.setBorder(null);
            btnAddIntervention
                    .setPressedIcon(new ImageIcon(getClass().getResource("/artwork/22x22/bw/add-pressed.png")));
            btnAddIntervention.addActionListener(e -> btnAddInterventionActionPerformed(e));
            panel3.add(btnAddIntervention);
        }
        panel2.add(panel3, CC.xy(1, 3));
    }
    contentPane.add(panel2, CC.xy(5, 3));

    //======== panel1 ========
    {
        panel1.setLayout(new HorizontalLayout(5));

        //---- btnCancel ----
        btnCancel.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/cancel.png")));
        btnCancel.setText(null);
        btnCancel.addActionListener(e -> btnCancelActionPerformed(e));
        panel1.add(btnCancel);

        //---- btnSave ----
        btnSave.setIcon(new ImageIcon(getClass().getResource("/artwork/22x22/apply.png")));
        btnSave.setText(null);
        btnSave.addActionListener(e -> btnSaveActionPerformed(e));
        panel1.add(btnSave);
    }
    contentPane.add(panel1, CC.xy(5, 5, CC.RIGHT, CC.DEFAULT));
    setSize(1145, 695);
    setLocationRelativeTo(getOwner());
}

From source file:org.tinymediamanager.ui.movies.MoviePanel.java

/**
 * Create the panel.//  ww  w  .  j av a2  s  .c o m
 */
public MoviePanel() {
    super();
    // load movielist
    LOGGER.debug("loading MovieList");
    movieList = MovieList.getInstance();
    sortedMovies = new SortedList<>(GlazedListsSwing.swingThreadProxyList(movieList.getMovies()),
            new MovieComparator());
    sortedMovies.setMode(SortedList.AVOID_MOVING_ELEMENTS);

    // build menu
    menu = new JMenu(BUNDLE.getString("tmm.movies")); //$NON-NLS-1$
    JFrame mainFrame = MainWindow.getFrame();
    JMenuBar menuBar = mainFrame.getJMenuBar();
    menuBar.add(menu);

    setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("850px:grow"),
                    FormFactory.RELATED_GAP_COLSPEC, },
            new RowSpec[] { FormFactory.RELATED_GAP_ROWSPEC, RowSpec.decode("500px:grow"), }));

    splitPaneHorizontal = new JSplitPane();
    splitPaneHorizontal.setContinuousLayout(true);
    add(splitPaneHorizontal, "2, 2, fill, fill");

    JPanel panelMovieList = new JPanel();
    splitPaneHorizontal.setLeftComponent(panelMovieList);
    panelMovieList.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"),
                    ColumnSpec.decode("default:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    FormFactory.DEFAULT_COLSPEC, },
            new RowSpec[] { RowSpec.decode("26px"), FormFactory.RELATED_GAP_ROWSPEC,
                    RowSpec.decode("fill:max(200px;default):grow"), FormFactory.RELATED_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC, FormFactory.DEFAULT_ROWSPEC, }));

    JToolBar toolBar = new JToolBar();
    toolBar.setRollover(true);
    toolBar.setFloatable(false);
    toolBar.setOpaque(false);
    panelMovieList.add(toolBar, "2, 1, left, fill");

    // udpate datasource
    // toolBar.add(actionUpdateDataSources);
    final JSplitButton buttonUpdateDatasource = new JSplitButton(IconManager.REFRESH);
    // temp fix for size of the button
    buttonUpdateDatasource.setText("   ");
    buttonUpdateDatasource.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonUpdateDatasource.setSplitWidth(18);
    buttonUpdateDatasource.setToolTipText(BUNDLE.getString("update.datasource")); //$NON-NLS-1$
    buttonUpdateDatasource.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionUpdateDataSources.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
            // build the popupmenu on the fly
            buttonUpdateDatasource.getPopupMenu().removeAll();
            JMenuItem item = new JMenuItem(actionUpdateDataSources2);
            buttonUpdateDatasource.getPopupMenu().add(item);
            buttonUpdateDatasource.getPopupMenu().addSeparator();
            for (String ds : MovieModuleManager.MOVIE_SETTINGS.getMovieDataSource()) {
                buttonUpdateDatasource.getPopupMenu()
                        .add(new JMenuItem(new MovieUpdateSingleDatasourceAction(ds)));
            }

            buttonUpdateDatasource.getPopupMenu().pack();
        }
    });

    JPopupMenu popup = new JPopupMenu("popup");
    buttonUpdateDatasource.setPopupMenu(popup);
    toolBar.add(buttonUpdateDatasource);

    JSplitButton buttonScrape = new JSplitButton(IconManager.SEARCH);
    // temp fix for size of the button
    buttonScrape.setText("   ");
    buttonScrape.setHorizontalAlignment(JButton.LEFT);
    // buttonScrape.setMargin(new Insets(2, 2, 2, 24));
    buttonScrape.setSplitWidth(18);
    buttonScrape.setToolTipText(BUNDLE.getString("movie.scrape.selected")); //$NON-NLS-1$

    // register for listener
    buttonScrape.addSplitButtonActionListener(new SplitButtonActionListener() {
        public void buttonClicked(ActionEvent e) {
            actionScrape.actionPerformed(e);
        }

        public void splitButtonClicked(ActionEvent e) {
        }
    });

    popup = new JPopupMenu("popup");
    JMenuItem item = new JMenuItem(actionScrape2);
    popup.add(item);
    item = new JMenuItem(actionScrapeUnscraped);
    popup.add(item);
    item = new JMenuItem(actionScrapeSelected);
    popup.add(item);
    buttonScrape.setPopupMenu(popup);
    toolBar.add(buttonScrape);

    toolBar.add(actionEditMovie);

    btnRen = new JButton("REN");
    btnRen.setAction(actionRename);
    toolBar.add(btnRen);

    btnMediaInformation = new JButton("MI");
    btnMediaInformation.setAction(actionMediaInformation);
    toolBar.add(btnMediaInformation);

    JButton btnCreateOflline = new JButton();
    btnCreateOflline.setAction(new MovieCreateOfflineAction(false));
    toolBar.add(btnCreateOflline);

    textField = EnhancedTextField.createSearchTextField();
    panelMovieList.add(textField, "3, 1, right, bottom");
    textField.setColumns(13);

    // table = new JTable();
    // build JTable

    MatcherEditor<Movie> textMatcherEditor = new TextComponentMatcherEditor<>(textField, new MovieFilterator());
    MovieMatcherEditor movieMatcherEditor = new MovieMatcherEditor();
    FilterList<Movie> extendedFilteredMovies = new FilterList<>(sortedMovies, movieMatcherEditor);
    textFilteredMovies = new FilterList<>(extendedFilteredMovies, textMatcherEditor);
    movieSelectionModel = new MovieSelectionModel(sortedMovies, textFilteredMovies, movieMatcherEditor);
    movieTableModel = new DefaultEventTableModel<>(GlazedListsSwing.swingThreadProxyList(textFilteredMovies),
            new MovieTableFormat());
    table = new ZebraJTable(movieTableModel);

    movieTableModel.addTableModelListener(new TableModelListener() {
        @Override
        public void tableChanged(TableModelEvent arg0) {
            lblMovieCountFiltered.setText(String.valueOf(movieTableModel.getRowCount()));
            // select first movie if nothing is selected
            ListSelectionModel selectionModel = table.getSelectionModel();
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() > 0) {
                selectionModel.setSelectionInterval(0, 0);
            }
            if (selectionModel.isSelectionEmpty() && movieTableModel.getRowCount() == 0) {
                movieSelectionModel.setSelectedMovie(null);
            }
        }
    });

    // install and save the comparator on the Table
    movieSelectionModel.setTableComparatorChooser(
            TableComparatorChooser.install(table, sortedMovies, TableComparatorChooser.SINGLE_COLUMN));

    // table = new MyTable();
    table.setNewFontSize((float) ((int) Math.round(getFont().getSize() * 0.916)));
    // scrollPane.setViewportView(table);

    // JScrollPane scrollPane = new JScrollPane(table);
    JScrollPane scrollPane = ZebraJTable.createStripedJScrollPane(table);
    panelMovieList.add(scrollPane, "2, 3, 4, 1, fill, fill");

    {
        final JToggleButton filterButton = new JToggleButton(IconManager.FILTER);
        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
        panelMovieList.add(filterButton, "5, 1, right, bottom");

        // add a propertychangelistener which reacts on setting a filter
        movieSelectionModel.addPropertyChangeListener(new PropertyChangeListener() {
            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                if ("filterChanged".equals(evt.getPropertyName())) {
                    if (Boolean.TRUE.equals(evt.getNewValue())) {
                        filterButton.setIcon(IconManager.FILTER_ACTIVE);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options.active")); //$NON-NLS-1$
                    } else {
                        filterButton.setIcon(IconManager.FILTER);
                        filterButton.setToolTipText(BUNDLE.getString("movieextendedsearch.options")); //$NON-NLS-1$
                    }
                }
            }
        });

        panelExtendedSearch = new MovieExtendedSearchPanel(movieSelectionModel);
        panelExtendedSearch.setVisible(false);
        // panelMovieList.add(panelExtendedSearch, "2, 5, 2, 1, fill, fill");
        filterButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent arg0) {
                if (panelExtendedSearch.isVisible() == true) {
                    panelExtendedSearch.setVisible(false);
                } else {
                    panelExtendedSearch.setVisible(true);
                }
            }
        });
    }

    JPanel panelStatus = new JPanel();
    panelMovieList.add(panelStatus, "2, 6, 2, 1");
    panelStatus.setLayout(new FormLayout(
            new ColumnSpec[] { FormFactory.RELATED_GAP_COLSPEC, ColumnSpec.decode("1px"),
                    ColumnSpec.decode("146px:grow"), FormFactory.RELATED_GAP_COLSPEC,
                    ColumnSpec.decode("default:grow"), },
            new RowSpec[] { RowSpec.decode("fill:default:grow"), }));

    panelMovieCount = new JPanel();
    panelStatus.add(panelMovieCount, "3, 1, left, fill");

    lblMovieCount = new JLabel(BUNDLE.getString("tmm.movies") + ":"); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCount);

    lblMovieCountFiltered = new JLabel("");
    panelMovieCount.add(lblMovieCountFiltered);

    lblMovieCountOf = new JLabel(BUNDLE.getString("tmm.of")); //$NON-NLS-1$
    panelMovieCount.add(lblMovieCountOf);

    lblMovieCountTotal = new JLabel("");
    panelMovieCount.add(lblMovieCountTotal);

    JLayeredPane layeredPaneRight = new JLayeredPane();
    layeredPaneRight.setLayout(
            new FormLayout(new ColumnSpec[] { ColumnSpec.decode("default"), ColumnSpec.decode("default:grow") },
                    new RowSpec[] { RowSpec.decode("default"), RowSpec.decode("default:grow") }));
    panelRight = new MovieInformationPanel(movieSelectionModel);
    layeredPaneRight.add(panelRight, "1, 1, 2, 2, fill, fill");
    layeredPaneRight.setLayer(panelRight, 0);

    // glass pane
    layeredPaneRight.add(panelExtendedSearch, "1, 1, fill, fill");
    layeredPaneRight.setLayer(panelExtendedSearch, 1);

    splitPaneHorizontal.setRightComponent(layeredPaneRight);
    splitPaneHorizontal.setContinuousLayout(true);

    // beansbinding init
    initDataBindings();

    addComponentListener(new ComponentAdapter() {
        @Override
        public void componentHidden(ComponentEvent e) {
            menu.setVisible(false);
            super.componentHidden(e);
        }

        @Override
        public void componentShown(ComponentEvent e) {
            menu.setVisible(true);
            super.componentHidden(e);
        }
    });

    // further initializations
    init();

    // filter
    if (MovieModuleManager.MOVIE_SETTINGS.isStoreUiFilters()) {
        movieList.searchDuplicates();
        movieSelectionModel.filterMovies(MovieModuleManager.MOVIE_SETTINGS.getUiFilters());
    }
}

From source file:fxts.stations.transport.tradingapi.TradingServerSession.java

public void relogin() {
    if (mLogout) {
        return;/*from   www .  j a va  2 s  .  c o m*/
    }
    final JDialog jd = TradeApp.getInst().getMainFrame().createWaitDialog("Session Lost...Reconnecting");
    jd.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentShown(ComponentEvent aEvent) {
            Thread worker = new Thread(new Runnable() {
                public void run() {
                    try {
                        TradingServerSession.getInstance().getGateway().relogin();
                        Liaison.getInstance().refresh();
                    } catch (Exception e) {
                        e.printStackTrace();
                    } finally {
                        jd.dispose();
                        jd.setVisible(false);
                    }
                }
            });
            worker.start();
        }
    });
    jd.setVisible(true);
}

From source file:shuffle.fwk.service.teams.EditTeamService.java

@SuppressWarnings("serial")
private Component makeTeamPanel() {

    JPanel firstOptionRow = new JPanel(new GridBagLayout());
    GridBagConstraints rowc = new GridBagConstraints();
    rowc.fill = GridBagConstraints.HORIZONTAL;
    rowc.weightx = 0.0;//from  ww  w .ja v  a2  s. c  o m
    rowc.weighty = 0.0;

    rowc.weightx = 1.0;
    rowc.gridx = 1;
    stageChooser = new StageChooser(this);
    firstOptionRow.add(stageChooser, rowc);
    rowc.weightx = 0.0;

    JPanel secondOptionRow = new JPanel(new GridBagLayout());

    rowc.gridx = 1;
    JLabel megaLabel = new JLabel(getString(KEY_MEGA_LABEL));
    megaLabel.setToolTipText(getString(KEY_MEGA_TOOLTIP));
    secondOptionRow.add(megaLabel, rowc);

    rowc.gridx = 2;
    megaChooser = new JComboBox<String>();
    megaChooser.setToolTipText(getString(KEY_MEGA_TOOLTIP));
    secondOptionRow.add(megaChooser, rowc);

    rowc.gridx = 3;
    JPanel progressPanel = new JPanel(new BorderLayout());
    megaActive = new JCheckBox(getString(KEY_ACTIVE));
    megaActive.setSelected(false);
    megaActive.setToolTipText(getString(KEY_ACTIVE_TOOLTIP));
    progressPanel.add(megaActive, BorderLayout.WEST);
    megaProgressChooser = new JComboBox<Integer>();
    progressPanel.add(megaProgressChooser, BorderLayout.EAST);
    megaProgressChooser.setToolTipText(getString(KEY_MEGA_PROGRESS_TOOLTIP));
    secondOptionRow.add(progressPanel, rowc);

    JPanel thirdOptionRow = new JPanel(new GridBagLayout());

    rowc.gridx = 1;
    JButton clearTeamButton = new JButton(getString(KEY_CLEAR_TEAM));
    clearTeamButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            clearTeam();
        }
    });
    clearTeamButton.setToolTipText(getString(KEY_CLEAR_TEAM_TOOLTIP));
    thirdOptionRow.add(clearTeamButton, rowc);

    rowc.gridx = 2;
    woodCheckBox = new JCheckBox(getString(KEY_WOOD));
    woodCheckBox.setToolTipText(getString(KEY_WOOD_TOOLTIP));
    thirdOptionRow.add(woodCheckBox, rowc);

    rowc.gridx = 3;
    metalCheckBox = new JCheckBox(getString(KEY_METAL));
    metalCheckBox.setToolTipText(getString(KEY_METAL_TOOLTIP));
    thirdOptionRow.add(metalCheckBox, rowc);

    rowc.gridx = 4;
    coinCheckBox = new JCheckBox(getString(KEY_COIN));
    coinCheckBox.setToolTipText(getString(KEY_COIN_TOOLTIP));
    thirdOptionRow.add(coinCheckBox, rowc);

    rowc.gridx = 5;
    freezeCheckBox = new JCheckBox(getString(KEY_FREEZE));
    freezeCheckBox.setToolTipText(getString(KEY_FREEZE_TOOLTIP));
    thirdOptionRow.add(freezeCheckBox, rowc);

    JPanel topPart = new JPanel(new GridBagLayout());
    GridBagConstraints topC = new GridBagConstraints();
    topC.fill = GridBagConstraints.HORIZONTAL;
    topC.weightx = 0.0;
    topC.weighty = 0.0;
    topC.gridx = 1;
    topC.gridy = 1;
    topC.gridwidth = 1;
    topC.gridheight = 1;
    topC.anchor = GridBagConstraints.CENTER;

    topC.gridy = 1;
    topPart.add(firstOptionRow, topC);
    topC.gridy = 2;
    topPart.add(secondOptionRow, topC);
    topC.gridy = 3;
    topPart.add(thirdOptionRow, topC);

    addOptionListeners();

    teamPanel = new JPanel(new WrapLayout()) {
        // Fix to make it play nice with the scroll bar.
        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width = (int) (d.getWidth() - 20);
            return d;
        }
    };
    final JScrollPane scrollPane = new JScrollPane(teamPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
            ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER) {
        @Override
        public Dimension getMinimumSize() {
            Dimension d = super.getMinimumSize();
            d.width = topPart.getMinimumSize().width;
            d.height = rosterScrollPane.getPreferredSize().height - topPart.getPreferredSize().height;
            return d;
        }

        @Override
        public Dimension getPreferredSize() {
            Dimension d = super.getPreferredSize();
            d.width = topPart.getMinimumSize().width;
            d.height = rosterScrollPane.getPreferredSize().height - topPart.getPreferredSize().height;
            return d;
        }
    };
    scrollPane.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            scrollPane.revalidate();
        }
    });
    scrollPane.getVerticalScrollBar().setUnitIncrement(27);

    JPanel ret = new JPanel(new GridBagLayout());
    GridBagConstraints rc = new GridBagConstraints();
    rc.fill = GridBagConstraints.VERTICAL;
    rc.weightx = 0.0;
    rc.weighty = 0.0;
    rc.gridx = 1;
    rc.gridy = 1;
    rc.insets = new Insets(5, 5, 5, 5);
    ret.add(topPart, rc);
    rc.gridy += 1;
    rc.weightx = 0.0;
    rc.weighty = 1.0;
    rc.insets = new Insets(0, 0, 0, 0);
    ret.add(scrollPane, rc);
    return ret;
}

From source file:org.rdv.datapanel.AbstractDataPanel.java

/**
 * Detach the UI component from the data panel container.
 * /*from  w w  w. j a  va 2  s  .  c  o m*/
 * @since  1.1
 */
void detachPanel() {
    attached = false;
    properties.setProperty("attached", "false");
    dataPanelContainer.removeDataPanel(component);

    achButton.setIcon(attachIconFileName);

    frame = new JFrame(getTitle());
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            closePanel();
        }
    });
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    frame.getContentPane().add(component);

    String bounds = properties.getProperty("bounds");
    if (bounds != null) {
        loadBounds(bounds);
    } else {
        frame.pack();
    }

    frame.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            storeBounds();
        }

        public void componentMoved(ComponentEvent e) {
            storeBounds();
        }

        public void componentShown(ComponentEvent e) {
            storeBounds();
        }
    });

    frame.setVisible(true);
}

From source file:lejos.pc.charting.LogChartFrame.java

/** All the setup of components, etc. What's scary is Swing is a "lightweight" GUI framework...
 * @throws Exception/*from w w  w.  jav  a 2s .c o  m*/
 */
private void jbInit() throws Exception {
    this.setJMenuBar(menuBar);
    this.setSize(new Dimension(819, 613));
    this.setMinimumSize(new Dimension(819, 613));
    this.setTitle("NXT Charting Logger");
    this.setEnabled(true);
    // enforce minimum window size
    this.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            JFrame theFrame = (JFrame) e.getSource();
            Dimension d1 = theFrame.getMinimumSize();
            Dimension d2 = theFrame.getSize();
            boolean enforce = false;
            if (theFrame.getWidth() < d1.getWidth()) {
                d2.setSize(d1.getWidth(), d2.getHeight());
                enforce = true;
            }
            if (theFrame.getHeight() < d1.getHeight()) {
                d2.setSize(d2.getWidth(), d1.getHeight());
                enforce = true;
            }
            if (enforce)
                theFrame.setSize(d2);
        }
    });

    this.getContentPane().setLayout(gridBagLayout1);
    MenuActionListener menuItemActionListener = new MenuActionListener();
    MenuEventListener menuListener = new MenuEventListener();

    menu = new JMenu("Edit");
    menu.setMnemonic(KeyEvent.VK_E);
    menuBar.add(menu);
    menuItem = new JMenuItem("Copy Chart Image", KeyEvent.VK_I);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);
    menuItem = new JMenuItem("Copy Data Log", KeyEvent.VK_D);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);

    menu = new JMenu("View");
    menu.setMnemonic(KeyEvent.VK_V);
    menu.setActionCommand("VIEW_MENU");
    menu.addMenuListener(menuListener);
    menuBar.add(menu);
    menuItem = new JMenuItem("Expand Chart", KeyEvent.VK_F);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);
    menuItem = new JMenuItem("Chart in New Window", KeyEvent.VK_N);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);

    menu = new JMenu("Help");
    menu.setMnemonic(KeyEvent.VK_H);
    menuBar.add(menu);
    menuItem = new JMenuItem("Chart controls", KeyEvent.VK_C);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);
    menuItem = new JMenuItem("Generate sample data", KeyEvent.VK_G);
    menuItem.addActionListener(menuItemActionListener);
    menu.add(menuItem);
    menuItem = new JMenuItem("About", KeyEvent.VK_A);
    menuItem.addActionListener(menuItemActionListener);
    jTabbedPane1.setPreferredSize(new Dimension(621, 199));
    jTabbedPane1.setMinimumSize(new Dimension(621, 199));
    menu.add(menuItem);

    jButtonConnect.setText("Connect");
    jButtonConnect.setBounds(new Rectangle(25, 65, 115, 25));
    jButtonConnect.setToolTipText("Connect/disconnect toggle");
    jButtonConnect.setMnemonic('C');
    jButtonConnect.setSelected(true);
    jButtonConnect.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            jButtonConnect_actionPerformed(e);
        }
    });
    UIPanel.setSize(new Dimension(820, 200));
    UIPanel.setLayout(null);
    UIPanel.setPreferredSize(new Dimension(300, 200));
    UIPanel.setMinimumSize(new Dimension(300, 200));
    UIPanel.setBounds(new Rectangle(0, 350, 820, 200));
    UIPanel.setMaximumSize(new Dimension(300, 32767));
    connectionPanel.setBounds(new Rectangle(10, 10, 175, 100));
    connectionPanel.setBorder(BorderFactory.createTitledBorder("Connection"));
    connectionPanel.setLayout(null);
    connectionPanel.setFont(new Font("Tahoma", 0, 11));

    jLabel1logfilename.setText("Log File:");
    jLabel1logfilename.setBounds(new Rectangle(10, 125, 165, 20));
    jLabel1logfilename.setHorizontalTextPosition(SwingConstants.RIGHT);
    jLabel1logfilename.setHorizontalAlignment(SwingConstants.LEFT);
    jLabel1logfilename.setToolTipText("Specify the name of your log file here");

    jTextFieldNXTName.setBounds(new Rectangle(5, 40, 165, 20));
    jTextFieldNXTName.setToolTipText(
            "The name or Address of the NXT. Leave empty and the first one found will be used.");

    jTextFieldNXTName.requestFocus();

    jTextAreaStatus.setLineWrap(true);
    jTextAreaStatus.setFont(new Font("Tahoma", 0, 11));
    jTextAreaStatus.setWrapStyleWord(true);
    jTextAreaStatus.setBackground(SystemColor.window);

    dataLogTextArea.setLineWrap(false);
    dataLogTextArea.setFont(new Font("Tahoma", 0, 11));
    dataLogTextArea.setBackground(SystemColor.window);

    FQPathTextArea.setBounds(new Rectangle(5, 170, 185, 40));
    FQPathTextArea.setLineWrap(true);
    FQPathTextArea.setText(getCanonicalName(new File(".", "")));
    FQPathTextArea.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    FQPathTextArea.setRows(2);

    FQPathTextArea.setFont(new Font("Tahoma", 0, 9));
    FQPathTextArea.setOpaque(false);
    FQPathTextArea.setEditable(false);

    selectFolderButton.setText("Folder...");
    selectFolderButton.setBounds(new Rectangle(120, 125, 70, 20));
    selectFolderButton.setMargin(new Insets(1, 1, 1, 1));
    selectFolderButton.setFocusable(false);
    selectFolderButton.setMnemonic('F');
    selectFolderButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            selectFolderButton_actionPerformed(e);
        }
    });

    // domain display limits GUI
    chartOptionsPanel.setLayout(null);
    chartDomLimitsPanel.setBounds(new Rectangle(5, 35, 180, 135));
    chartDomLimitsPanel.setLayout(gridLayout1);
    chartDomLimitsPanel.setBorder(BorderFactory.createTitledBorder("Domain Display Limiting"));
    domainDisplayLimitSlider.setEnabled(false);
    domainDisplayLimitSlider.setMaximum(MAXDOMAIN_DATAPOINT_LIMIT);
    domainDisplayLimitSlider.setMinimum(MINDOMAIN_LIMIT);
    domainDisplayLimitSlider.setValue(MAXDOMAIN_DATAPOINT_LIMIT);
    domainDisplayLimitSlider.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            domainDisplayLimitSlider_stateChanged(e);
        }
    });
    useTimeRadioButton.setText("By Time");
    useTimeRadioButton.setEnabled(false);
    useTimeRadioButton.setMnemonic('I');
    useTimeRadioButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            domainDisplayLimitRadioButton_actionPerformed(e);
        }
    });
    useDataPointsRadioButton.setText("By Data Points");
    ButtonGroup bg1 = new ButtonGroup();
    bg1.add(useTimeRadioButton);
    bg1.add(useDataPointsRadioButton);
    useDataPointsRadioButton.setSelected(true);
    useDataPointsRadioButton.setEnabled(false);
    useDataPointsRadioButton.setMnemonic('P');
    useDataPointsRadioButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            domainDisplayLimitRadioButton_actionPerformed(e);
        }
    });
    datasetLimitEnableCheckBox.setText("Enable");
    datasetLimitEnableCheckBox.setRolloverEnabled(true);
    datasetLimitEnableCheckBox.setMnemonic('A');
    datasetLimitEnableCheckBox.setToolTipText("Enable Domain Clipping");
    datasetLimitEnableCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            datasetLimitEnableCheckBox_actionPerformed(e);
        }
    });
    domainLimitLabel.setText(String.format("%1$,d datapoints", MAXDOMAIN_DATAPOINT_LIMIT).toString());
    domainLimitLabel.setEnabled(false);
    gridLayout1.setRows(5);
    gridLayout1.setColumns(1);

    jLabel1.setText("Chart Title:");
    jLabel1.setBounds(new Rectangle(200, 10, 85, 20));
    jLabel1.setPreferredSize(new Dimension(115, 14));
    jLabel2.setText("Range Axis 1 Label:");
    jLabel2.setBounds(new Rectangle(200, 35, 115, 20));
    jLabel2.setSize(new Dimension(115, 20));
    jLabel3.setText("Range Axis 2 Label:");
    jLabel3.setBounds(new Rectangle(200, 60, 115, 20));
    jLabel3.setSize(new Dimension(115, 20));
    jLabel4.setText("Range Axis 3 Label:");
    jLabel4.setBounds(new Rectangle(200, 85, 115, 20));
    jLabel4.setSize(new Dimension(115, 20));
    jLabel6.setText("Range Axis 4 Label:");
    jLabel6.setBounds(new Rectangle(200, 110, 115, 20));
    jLabel6.setSize(new Dimension(115, 20));
    titleLabelChangeNotifier notifier = new titleLabelChangeNotifier();
    chartTitleTextField.setBounds(new Rectangle(315, 10, 290, 20));
    chartTitleTextField.getDocument().addDocumentListener(notifier);
    axis1LabelTextField.setBounds(new Rectangle(315, 35, 290, 20));
    axis1LabelTextField.getDocument().addDocumentListener(notifier);
    axis2LabelTextField.setBounds(new Rectangle(315, 60, 290, 20));
    axis2LabelTextField.getDocument().addDocumentListener(notifier);
    axis3LabelTextField.setBounds(new Rectangle(315, 85, 290, 20));
    axis3LabelTextField.getDocument().addDocumentListener(notifier);
    axis4LabelTextField.setBounds(new Rectangle(315, 110, 290, 20));
    showCommentsCheckBox.setText("Show Comment Markers");
    showCommentsCheckBox.setBounds(new Rectangle(200, 140, 185, 25));
    showCommentsCheckBox.setToolTipText("Show/Hide any comment markers on the chart");
    showCommentsCheckBox.setRolloverEnabled(true);
    showCommentsCheckBox.setSelected(true);
    showCommentsCheckBox.setMnemonic('M');
    showCommentsCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            customChartPanel.setCommentsVisible(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    scrollDomainCheckBox.setText("Scroll Domain");
    scrollDomainCheckBox.setBounds(new Rectangle(10, 5, 175, 20));
    scrollDomainCheckBox.setSize(new Dimension(175, 25));
    scrollDomainCheckBox.setSelected(true);
    scrollDomainCheckBox.setMnemonic('O');
    scrollDomainCheckBox.setToolTipText("Checked to scroll domain as new data is received");
    scrollDomainCheckBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scrollDomainCheckBox_actionPerformed(e);
        }
    });
    axis4LabelTextField.getDocument().addDocumentListener(notifier);

    logFileTextField.setBounds(new Rectangle(10, 145, 180, 20));
    logFileTextField.setText("NXTData.txt");
    logFileTextField.setPreferredSize(new Dimension(180, 20));
    logFileTextField.setToolTipText("File name. Leave empty to not log to file.");
    statusScrollPane.setOpaque(false);
    dataLogScrollPane.setOpaque(false);

    customChartPanel.setMinimumSize(new Dimension(400, 300));
    customChartPanel.setPreferredSize(new Dimension(812, 400));

    jLabel5.setText("NXT Name/Address:");
    jLabel5.setBounds(new Rectangle(5, 20, 160, 20));
    jLabel5.setToolTipText(jTextFieldNXTName.getToolTipText());
    jLabel5.setHorizontalTextPosition(SwingConstants.RIGHT);
    jLabel5.setHorizontalAlignment(SwingConstants.LEFT);

    connectionPanel.add(jTextFieldNXTName, null);
    connectionPanel.add(jButtonConnect, null);
    connectionPanel.add(jLabel5, null);
    dataLogScrollPane.setViewportView(dataLogTextArea);
    jTabbedPane1.addTab("Data Log", dataLogScrollPane);
    statusScrollPane.setViewportView(jTextAreaStatus);
    jTabbedPane1.addTab("Status", statusScrollPane);
    jTabbedPane1.addTab("Chart", chartOptionsPanel);
    chartDomLimitsPanel.add(datasetLimitEnableCheckBox, null);
    chartDomLimitsPanel.add(useDataPointsRadioButton, null);
    chartDomLimitsPanel.add(useTimeRadioButton, null);
    chartDomLimitsPanel.add(domainDisplayLimitSlider, null);
    chartDomLimitsPanel.add(domainLimitLabel, null);
    chartOptionsPanel.add(scrollDomainCheckBox, null);
    chartOptionsPanel.add(showCommentsCheckBox, null);
    chartOptionsPanel.add(axis4LabelTextField, null);
    chartOptionsPanel.add(axis3LabelTextField, null);
    chartOptionsPanel.add(axis2LabelTextField, null);
    chartOptionsPanel.add(axis1LabelTextField, null);
    chartOptionsPanel.add(chartTitleTextField, null);
    chartOptionsPanel.add(jLabel6, null);
    chartOptionsPanel.add(jLabel4, null);
    chartOptionsPanel.add(jLabel3, null);
    chartOptionsPanel.add(jLabel2, null);
    chartOptionsPanel.add(jLabel1, null);
    chartOptionsPanel.add(chartDomLimitsPanel, null);

    tglbtnpauseplay = new JToggleButton("");
    tglbtnpauseplay.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (lpm == null)
                return;
            boolean doPause = false;
            if (e.getStateChange() == ItemEvent.SELECTED) {
                doPause = true;
            }
            lpm.setReaderPaused(doPause);
        }
    });
    //        tglbtnpauseplay.addChangeListener(new ChangeListener() {
    //           public void stateChanged(ChangeEvent e) {
    //              System.out.println(e.toString());
    //              //lpm.setReaderPaused(doPause)
    //           }
    //        });
    tglbtnpauseplay
            .setSelectedIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/play.png")));
    tglbtnpauseplay.setIcon(new ImageIcon(LogChartFrame.class.getResource("/lejos/pc/charting/pause.png")));
    tglbtnpauseplay.setBounds(571, 135, 30, 30);
    chartOptionsPanel.add(tglbtnpauseplay);

    jTabbedPane1.setToolTipTextAt(0, "The tab-delimited log of the data sent from the NXT");
    jTabbedPane1.setToolTipTextAt(1, "Status output");
    jTabbedPane1.setToolTipTextAt(2, "Chart options");
    jTabbedPane1.setMnemonicAt(0, KeyEvent.VK_D);
    jTabbedPane1.setMnemonicAt(1, KeyEvent.VK_S);
    jTabbedPane1.setMnemonicAt(2, KeyEvent.VK_T);
    this.getContentPane().add(customChartPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0,
            GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    this.getContentPane().add(UIPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 0, 0, 0), -107, 0));

    this.getContentPane().add(jTabbedPane1, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0,
            GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
    UIPanel.add(connectionPanel, null);
    UIPanel.add(selectFolderButton, null);
    UIPanel.add(logFileTextField, null);
    UIPanel.add(jLabel1logfilename, null);
    UIPanel.add(FQPathTextArea, null);
    ActionListener taskPerformer = new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String theData = null;
            for (;;) {
                theData = LogChartFrame.this.logDataQueue.poll();
                if (theData == null)
                    break;
                try {
                    dataLogTextArea.getDocument().insertString(dataLogTextArea.getDocument().getLength(),
                            theData, null);
                } catch (BadLocationException e) {
                    System.out.print(
                            "BadLocationException in datalog textarea updater thread:" + e.toString() + "\n");
                }
            }
        }
    };
    this.updateLogTextAreaTimer = new Timer(1000, taskPerformer);
    this.updateLogTextAreaTimer.start();
}