Example usage for javax.swing.border TitledBorder TitledBorder

List of usage examples for javax.swing.border TitledBorder TitledBorder

Introduction

In this page you can find the example usage for javax.swing.border TitledBorder TitledBorder.

Prototype

public TitledBorder(Border border) 

Source Link

Document

Creates a TitledBorder instance with the specified border and an empty title.

Usage

From source file:psidev.psi.mi.filemakers.xmlMaker.gui.XsdTreePanelImpl.java

/**
 * create a button panel that includes buttons for loading the schema, to
 * associate a node to a flat file, a cell a default value or to specify
 * that a value should be automaticaly generated, to get informations about
 * the node, print the XML file or just have a preview of it.
 *//*  www. j  ava 2  s.  c  o m*/
public Box getButtonPanel() {
    // associationLabel.setEditable(false);

    Box buttonsPanel = new Box(BoxLayout.Y_AXIS);

    JPanel treeBox = new JPanel();//
    treeBox.setLayout(new BoxLayout(treeBox, BoxLayout.Y_AXIS));// (BoxLayout.Y_AXIS);

    // Box mappingBox = new Box(BoxLayout.Y_AXIS);
    // mappingBox.setBorder(new TitledBorder("Mapping"));

    Box associationBox = new Box(BoxLayout.Y_AXIS);
    associationBox.setBorder(new TitledBorder("Associations"));

    Box nodeBox = new Box(BoxLayout.Y_AXIS);
    nodeBox.setBorder(new TitledBorder("Node"));

    Box outputBox = new Box(BoxLayout.Y_AXIS);
    outputBox.setBorder(new TitledBorder("Output"));

    /* add a button for loading a XML Schema */
    JButton loadFileb = new JButton("Open File");
    Utils.setDefaultSize(loadFileb);
    loadFileb.addActionListener(new LoadSchemaListener());

    JButton loadURLb = new JButton("Open URL");
    Utils.setDefaultSize(loadURLb);
    loadURLb.addActionListener(new LoadURLSchemaListener());

    JButton setIdb = new JButton("Prefix");
    Utils.setDefaultSize(setIdb);
    setIdb.addActionListener(new SetIdListener());

    /* add a button for duplicate a node (in case of lists) */
    JButton duplicateb = new JButton("Duplicate");
    Utils.setDefaultSize(duplicateb);
    duplicateb.addActionListener(new DuplicateListener());

    /* add a button for restauring original choice */
    JButton choiceb = new JButton("Restore");
    Utils.setDefaultSize(choiceb);
    choiceb.addActionListener(new OriginalNodeListener());

    JButton infosb = new JButton("About");
    Utils.setDefaultSize(infosb);
    infosb.addActionListener(new InfosListener());

    JButton checkb = new JButton("Check");
    Utils.setDefaultSize(checkb);
    checkb.addActionListener(new CheckListener());

    JButton previewb = new JButton("Preview");
    Utils.setDefaultSize(previewb);
    previewb.addActionListener(new PreviewListener());

    JButton printb = new JButton("Make XML");
    Utils.setDefaultSize(printb);
    printb.addActionListener(new PrintListener());

    treeBox.add(loadFileb);
    treeBox.add(loadURLb);
    treeBox.add(setIdb);
    treeBox.add(checkb);
    treeBox.setBorder(new TitledBorder("Schema"));

    nodeBox.add(duplicateb);
    nodeBox.add(choiceb);
    nodeBox.add(infosb);

    outputBox.add(previewb);
    outputBox.add(printb);

    associationButtons = new ButtonGroup();

    fieldAssociation = new JRadioButton("to field");
    duplicableFieldAssociation = new JRadioButton("to duplicable field");
    dictionnaryAssociation = new JRadioButton("to dictionnary");
    defaultAssociation = new JRadioButton("to default value");
    autoGenerationAssociationButton = new JRadioButton("to automatic value");
    flatFileAssociation = new JRadioButton("to flat file");

    associationButtons.add(flatFileAssociation);
    associationButtons.add(duplicableFieldAssociation);
    associationButtons.add(fieldAssociation);
    associationButtons.add(dictionnaryAssociation);
    associationButtons.add(defaultAssociation);
    associationButtons.add(autoGenerationAssociationButton);
    associationButtons.setSelected(flatFileAssociation.getModel(), true);

    JButton genericAssociationb = new JButton("Associate");
    Utils.setDefaultSize(genericAssociationb);
    genericAssociationb.addActionListener(new GenericAssociationListener());

    JButton genericCancelAssociationb = new JButton("Cancel");
    Utils.setDefaultSize(genericCancelAssociationb);
    genericCancelAssociationb.addActionListener(new GenericCancelAssociationListener());

    associationBox.add(flatFileAssociation);

    associationBox.add(duplicableFieldAssociation);

    associationBox.add(fieldAssociation);
    JButton editFieldb = new JButton("validation");
    Utils.setDefaultSize(editFieldb);
    editFieldb.addActionListener(new EditFieldAssociationListener());
    associationBox.add(editFieldb);
    associationBox.add(dictionnaryAssociation);
    associationBox.add(defaultAssociation);
    associationBox.add(defaultAssociation);
    associationBox.add(autoGenerationAssociationButton);

    associationBox.add(genericAssociationb);
    associationBox.add(genericCancelAssociationb);

    buttonsPanel.add(treeBox);
    buttonsPanel.add(associationBox);
    buttonsPanel.add(nodeBox);
    buttonsPanel.add(outputBox);
    // lineBox2.add(lineBox2);
    // buttonsPanel.add(lineBox3);
    return buttonsPanel;
}

From source file:psidev.psi.mi.filemakers.xmlMaker.XmlMakerGui.java

public XmlMakerGui() {
    super("XML Maker");

    /* look n'feel */
    try {/*w  ww . j  a va 2 s.c o  m*/
        //         UIManager.setLookAndFeel(new TonicLookAndFeel());
    } catch (Exception e) {
        System.out.println("Unable to load look'n feel");
    }

    getContentPane().setLayout(new BorderLayout());

    xsdTree = new XsdTreeStructImpl();
    JTextPaneMessageManager messageManager = new JTextPaneMessageManager();
    xsdTree.setMessageManager(messageManager);
    treePanel = new XsdTreePanelImpl(xsdTree, messageManager);

    flatFileTabbedPanel = new FlatFileTabbedPanel(xsdTree.flatFiles);
    flatFileTabbedPanel.setBorder(new TitledBorder("Flat files"));

    dictionnaryLists = new DictionaryPanel(xsdTree.dictionaries);
    dictionnaryLists.setBorder(new TitledBorder("Dictionnary"));

    Box associationsPanels = new Box(BoxLayout.Y_AXIS);

    associationsPanels.add(flatFileTabbedPanel);

    associationsPanels.add(dictionnaryLists);
    getContentPane().add(associationsPanels, BorderLayout.WEST);

    getContentPane().add(treePanel, BorderLayout.CENTER);

    treePanel.setTabFileTabbedPanel(flatFileTabbedPanel);
    treePanel.setDictionnaryPanel(dictionnaryLists);
    final CloseView fv = new CloseView();
    addWindowListener(fv);
    setJMenuBar(new XmlMakerMenu());
    //      setSize(800, 600);
    this.pack();
    setVisible(true);

    if (mappingFileName != null) {
        load(new File(mappingFileName));
    }

}

From source file:repast.simphony.visualization.gui.styleBuilder.EditedStyleDialog.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    dialogPane = new JPanel();
    buttonBar = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();
    panel1 = new JPanel();
    shapePanel = new JPanel();
    shapeComboBox = new JComboBox();
    iconColorbutton = new JButton();
    iconButton = new JButton();
    clearFileButton = new JButton();
    textureButton = new JButton();
    clearTextureButton = new JButton();
    previewPanel = new JPanel();
    panel3 = new JPanel();
    label1 = new JLabel();
    label2 = new JLabel();
    label3 = new JLabel();
    label4 = new JLabel();
    sizeComboBox = new JComboBox();
    sizeMinComboBox = new JComboBox();
    sizeMaxComboBox = new JComboBox();
    sizeScaleComboBox = new JComboBox();
    panel4 = new JPanel();
    label5 = new JLabel();
    label6 = new JLabel();
    label7 = new JLabel();
    label19 = new JLabel();
    labelComboBox = new JComboBox();
    labelPositionComboBox = new JComboBox();
    labelOffsetTextField = new JTextField();
    labelPrecisionComboBox = new JComboBox();
    panel2 = new JPanel();
    label8 = new JLabel();
    label9 = new JLabel();
    label10 = new JLabel();
    label11 = new JLabel();
    labelFontFamilyComboBox = new JComboBox();
    labelFontSizeComboBox = new JComboBox();
    labelFontStyleComboBox = new JComboBox();
    fontColorButton = new JButton();
    panel6 = new JPanel();
    label15 = new JLabel();
    label16 = new JLabel();
    label17 = new JLabel();
    label18 = new JLabel();
    label12 = new JLabel();
    redValueComboBox = new JComboBox();
    redMinComboBox = new JComboBox();
    redMaxComboBox = new JComboBox();
    redScaleComboBox = new JComboBox();
    label13 = new JLabel();
    greenValueComboBox = new JComboBox();
    greenMinComboBox = new JComboBox();
    greenMaxComboBox = new JComboBox();
    greenScaleComboBox = new JComboBox();
    label14 = new JLabel();
    blueValueComboBox = new JComboBox();
    blueMinComboBox = new JComboBox();
    blueMaxComboBox = new JComboBox();
    blueScaleComboBox = new JComboBox();
    CellConstraints cc = new CellConstraints();

    //======== this ========
    setModal(true);//from ww w .j av  a2 s. c o  m
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    //======== dialogPane ========
    {
        dialogPane.setBorder(Borders.DIALOG);
        dialogPane.setLayout(new BorderLayout());

        //======== buttonBar ========
        {
            buttonBar.setBorder(Borders.BUTTON_BAR_PAD);
            buttonBar.setLayout(new FormLayout(
                    new ColumnSpec[] { FormSpecs.GLUE_COLSPEC, FormSpecs.BUTTON_COLSPEC,
                            FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.BUTTON_COLSPEC },
                    RowSpec.decodeSpecs("pref")));

            //---- okButton ----
            okButton.setText("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    okButtonActionPerformed(e);
                }
            });
            buttonBar.add(okButton, cc.xy(2, 1));

            //---- cancelButton ----
            cancelButton.setText("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    cancelButtonActionPerformed(e);
                }
            });
            buttonBar.add(cancelButton, cc.xy(4, 1));
        }
        dialogPane.add(buttonBar, BorderLayout.SOUTH);

        //======== panel1 ========
        {
            panel1.setLayout(new FormLayout(
                    new ColumnSpec[] { ColumnSpec.decode("left:max(default;166dlu):grow"),
                            FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                            FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(133)),
                            FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC },
                    new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                            FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                            FormSpecs.LINE_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                            FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                            FormSpecs.DEFAULT_ROWSPEC }));

            //======== shapePanel ========
            {
                shapePanel.setBorder(new TitledBorder("Icon Shape and Color"));
                shapePanel.setLayout(new FormLayout(
                        new ColumnSpec[] { new ColumnSpec(Sizes.dluX(79)),
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC },
                        new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                new RowSpec(Sizes.dluY(17)) }));

                //---- shapeComboBox ----
                shapeComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        shapeComboBoxActionPerformed(e);
                    }
                });
                shapePanel.add(shapeComboBox, cc.xy(1, 1));

                //---- iconColorbutton ----
                iconColorbutton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        iconColorbuttonActionPerformed(e);
                    }
                });
                shapePanel.add(iconColorbutton, cc.xy(3, 1));

                //---- iconButton ----
                iconButton.setText("text");
                iconButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        iconButtonActionPerformed(e);
                    }
                });
                shapePanel.add(iconButton, cc.xy(1, 5));

                //---- clearFileButton ----
                clearFileButton.setText("text");
                clearFileButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        clearFileButtonActionPerformed(e);
                    }
                });
                shapePanel.add(clearFileButton, cc.xy(3, 5));

                //---- textureButton ----
                textureButton.setText("Select Texture");
                textureButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        textureButtonActionPerformed(e);
                    }
                });
                shapePanel.add(textureButton, cc.xy(1, 7));

                //---- clearTextureButton ----
                clearTextureButton.setText("Clear Texture");
                clearTextureButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        clearTextureButtonActionPerformed(e);
                    }
                });
                shapePanel.add(clearTextureButton, cc.xy(3, 7));
            }
            panel1.add(shapePanel, cc.xywh(1, 1, 2, 1));

            //======== previewPanel ========
            {
                previewPanel.setBorder(new TitledBorder("Icon Preview"));
                previewPanel.setLayout(new FormLayout("101dlu:grow", "top:57dlu:grow"));
            }
            panel1.add(previewPanel, cc.xywh(5, 1, 3, 1, CellConstraints.DEFAULT, CellConstraints.TOP));

            //======== panel3 ========
            {
                panel3.setBorder(new TitledBorder("Icon Size"));
                panel3.setLayout(new FormLayout(
                        new ColumnSpec[] { ColumnSpec.decode("max(pref;66dlu)"),
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC },
                        new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                FormSpecs.DEFAULT_ROWSPEC }));

                //---- label1 ----
                label1.setText("Value");
                panel3.add(label1, cc.xy(1, 1));

                //---- label2 ----
                label2.setText("Minimum");
                panel3.add(label2, cc.xy(5, 1));

                //---- label3 ----
                label3.setText("Maximum");
                panel3.add(label3, cc.xy(9, 1));

                //---- label4 ----
                label4.setText("Scaling");
                panel3.add(label4, cc.xy(13, 1));

                //---- sizeComboBox ----
                sizeComboBox.setEditable(true);
                sizeComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        sizeComboBoxActionPerformed(e);
                    }
                });
                panel3.add(sizeComboBox, cc.xy(1, 3));

                //---- sizeMinComboBox ----
                sizeMinComboBox.setEditable(true);
                sizeMinComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        sizeMinComboBoxActionPerformed(e);
                    }
                });
                panel3.add(sizeMinComboBox, cc.xy(5, 3));

                //---- sizeMaxComboBox ----
                sizeMaxComboBox.setEditable(true);
                sizeMaxComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        sizeMaxComboBoxActionPerformed(e);
                    }
                });
                panel3.add(sizeMaxComboBox, cc.xy(9, 3));

                //---- sizeScaleComboBox ----
                sizeScaleComboBox.setEditable(true);
                sizeScaleComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        sizeScaleComboBoxActionPerformed(e);
                    }
                });
                panel3.add(sizeScaleComboBox, cc.xy(13, 3));
            }
            panel1.add(panel3, cc.xywh(1, 3, 7, 1));

            //======== panel4 ========
            {
                panel4.setBorder(new TitledBorder("Icon Label"));
                panel4.setLayout(new FormLayout(
                        new ColumnSpec[] { ColumnSpec.decode("max(pref;67dlu)"),
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, new ColumnSpec(Sizes.dluX(33)),
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                                FormSpecs.LABEL_COMPONENT_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC },
                        new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                FormSpecs.DEFAULT_ROWSPEC }));

                //---- label5 ----
                label5.setText("Value");
                panel4.add(label5, cc.xy(1, 1));

                //---- label6 ----
                label6.setText("Position");
                panel4.add(label6, cc.xy(5, 1));

                //---- label7 ----
                label7.setText("Offset");
                panel4.add(label7, cc.xy(9, 1));

                //---- label19 ----
                label19.setText("Precision");
                panel4.add(label19, cc.xy(13, 1));

                //---- labelComboBox ----
                labelComboBox.setEditable(true);
                labelComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        labelComboBoxActionPerformed(e);
                    }
                });
                panel4.add(labelComboBox, cc.xy(1, 3));

                //---- labelPositionComboBox ----
                labelPositionComboBox.setEditable(true);
                labelPositionComboBox
                        .setModel(new DefaultComboBoxModel(new String[] { "bottom", "top", "left", "right" }));
                labelPositionComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        labelPositionComboBoxActionPerformed(e);
                    }
                });
                panel4.add(labelPositionComboBox, cc.xy(5, 3));

                //---- labelOffsetTextField ----
                labelOffsetTextField.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        labelOffsetTextFieldActionPerformed(e);
                    }
                });
                panel4.add(labelOffsetTextField, cc.xy(9, 3));

                //---- labelPrecisionComboBox ----
                labelPrecisionComboBox.setEditable(true);
                labelPrecisionComboBox.setModel(new DefaultComboBoxModel(
                        new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12" }));
                labelPrecisionComboBox.setSelectedIndex(2);
                labelPrecisionComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        labelPrecisionComboBoxActionPerformed(e);
                    }
                });
                panel4.add(labelPrecisionComboBox, cc.xy(13, 3));
            }
            panel1.add(panel4, cc.xywh(1, 5, 7, 1));

            //======== panel2 ========
            {
                panel2.setBorder(new TitledBorder("Icon Label Font"));
                panel2.setLayout(new FormLayout(
                        new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC },
                        new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                FormSpecs.DEFAULT_ROWSPEC }));

                //---- label8 ----
                label8.setText("Font");
                panel2.add(label8, cc.xy(1, 1));

                //---- label9 ----
                label9.setText("Font Size");
                panel2.add(label9, cc.xy(5, 1));

                //---- label10 ----
                label10.setText("Font Style");
                panel2.add(label10, cc.xy(9, 1));

                //---- label11 ----
                label11.setText("Font Color");
                panel2.add(label11, cc.xy(13, 1));

                //---- labelFontFamilyComboBox ----
                labelFontFamilyComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        labelFontFamilyComboBoxActionPerformed(e);
                    }
                });
                panel2.add(labelFontFamilyComboBox, cc.xy(1, 3));

                //---- labelFontSizeComboBox ----
                labelFontSizeComboBox.setModel(new DefaultComboBoxModel(new String[] { "8", "10", "11", "12",
                        "14", "16", "18", "20", "24", "30", "36", "40", "48", "60", "72 " }));
                labelFontSizeComboBox.setEditable(true);
                labelFontSizeComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        labelFontSizeComboBoxActionPerformed(e);
                    }
                });
                panel2.add(labelFontSizeComboBox, cc.xy(5, 3));

                //---- labelFontStyleComboBox ----
                labelFontStyleComboBox
                        .setModel(new DefaultComboBoxModel(new String[] { "Plain", "Bold", "Italic" }));
                labelFontStyleComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        labelFontStyleComboBoxActionPerformed(e);
                    }
                });
                panel2.add(labelFontStyleComboBox, cc.xy(9, 3));

                //---- fontColorButton ----
                fontColorButton.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        fontColorButtonActionPerformed(e);
                    }
                });
                panel2.add(fontColorButton, cc.xy(13, 3));
            }
            panel1.add(panel2, cc.xywh(1, 7, 7, 1));

            //======== panel6 ========
            {
                panel6.setBorder(new TitledBorder("Variable Icon Color"));
                panel6.setLayout(new FormLayout(
                        new ColumnSpec[] { FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC, FormSpecs.LABEL_COMPONENT_GAP_COLSPEC,
                                FormSpecs.DEFAULT_COLSPEC },
                        new RowSpec[] { FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                FormSpecs.DEFAULT_ROWSPEC, FormSpecs.LINE_GAP_ROWSPEC,
                                FormSpecs.DEFAULT_ROWSPEC }));

                //---- label15 ----
                label15.setText("Value");
                panel6.add(label15, cc.xy(3, 1));

                //---- label16 ----
                label16.setText("Minimum");
                panel6.add(label16, cc.xy(7, 1));

                //---- label17 ----
                label17.setText("Maximum");
                panel6.add(label17, cc.xy(11, 1));

                //---- label18 ----
                label18.setText("Scaling");
                panel6.add(label18, cc.xy(15, 1));

                //---- label12 ----
                label12.setText("Red");
                panel6.add(label12, cc.xy(1, 3));

                //---- redValueComboBox ----
                redValueComboBox.setEditable(true);
                redValueComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        redValueComboBoxActionPerformed(e);
                    }
                });
                panel6.add(redValueComboBox, cc.xy(3, 3));

                //---- redMinComboBox ----
                redMinComboBox.setEditable(true);
                redMinComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        redMinComboBoxActionPerformed(e);
                    }
                });
                panel6.add(redMinComboBox, cc.xy(7, 3));

                //---- redMaxComboBox ----
                redMaxComboBox.setEditable(true);
                redMaxComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        redMaxComboBoxActionPerformed(e);
                    }
                });
                panel6.add(redMaxComboBox, cc.xy(11, 3));

                //---- redScaleComboBox ----
                redScaleComboBox.setEditable(true);
                redScaleComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        redScaleComboBoxActionPerformed(e);
                    }
                });
                panel6.add(redScaleComboBox, cc.xy(15, 3));

                //---- label13 ----
                label13.setText("Green");
                panel6.add(label13, cc.xy(1, 5));

                //---- greenValueComboBox ----
                greenValueComboBox.setEditable(true);
                greenValueComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        greenValueComboBoxActionPerformed(e);
                    }
                });
                panel6.add(greenValueComboBox, cc.xy(3, 5));

                //---- greenMinComboBox ----
                greenMinComboBox.setEditable(true);
                greenMinComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        greenMinComboBoxActionPerformed(e);
                    }
                });
                panel6.add(greenMinComboBox, cc.xy(7, 5));

                //---- greenMaxComboBox ----
                greenMaxComboBox.setEditable(true);
                greenMaxComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        greenMaxComboBoxActionPerformed(e);
                    }
                });
                panel6.add(greenMaxComboBox, cc.xy(11, 5));

                //---- greenScaleComboBox ----
                greenScaleComboBox.setEditable(true);
                greenScaleComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        greenScaleComboBoxActionPerformed(e);
                    }
                });
                panel6.add(greenScaleComboBox, cc.xy(15, 5));

                //---- label14 ----
                label14.setText("Blue");
                panel6.add(label14, cc.xy(1, 7));

                //---- blueValueComboBox ----
                blueValueComboBox.setEditable(true);
                blueValueComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        blueValueComboBoxActionPerformed(e);
                    }
                });
                panel6.add(blueValueComboBox, cc.xy(3, 7));

                //---- blueMinComboBox ----
                blueMinComboBox.setEditable(true);
                blueMinComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        blueMinComboBoxActionPerformed(e);
                    }
                });
                panel6.add(blueMinComboBox, cc.xy(7, 7));

                //---- blueMaxComboBox ----
                blueMaxComboBox.setEditable(true);
                blueMaxComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        blueMaxComboBoxActionPerformed(e);
                    }
                });
                panel6.add(blueMaxComboBox, cc.xy(11, 7));

                //---- blueScaleComboBox ----
                blueScaleComboBox.setEditable(true);
                blueScaleComboBox.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        blueScaleComboBoxActionPerformed(e);
                    }
                });
                panel6.add(blueScaleComboBox, cc.xy(15, 7));
            }
            panel1.add(panel6, cc.xywh(1, 9, 7, 1));
        }
        dialogPane.add(panel1, BorderLayout.CENTER);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    setSize(520, 595);
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:ro.nextreports.designer.datasource.ConnectionDialog.java

private void create() {
    this.getContentPane().setLayout(new GridBagLayout());
    this.addComponentListener(new ComponentAdapter() {
        public void componentResized(ComponentEvent e) {
            resize();//from  w  w  w  .  ja v  a  2s . c  o m
        }
    });

    JPanel p = new JPanel(new GridBagLayout());
    backColor = p.getBackground();

    mName = new JTextField();
    mDriver = new JTextField();
    //mDriver.setBackground(backColor);
    mURL = new JTextField();
    //mURL.setBackground(backColor);
    mUser = new JTextField();
    //mUser.setBackground(backColor);
    mPassword = new JPasswordField();
    mPassword.setEchoChar('*');
    //mPassword.setBackground(backColor);
    txaStatus = new JTextArea();
    txaStatus.setEditable(false);
    txaStatus.setBackground(backColor);
    scr = new JScrollPane(txaStatus);
    scr.setSize(220, 50);
    scr.setBorder(new TitledBorder(STATUS));
    types = new JComboBox();
    types.addItemListener(this);

    urlFormatLabel = new JLabel();
    Font font = urlFormatLabel.getFont().deriveFont(Font.BOLD, 10);
    urlFormatLabel.setFont(font);

    urlButton = new JButton();
    urlButton.setPreferredSize(buttonDim);
    urlButton.setMinimumSize(buttonDim);
    urlButton.setMaximumSize(buttonDim);
    urlButton.setIcon(ImageUtil.getImageIcon("url_edit"));
    urlButton.setToolTipText(I18NSupport.getString("connection.dialog.tags.tooltip"));
    urlButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            editUrl();
        }
    });

    for (DriverTemplate template : templates) {
        types.addItem(template.getType());
    }
    types.setSelectedItem(DEFAULT_DRIVER_TYPE);

    auto = new JCheckBox(I18NSupport.getString("connection.dialog.auto"));

    if (viewOnly) {
        mName.setEditable(false);
        types.setEnabled(false);
        mDriver.setEditable(false);
        mURL.setEditable(false);
        mUser.setEditable(false);
        mPassword.setEditable(false);
        urlButton.setEnabled(false);
    }

    p.add(new JLabel(I18NSupport.getString("connection.dialog.name")), new GridBagConstraints(0, 0, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mName, new GridBagConstraints(1, 0, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JLabel(I18NSupport.getString("connection.dialog.type")), new GridBagConstraints(0, 1, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(types, new GridBagConstraints(1, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JLabel(I18NSupport.getString("connection.dialog.driver")), new GridBagConstraints(0, 2, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mDriver, new GridBagConstraints(1, 2, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JLabel(I18NSupport.getString("connection.dialog.url")), new GridBagConstraints(0, 3, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mURL, new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 0), 0, 0));
    p.add(urlButton, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));

    if (!viewOnly) {
        p.add(urlFormatLabel, new GridBagConstraints(1, 4, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(0, 5, 5, 5), 0, 0));
    }

    p.add(new JLabel(I18NSupport.getString("connection.dialog.user")), new GridBagConstraints(0, 5, 1, 1, 0.0,
            0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mUser, new GridBagConstraints(1, 5, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    p.add(new JLabel(I18NSupport.getString("connection.dialog.password")), new GridBagConstraints(0, 6, 1, 1,
            0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 0), 0, 0));
    p.add(mPassword, new GridBagConstraints(1, 6, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));

    if (!viewOnly) {
        p.add(auto, new GridBagConstraints(1, 7, 2, 1, 1.0, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
    }

    JButton okBtn, disBtn, drvBtn, addBtn, propBtn;
    okBtn = new JButton(I18NSupport.getString("connection.dialog.test"),
            ImageUtil.getImageIcon("database_connect"));
    okBtn.setMnemonic('T');
    okBtn.setActionCommand("ConnectOk");
    okBtn.setToolTipText(I18NSupport.getString("connection.dialog.test.tooltip"));
    okBtn.addActionListener(this);
    disBtn = new JButton(I18NSupport.getString("connection.dialog.disconnect"),
            ImageUtil.getImageIcon("database"));
    disBtn.setMnemonic('D');
    disBtn.setActionCommand("Disconnect");
    disBtn.setToolTipText(I18NSupport.getString("connection.dialog.disconnect"));
    disBtn.addActionListener(this);
    drvBtn = new JButton(I18NSupport.getString("connection.dialog.add.driver"),
            ImageUtil.getImageIcon("add_driver"));
    drvBtn.setMnemonic('A');
    drvBtn.setActionCommand("AddDriver");
    drvBtn.setToolTipText(I18NSupport.getString("connection.dialog.add.driver.tooltip"));
    drvBtn.addActionListener(this);
    propBtn = new JButton(I18NSupport.getString("connection.dialog.properties"),
            ImageUtil.getImageIcon("properties"));
    propBtn.setMnemonic('P');
    propBtn.setActionCommand("Properties");
    propBtn.setToolTipText(I18NSupport.getString("connection.dialog.properties.tooltip"));
    propBtn.addActionListener(this);
    addBtn = new JButton(ImageUtil.getImageIcon("database_export"));
    if (oldDataSource == null) {
        addBtn.setText(I18NSupport.getString("connection.dialog.save"));
        addBtn.setToolTipText(I18NSupport.getString("connection.dialog.save.tooltip"));
        addBtn.setMnemonic('S');
    } else {
        addBtn.setText(I18NSupport.getString("connection.dialog.modify"));
        addBtn.setToolTipText(I18NSupport.getString("connection.dialog.modify.tooltip"));
        addBtn.setMnemonic('M');
    }
    addBtn.setActionCommand("AddDataSource");
    addBtn.addActionListener(this);
    JPanel btnPanel = new JPanel();
    btnPanel.setLayout(new BoxLayout(btnPanel, BoxLayout.X_AXIS));
    btnPanel.add(Box.createHorizontalGlue());
    btnPanel.add(propBtn);
    btnPanel.add(Box.createRigidArea(new Dimension(5, 5)));
    btnPanel.add(okBtn);
    btnPanel.add(Box.createRigidArea(new Dimension(5, 5)));
    //btnPanel.add(disBtn);
    //btnPanel.add(Box.createRigidArea(new Dimension(5, 5)));
    btnPanel.add(addBtn);
    //        btnPanel.add(Box.createRigidArea(new Dimension(5, 5)));
    //        btnPanel.add(drvBtn);
    SwingUtil.equalizeButtonSizes(btnPanel);

    if (!viewOnly) {
        p.add(btnPanel, new GridBagConstraints(0, 8, 3, 1, 1.0, 0.0, GridBagConstraints.EAST,
                GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
        p.add(scr, new GridBagConstraints(0, 9, 3, 1, 1.0, 1.0, GridBagConstraints.EAST,
                GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
    }

    this.getContentPane().add(p, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));

    if (oldDataSource != null) {
        mName.setText(oldDataSource.getName());
        types.setSelectedItem(oldDataSource.getType());
        mDriver.setText(oldDataSource.getDriver());
        mURL.setText(oldDataSource.getUrl());
        mUser.setText(oldDataSource.getUser());
        mPassword.setText(oldDataSource.getPassword());
    }
}

From source file:ro.nextreports.designer.querybuilder.SelectionColumnPanel.java

private void buildUI() {

    setLayout(new GridBagLayout());

    final DBViewer viewer = Globals.getDBViewer();

    schemaCombo = new JComboBox();
    schemaCombo.setPreferredSize(comboDim);

    schemaCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            String schema = (String) e.getItem();
            shownColumnModel.clear();// w  ww. j a v a 2  s.c  o  m
            columnModel.clear();
            tableModel.clear();
            try {
                DBInfo dbInfo = viewer.getDBInfo(schema, DBInfo.TABLES | DBInfo.VIEWS);
                List<DBTable> tables = dbInfo.getTables();
                Collections.sort(tables);
                for (DBTable table : tables) {
                    tableModel.addElement(table);
                }
            } catch (NextSqlException ex) {
                LOG.error(ex.getMessage(), ex);
                ex.printStackTrace();
            }
        }
    });

    try {
        List<String> schemas = viewer.getSchemas();
        String schemaName = viewer.getUserSchema();
        Collections.sort(schemas);
        boolean added = false;
        for (String schema : schemas) {
            if (DefaultSchemaManager.getInstance().isVisible(
                    DefaultDataSourceManager.getInstance().getConnectedDataSource().getName(), schema)) {
                added = true;
                schemaCombo.addItem(schema);
            }
        }

        if ((schema == null) || schema.equals(DefaultDBViewer.NO_SCHEMA_NAME)) {
            schema = DefaultDBViewer.NO_SCHEMA_NAME;//viewer.getUserSchema();
        }
        if (!added) {
            schemaCombo.addItem(schema);
        }
        schemaCombo.setSelectedItem(schema);
    } catch (NextSqlException e) {
        LOG.error(e.getMessage(), e);
        e.printStackTrace();
    }

    // create table list
    tableList = new JXList(tableModel);
    tableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    tableList.setCellRenderer(new DBTableCellRenderer());

    // create column list
    columnList = new JXList(columnModel);
    if (singleSelection) {
        columnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }
    columnList.setCellRenderer(new DBColumnCellRenderer());

    shownColumnList = new JXList(shownColumnModel);
    if (singleSelection) {
        shownColumnList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    } else {
        columnList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    }
    addDoubleClick();

    shownColumnList.setCellRenderer(new DBColumnCellRenderer());
    shownColumnList.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent mouseEvent) {
            if ((mouseEvent.getModifiers() & InputEvent.BUTTON3_MASK) == InputEvent.BUTTON3_MASK) {
                JPopupMenu popupMenu = new JPopupMenu();
                JMenuItem menuItem = new JMenuItem(new DeselectListAction(shownColumnList));
                popupMenu.add(menuItem);
                popupMenu.show((Component) mouseEvent.getSource(), mouseEvent.getX(), mouseEvent.getY());
            }
        }
    });

    tableList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (e.getValueIsAdjusting() == false) {
                int index = tableList.getSelectedIndex();
                if (index == -1) {
                    return;
                }
                DBTable table = (DBTable) tableModel.getElementAt(index);
                try {
                    List<DBColumn> columns = null;
                    try {
                        columns = viewer.getColumns(table.getSchema(), table.getName());
                    } catch (MalformedTableNameException e1) {
                        Show.error("Malformed table name : " + table.getName());
                        return;
                    }
                    Collections.sort(columns);
                    columnModel.clear();
                    shownColumnModel.clear();
                    for (DBColumn column : columns) {
                        columnModel.addElement(column);
                        shownColumnModel.addElement(column);
                    }
                } catch (NextSqlException e1) {
                    LOG.error(e1.getMessage(), e1);
                    e1.printStackTrace();
                    Show.error(e1);
                }
            }
        }
    });

    columnList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            shownColumnList.clearSelection();
        }
    });

    scrTable = new JScrollPane(tableList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrTable.setPreferredSize(scrDim);
    scrTable.setMinimumSize(scrDim);
    scrTable.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.tables")));
    scrColumn = new JScrollPane(columnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrColumn.setPreferredSize(scrDim);
    scrColumn.setMinimumSize(scrDim);
    scrColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.columns")));
    scrShownColumn = new JScrollPane(shownColumnList, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrShownColumn.setPreferredSize(scrDim);
    scrShownColumn.setMinimumSize(scrDim);
    scrShownColumn.setBorder(new TitledBorder(I18NSupport.getString("parameter.source.shown.columns")));

    JPanel schemaPanel = new JPanel();
    schemaPanel.setLayout(new BoxLayout(schemaPanel, BoxLayout.X_AXIS));
    schemaPanel.add(new JLabel("Schema"));
    schemaPanel.add(Box.createHorizontalStrut(5));
    schemaPanel.add(schemaCombo);

    add(schemaPanel, new GridBagConstraints(0, 0, 3, 1, 0.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
    add(scrTable, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH,
            new Insets(0, 0, 0, 5), 0, 0));
    add(scrColumn, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 5), 0, 0));
    if (show) {
        add(scrShownColumn, new GridBagConstraints(2, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    }
}

From source file:ru.goodfil.catalog.ui.forms.OePanel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - ????? ???????
    panel1 = new JPanel();
    panel2 = new JPanel();
    btnCreateBrand = new JButton();
    btnEditBrand = new JButton();
    btnRemoveBrand = new JButton();
    btnUnionBrand = new JButton();
    hSpacer1 = new JPanel(null);
    tbSearchBrand = new JTextField();
    btnSearchBrand = new JButton();
    scrollPane1 = new JScrollPane();
    lstBrands = new JList();
    lLstBrandsStatus = new JLabel();
    panel3 = new JPanel();
    panel4 = new JPanel();
    btnCreateOe = new JButton();
    btnEditOe = new JButton();
    btnRemoveOe = new JButton();
    btnUnionOe = new JButton();
    hSpacer2 = new JPanel(null);
    tbSearchOe = new JTextField();
    btnSearchOe = new JButton();
    scrollPane2 = new JScrollPane();
    lstOes = new JList();
    lLstOesStatus = new JLabel();
    popupMenu1 = new JPopupMenu();
    menuItem1 = new JMenuItem();
    menuItem2 = new JMenuItem();
    menuItem3 = new JMenuItem();
    menuItem4 = new JMenuItem();
    popupMenu2 = new JPopupMenu();
    menu1 = new JMenu();
    menuItem5 = new JMenuItem();
    menuItem6 = new JMenuItem();
    CellConstraints cc = new CellConstraints();

    //======== this ========

    // JFormDesigner evaluation mark
    setBorder(/*from  w ww. j a  v a 2  s  .  c  om*/
            new javax.swing.border.CompoundBorder(
                    new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),
                            "JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,
                            javax.swing.border.TitledBorder.BOTTOM,
                            new java.awt.Font("Dialog", java.awt.Font.BOLD, 12), java.awt.Color.red),
                    getBorder()));
    addPropertyChangeListener(new java.beans.PropertyChangeListener() {
        public void propertyChange(java.beans.PropertyChangeEvent e) {
            if ("border".equals(e.getPropertyName()))
                throw new RuntimeException();
        }
    });

    setLayout(new FormLayout("default:grow, $lcgap, default:grow", "fill:default:grow"));

    //======== panel1 ========
    {
        panel1.setBorder(new TitledBorder(
                "\u041f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u0438"));
        panel1.setLayout(
                new FormLayout("default:grow", "fill:21dlu, $lgap, fill:default:grow, $lgap, default"));

        //======== panel2 ========
        {
            panel2.setLayout(new FormLayout("4*(21dlu), default:grow, 100dlu, 21dlu", "fill:default:grow"));

            //---- btnCreateBrand ----
            btnCreateBrand
                    .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png")));
            btnCreateBrand.setToolTipText(
                    "\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440");
            btnCreateBrand.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnCreateBrandActionPerformed(e);
                }
            });
            panel2.add(btnCreateBrand, cc.xy(1, 1));

            //---- btnEditBrand ----
            btnEditBrand
                    .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png")));
            btnEditBrand.setToolTipText(
                    "\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440");
            btnEditBrand.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnEditBrandActionPerformed(e);
                }
            });
            panel2.add(btnEditBrand, cc.xy(2, 1));

            //---- btnRemoveBrand ----
            btnRemoveBrand.setIcon(
                    new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png")));
            btnRemoveBrand.setToolTipText(
                    "\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440");
            btnRemoveBrand.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnRemoveBrandActionPerformed(e);
                }
            });
            panel2.add(btnRemoveBrand, cc.xy(3, 1));

            //---- btnUnionBrand ----
            btnUnionBrand.setIcon(
                    new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/recycle_24.png")));
            btnUnionBrand.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnUnionBrandActionPerformed(e);
                }
            });
            panel2.add(btnUnionBrand, cc.xy(4, 1));
            panel2.add(hSpacer1, cc.xy(5, 1));

            //---- tbSearchBrand ----
            tbSearchBrand.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    tbSearchBrandKeyTyped(e);
                }

                @Override
                public void keyReleased(KeyEvent e) {
                    tbSearchBrandKeyTyped(e);
                }

                @Override
                public void keyTyped(KeyEvent e) {
                    tbSearchBrandKeyTyped(e);
                }
            });
            tbSearchBrand.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    tbSearchBrandFocusGained(e);
                }

                @Override
                public void focusLost(FocusEvent e) {
                    tbSearchBrandFocusGained(e);
                }
            });
            panel2.add(tbSearchBrand, cc.xy(6, 1));

            //---- btnSearchBrand ----
            btnSearchBrand.setIcon(
                    new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/find_next_24.png")));
            btnSearchBrand.setToolTipText(
                    "\u041f\u043e\u0438\u0441\u043a \u043c\u043e\u0442\u043e\u0440\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438");
            btnSearchBrand.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnSearchBrandActionPerformed(e);
                }
            });
            panel2.add(btnSearchBrand, cc.xy(7, 1));
        }
        panel1.add(panel2, cc.xy(1, 1));

        //======== scrollPane1 ========
        {

            //---- lstBrands ----
            lstBrands.setToolTipText(
                    "\u0415\u0441\u043b\u0438 \u0448\u0440\u0438\u0444\u0442 \u0411\u0440\u0435\u043d\u0434\u0430 \u0432\u044b\u0434\u0435\u043b\u0435\u043d \u043f\u043e\u043b\u0443\u0436\u0438\u0440\u043d\u044b\u043c, \u0442\u043e \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0432\u0438\u0434\u0435\u043d \u0432 \u043e\u0442\u0447\u0443\u0436\u0434\u0430\u0435\u043c\u043e\u0439 \u043a\u043e\u043f\u0438\u0438, \u0434\u043b\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043e\u043a. \u0415\u0441\u043b\u0438 \u0436\u0435 \u043d\u0435 \u0432\u044b\u0434\u0435\u043b\u0435\u043d, \u0442\u043e \u0432\u0438\u0434\u0435\u043d \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.");
            lstBrands.addListSelectionListener(new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    lstBrandsValueChanged(e);
                }
            });
            lstBrands.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    lstBrandsKeyPressed(e);
                }
            });
            lstBrands.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    lstBrandsMouseClicked(e);
                }
            });
            scrollPane1.setViewportView(lstBrands);
        }
        panel1.add(scrollPane1, cc.xy(1, 3));

        //---- lLstBrandsStatus ----
        lLstBrandsStatus.setText("text");
        panel1.add(lLstBrandsStatus, cc.xy(1, 5));
    }
    add(panel1, cc.xy(1, 1));

    //======== panel3 ========
    {
        panel3.setBorder(new TitledBorder("\u041d\u043e\u043c\u0435\u0440\u0430 \u041e\u0415"));
        panel3.setLayout(new FormLayout("default:grow", "default, $lgap, fill:default:grow, $lgap, default"));

        //======== panel4 ========
        {
            panel4.setLayout(new FormLayout("4*(21dlu), default:grow, 100dlu, 21dlu", "fill:21dlu"));

            //---- btnCreateOe ----
            btnCreateOe
                    .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/add_24.png")));
            btnCreateOe.setToolTipText(
                    "\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440");
            btnCreateOe.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnCreateOeActionPerformed(e);
                }
            });
            panel4.add(btnCreateOe, cc.xy(1, 1));

            //---- btnEditOe ----
            btnEditOe
                    .setIcon(new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/edit_24.png")));
            btnEditOe.setToolTipText(
                    "\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440");
            btnEditOe.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnEditOeActionPerformed(e);
                }
            });
            panel4.add(btnEditOe, cc.xy(2, 1));

            //---- btnRemoveOe ----
            btnRemoveOe.setIcon(
                    new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/delete_24.png")));
            btnRemoveOe.setToolTipText(
                    "\u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0444\u0438\u043b\u044c\u0442\u0440");
            btnRemoveOe.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnRemoveOeActionPerformed(e);
                }
            });
            panel4.add(btnRemoveOe, cc.xy(3, 1));

            //---- btnUnionOe ----
            btnUnionOe.setIcon(
                    new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/recycle_24.png")));
            btnUnionOe.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnUnionOeActionPerformed(e);
                }
            });
            panel4.add(btnUnionOe, cc.xy(4, 1));
            panel4.add(hSpacer2, cc.xy(5, 1));

            //---- tbSearchOe ----
            tbSearchOe.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    tbSearchOeKeyPressed(e);
                }

                @Override
                public void keyReleased(KeyEvent e) {
                    tbSearchOeKeyPressed(e);
                }
            });
            tbSearchOe.addFocusListener(new FocusAdapter() {
                @Override
                public void focusGained(FocusEvent e) {
                    tbSearchOeFocusGained(e);
                }

                @Override
                public void focusLost(FocusEvent e) {
                    tbSearchOeFocusGained(e);
                }
            });
            panel4.add(tbSearchOe, cc.xy(6, 1));

            //---- btnSearchOe ----
            btnSearchOe.setIcon(
                    new ImageIcon(getClass().getResource("/ru/goodfil/catalog/ui/icons/find_next_24.png")));
            btnSearchOe.setToolTipText(
                    "\u041f\u043e\u0438\u0441\u043a \u043c\u043e\u0442\u043e\u0440\u043e\u0432 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f \u0438\u0437 \u0432\u044b\u0431\u0440\u0430\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u0438\u0438");
            btnSearchOe.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnSearchOeActionPerformed(e);
                }
            });
            panel4.add(btnSearchOe, cc.xy(7, 1));
        }
        panel3.add(panel4, cc.xy(1, 1));

        //======== scrollPane2 ========
        {

            //---- lstOes ----
            lstOes.addKeyListener(new KeyAdapter() {
                @Override
                public void keyPressed(KeyEvent e) {
                    lstOesKeyPressed(e);
                }
            });
            lstOes.addListSelectionListener(new ListSelectionListener() {
                @Override
                public void valueChanged(ListSelectionEvent e) {
                    lstOesValueChanged(e);
                }
            });
            lstOes.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent e) {
                    lstOesMouseClicked(e);
                }
            });
            scrollPane2.setViewportView(lstOes);
        }
        panel3.add(scrollPane2, cc.xy(1, 3));

        //---- lLstOesStatus ----
        lLstOesStatus.setText("text");
        panel3.add(lLstOesStatus, cc.xy(1, 5));
    }
    add(panel3, cc.xy(3, 1));

    //======== popupMenu1 ========
    {
        popupMenu1.addPopupMenuListener(new PopupMenuListener() {
            @Override
            public void popupMenuCanceled(PopupMenuEvent e) {
            }

            @Override
            public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
            }

            @Override
            public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
                popupMenu1PopupMenuWillBecomeVisible(e);
            }
        });

        //---- menuItem1 ----
        menuItem1.setText(
                "\u041a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440");
        menuItem1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                copyToClipboard(e);
            }
        });
        popupMenu1.add(menuItem1);

        //---- menuItem2 ----
        menuItem2.setText(
                "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430");
        menuItem2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                pasteFromClipboard(e);
            }
        });
        popupMenu1.add(menuItem2);
        popupMenu1.addSeparator();

        //---- menuItem3 ----
        menuItem3.setText(
                "\u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0431\u0443\u0444\u0435\u0440 (\u0421 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435\u043c)");
        menuItem3.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                cutToClipboard(e);
            }
        });
        popupMenu1.add(menuItem3);

        //---- menuItem4 ----
        menuItem4.setText(
                "\u0412\u044b\u043d\u0435\u0441\u0442\u0438 \u0438\u0437 \u0431\u0443\u0444\u0435\u0440\u0430");
        menuItem4.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                pasteFromClipboard(e);
            }
        });
        popupMenu1.add(menuItem4);
    }

    //======== popupMenu2 ========
    {

        //======== menu1 ========
        {
            menu1.setText(
                    "\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u043e\u0442\u0447\u0443\u0436\u0434\u0430\u0435\u043c\u043e\u0439 \u043a\u043e\u043f\u0438\u0438");

            //---- menuItem5 ----
            menuItem5.setText("\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c");
            menuItem5.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItemReprezentInStandalone(e);
                }
            });
            menu1.add(menuItem5);

            //---- menuItem6 ----
            menuItem6.setText("\u041d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c");
            menuItem6.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    menuItemDontReprezentInStandalone(e);
                }
            });
            menu1.add(menuItem6);
        }
        popupMenu2.add(menu1);
    }
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:uk.ac.abdn.csd.p2p.server.ServerGUI.java

/**
 * This method prepares all the graphical components that are contained with P2P Visualisation Server.
 *///from  w  w  w . ja  v a2s .  c  o  m
// <editor-fold defaultstate="collapsed" desc="...GUI">
private void initializeComponent() {
    listeningPort = 0;

    JFrame frame = new JFrame();
    BorderLayout layout = new BorderLayout();

    //create a graph
    overlay = new UndirectedSparseGraph<Vertex, Edge>();
    ObservableGraph<Vertex, Edge> og = new ObservableGraph<Vertex, Edge>(overlay);
    /*   og.addGraphEventListener(new GraphEventListener<Vertex, Edge>() {
       @Override
       public void handleGraphEvent(
       GraphEvent<Vertex, Edge> evt) {
    System.err.println("got " + evt);
            
       }
    });*/
    this.overlay = og;
    layout1 = new FRLayout2<Vertex, Edge>(overlay);
    vv = new VisualizationViewer<Vertex, Edge>(layout1, new Dimension(700, 200));
    vv.setGraphMouse(new DefaultModalGraphMouse<Vertex, Edge>());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<Vertex>());
    vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller<Edge>());
    vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
    vv.getRenderContext().setVertexFillPaintTransformer(new VertexPainter());

    DefaultModalGraphMouse gm1 = new DefaultModalGraphMouse();
    gm1.setMode(ModalGraphMouse.Mode.TRANSFORMING);
    gm1.setMode(ModalGraphMouse.Mode.PICKING);
    gm1.add(new MyPopupGraphMousePlugin());
    vv.setGraphMouse(gm1);
    vv.addKeyListener(gm1.getModeKeyListener());

    contentPane = new JPanel(layout);

    displayPanel = new javax.swing.JPanel();

    consoleTextArea = new JTextArea();
    jScrollPane2 = new JScrollPane();
    clearButton = new JButton();
    consolePanel = new JPanel();
    clearButton = new javax.swing.JButton();

    nodeTextArea = new JTextArea();
    jScrollPane1 = new JScrollPane();
    nodePanel = new JPanel();

    linkTextArea = new JTextArea();
    jScrollPane3 = new JScrollPane();
    linkPanel = new JPanel();

    menuBar = new javax.swing.JMenuBar();
    serverMenu = new javax.swing.JMenu();
    startServerMenuItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JPopupMenu.Separator();
    exitMenuItem = new javax.swing.JMenuItem();
    editMenu = new javax.swing.JMenu();
    settingMenuItem = new javax.swing.JMenuItem();
    colorSettingMenuItem = new javax.swing.JMenuItem();
    toolMenuItem = new javax.swing.JMenu();
    clearMenuItem = new javax.swing.JMenuItem();
    helpMenu = new javax.swing.JMenu();
    aboutMenuItem = new javax.swing.JMenuItem();
    zoominMenuItem = new javax.swing.JMenuItem();
    zoomoutMenuItem = new javax.swing.JMenuItem();
    layoutSettingMenuItem = new javax.swing.JMenuItem();
    labelPositionMenuItem = new javax.swing.JMenuItem();
    speedSettingMenuItem = new javax.swing.JMenuItem();
    topologySettingMenuItem = new javax.swing.JMenuItem();
    findNodeMenuItem = new javax.swing.JMenuItem();

    serverMenu.setText("Server");
    serverMenu.setToolTipText("Server");

    startServerMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C,
            java.awt.event.InputEvent.ALT_MASK));
    startServerMenuItem.setText("Start Server");
    startServerMenuItem.setToolTipText("Start Server");
    startServerMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            startServerMenuItemActionPerformed(evt);
        }
    });
    serverMenu.add(startServerMenuItem);
    serverMenu.add(jSeparator1);

    exitMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X,
            java.awt.event.InputEvent.ALT_MASK));
    exitMenuItem.setText("Exit");
    exitMenuItem.setToolTipText("Exit");
    exitMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            exitMenuItemActionPerformed(evt);
        }
    });
    serverMenu.add(exitMenuItem);

    menuBar.add(serverMenu);

    editMenu.setText("Edit");
    editMenu.setToolTipText("Edit");

    settingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S,
            java.awt.event.InputEvent.ALT_MASK));
    settingMenuItem.setText("Server Settings");
    settingMenuItem.setToolTipText("Server Settings");
    settingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            settingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(settingMenuItem);

    colorSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_M,
            java.awt.event.InputEvent.ALT_MASK));
    colorSettingMenuItem.setText("Colour Settings");
    colorSettingMenuItem.setToolTipText("Colour Settings");
    colorSettingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            colorSettingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(colorSettingMenuItem);

    layoutSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L,
            java.awt.event.InputEvent.ALT_MASK));
    layoutSettingMenuItem.setText("Layout Settings");
    layoutSettingMenuItem.setToolTipText("Layout Settings");
    layoutSettingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            layoutSettingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(layoutSettingMenuItem);

    speedSettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V,
            java.awt.event.InputEvent.ALT_MASK));
    speedSettingMenuItem.setText("Speed Settings");
    speedSettingMenuItem.setToolTipText("Speed Settings");
    speedSettingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            speedSettingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(speedSettingMenuItem);

    topologySettingMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T,
            java.awt.event.InputEvent.ALT_MASK));
    topologySettingMenuItem.setText("Topology Settings");
    topologySettingMenuItem.setToolTipText("Topology Settings");
    topologySettingMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            topologySettingMenuItemActionPerformed(evt);
        }
    });
    editMenu.add(topologySettingMenuItem);

    menuBar.add(editMenu);

    toolMenuItem.setText("Tools");
    toolMenuItem.setToolTipText("Tools");

    labelPositionMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P,
            java.awt.event.InputEvent.ALT_MASK));
    labelPositionMenuItem.setText("Vertex Label Position");
    labelPositionMenuItem.setToolTipText("Vertex Label Position");
    toolMenuItem.add(labelPositionMenuItem);
    labelPositionMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            labelPositionMenuItemActionPerformed(evt);

        }
    });

    final ScalingControl scaler = new CrossoverScalingControl();

    zoominMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_I,
            java.awt.event.InputEvent.ALT_MASK));
    zoominMenuItem.setText("Zoom-In");
    zoominMenuItem.setToolTipText("Zoom-In");
    toolMenuItem.add(zoominMenuItem);
    zoominMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    zoomoutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O,
            java.awt.event.InputEvent.ALT_MASK));
    zoomoutMenuItem.setText("Zoom-Out");
    zoomoutMenuItem.setToolTipText("Zoom-Out");
    toolMenuItem.add(zoomoutMenuItem);
    zoomoutMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            scaler.scale(vv, 0.9f, vv.getCenter());
        }
    });

    findNodeMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F,
            java.awt.event.InputEvent.ALT_MASK));
    findNodeMenuItem.setText("Find Node on Overlay");
    findNodeMenuItem.setToolTipText("Find Node");
    toolMenuItem.add(findNodeMenuItem);
    findNodeMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            findNodeMenuItemMenuItemActionPerformed(evt);
        }
    });

    menuBar.add(toolMenuItem);

    helpMenu.setText("Help");
    helpMenu.setToolTipText("Help");

    aboutMenuItem.setText("About");
    aboutMenuItem.setToolTipText("About");
    aboutMenuItem.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            aboutMenuItemActionPerformed(evt);
        }
    });
    helpMenu.add(aboutMenuItem);

    menuBar.add(helpMenu);

    displayPanel.setLayout(new BorderLayout());
    displayPanel.setBorder(new TitledBorder("P2P Overlay"));
    displayPanel.add(vv);
    validate();
    //
    // nodeTextArea
    //
    nodeTextArea.setEditable(false);
    nodeTextArea.setLineWrap(true);

    //
    // jScrollPane1
    //
    jScrollPane1.setViewportView(nodeTextArea);
    //jScrollPane1.setsi
    //
    // nodePanel
    //
    nodePanel.setLayout(new BoxLayout(nodePanel, BoxLayout.X_AXIS));
    nodePanel.add(jScrollPane1, 0);

    nodePanel.setBorder(new TitledBorder("Nodes Active"));
    //
    // linkTextArea
    //
    linkTextArea.setEditable(false);
    linkTextArea.setLineWrap(true);
    //
    // jScrollPane3
    //
    jScrollPane3.setViewportView(linkTextArea);
    //
    // linkPanel
    //
    linkPanel.setLayout(new BoxLayout(linkPanel, BoxLayout.X_AXIS));
    linkPanel.add(jScrollPane3, 0);
    linkPanel.setBorder(new TitledBorder("Node Links"));
    //
    // consoleTextArea
    //
    consoleTextArea.setEditable(false);
    consoleTextArea.setLineWrap(true);
    //
    // jScrollPane2
    //
    jScrollPane2.setViewportView(consoleTextArea);
    //
    // clearButton
    //
    clearButton.setText("Clear");
    clearButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearButton_actionPerformed(e);
        }

    });
    //
    // consolePanel
    //
    consolePanel.setLayout(new BoxLayout(consolePanel, BoxLayout.X_AXIS));
    consolePanel.add(jScrollPane2, 0);
    consolePanel.add(clearButton, 1);
    consolePanel.setBorder(new TitledBorder("Console"));
    //
    // ServerGUI
    //
    Dimension panelD = new Dimension(700, 330); // display Panel
    Dimension panelD1 = new Dimension(700, 134); // control Panel      
    Dimension panelD2 = new Dimension(350, 140); // nodepanel and linkpanel
    Dimension panelD3 = new Dimension(700, 140); // nodepanel and linkpanel togther
    consolePanel.setPreferredSize(panelD1);
    displayPanel.setPreferredSize(panelD);
    nodePanel.setPreferredSize(panelD2);
    linkPanel.setPreferredSize(panelD2);
    Box box = new Box(BoxLayout.X_AXIS); // put nodepanel and linkpanel in one box
    box.add(nodePanel);
    box.add(linkPanel);
    box.setSize(panelD3);

    //contentPane.add(BorderLayout.NORTH,displayPanel);
    //contentPane.add(BorderLayout.CENTER,box);
    contentPane.add(BorderLayout.NORTH, box);
    contentPane.add(BorderLayout.CENTER, displayPanel);
    contentPane.add(BorderLayout.SOUTH, consolePanel);

    frame.setJMenuBar(menuBar);
    frame.getContentPane().add(contentPane);
    frame.setTitle("P2P Visualisation Server");
    frame.setSize(new Dimension(800, 600));
    frame.setResizable(true);
    // This code has been adapted from http://lookass.ch/?id=4&area=art&art=47
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    Dimension size = frame.getSize();
    screenSize.height = screenSize.height / 2;
    screenSize.width = screenSize.width / 2;
    size.height = size.height / 2;
    size.width = size.width / 2;
    int y = screenSize.height - size.height;
    int x = screenSize.width - size.width;
    frame.setLocation(x, y);
    frame.setVisible(true);

    frame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
    frame.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowClosing(java.awt.event.WindowEvent evt) {
            formWindowClosing(evt);
        }
    });
}

From source file:VASSAL.configure.TextConfigurer.java

public java.awt.Component getControls() {
    if (p == null) {
        p = new JPanel();
        p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
        textArea = new JTextArea(6, 20);
        if (wordWrap) {
            textArea.setLineWrap(true);/*w w  w .ja va 2  s.  c  o  m*/
            textArea.setWrapStyleWord(true);
        }
        textArea.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                queueForUpdate(textArea.getText());
            }
        });
        textArea.setText((String) getValue());
        JScrollPane scroll = new ScrollPane(textArea);
        if (name != null) {
            scroll.setBorder(new TitledBorder(name));
        }
        p.add(scroll);
    }
    return p;
}

From source file:VASSAL.launch.ModuleManagerWindow.java

public ModuleManagerWindow() {
    setTitle("VASSAL");
    setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));

    ApplicationIcons.setFor(this);

    final AbstractAction shutDownAction = new AbstractAction() {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            if (!AbstractLaunchAction.shutDown())
                return;

            final Prefs gl = Prefs.getGlobalPrefs();
            try {
                gl.write();/*from w  w  w  .j  a v a  2  s .  c  om*/
                gl.close();
            } catch (IOException ex) {
                WriteErrorDialog.error(ex, gl.getFile());
            } finally {
                IOUtils.closeQuietly(gl);
            }

            logger.info("Exiting");
            System.exit(0);
        }
    };
    shutDownAction.putValue(Action.NAME, Resources.getString(Resources.QUIT));

    setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            shutDownAction.actionPerformed(null);
        }
    });

    // setup menubar and actions
    final MenuManager mm = MenuManager.getInstance();
    final MenuBarProxy mb = mm.getMenuBarProxyFor(this);

    // file menu
    final MenuProxy fileMenu = new MenuProxy(Resources.getString("General.file"));
    fileMenu.setMnemonic(Resources.getString("General.file.shortcut").charAt(0));

    fileMenu.add(mm.addKey("Main.play_module"));
    fileMenu.add(mm.addKey("Main.edit_module"));
    fileMenu.add(mm.addKey("Main.new_module"));
    fileMenu.add(mm.addKey("Main.import_module"));
    fileMenu.addSeparator();

    if (!SystemUtils.IS_OS_MAC_OSX) {
        fileMenu.add(mm.addKey("Prefs.edit_preferences"));
        fileMenu.addSeparator();
        fileMenu.add(mm.addKey("General.quit"));
    }

    // tools menu
    final MenuProxy toolsMenu = new MenuProxy(Resources.getString("General.tools"));

    // Initialize Global Preferences
    Prefs.getGlobalPrefs().getEditor().initDialog(this);
    Prefs.initSharedGlobalPrefs();

    final BooleanConfigurer serverStatusConfig = new BooleanConfigurer(SHOW_STATUS_KEY, null, Boolean.FALSE);
    Prefs.getGlobalPrefs().addOption(null, serverStatusConfig);

    dividerLocationConfig = new IntConfigurer(DIVIDER_LOCATION_KEY, null, -10);
    Prefs.getGlobalPrefs().addOption(null, dividerLocationConfig);

    toolsMenu.add(new CheckBoxMenuItemProxy(new AbstractAction(Resources.getString("Chat.server_status")) {
        private static final long serialVersionUID = 1L;

        public void actionPerformed(ActionEvent e) {
            serverStatusView.toggleVisibility();
            serverStatusConfig.setValue(serverStatusConfig.booleanValue() ? Boolean.FALSE : Boolean.TRUE);
            if (serverStatusView.isVisible()) {
                setDividerLocation(getPreferredDividerLocation());
            }
        }
    }, serverStatusConfig.booleanValue()));

    // help menu
    final MenuProxy helpMenu = new MenuProxy(Resources.getString("General.help"));
    helpMenu.setMnemonic(Resources.getString("General.help.shortcut").charAt(0));

    helpMenu.add(mm.addKey("General.help"));
    helpMenu.add(mm.addKey("Main.tour"));
    helpMenu.addSeparator();
    helpMenu.add(mm.addKey("UpdateCheckAction.update_check"));
    helpMenu.add(mm.addKey("Help.error_log"));

    if (!SystemUtils.IS_OS_MAC_OSX) {
        helpMenu.addSeparator();
        helpMenu.add(mm.addKey("AboutScreen.about_vassal"));
    }

    mb.add(fileMenu);
    mb.add(toolsMenu);
    mb.add(helpMenu);

    // add actions
    mm.addAction("Main.play_module", new Player.PromptLaunchAction(this));
    mm.addAction("Main.edit_module", new Editor.PromptLaunchAction(this));
    mm.addAction("Main.new_module", new Editor.NewModuleLaunchAction(this));
    mm.addAction("Main.import_module", new Editor.PromptImportLaunchAction(this));
    mm.addAction("Prefs.edit_preferences", Prefs.getGlobalPrefs().getEditor().getEditAction());
    mm.addAction("General.quit", shutDownAction);

    URL url = null;
    try {
        url = new File(Documentation.getDocumentationBaseDir(), "README.html").toURI().toURL();
    } catch (MalformedURLException e) {
        ErrorDialog.bug(e);
    }
    mm.addAction("General.help", new ShowHelpAction(url, null));

    mm.addAction("Main.tour", new LaunchTourAction(this));
    mm.addAction("AboutScreen.about_vassal", new AboutVASSALAction(this));
    mm.addAction("UpdateCheckAction.update_check", new UpdateCheckAction(this));
    mm.addAction("Help.error_log", new ShowErrorLogAction(this));

    setJMenuBar(mm.getMenuBarFor(this));

    // Load Icons
    moduleIcon = new ImageIcon(getClass().getResource("/images/mm-module.png"));
    activeExtensionIcon = new ImageIcon(getClass().getResource("/images/mm-extension-active.png"));
    inactiveExtensionIcon = new ImageIcon(getClass().getResource("/images/mm-extension-inactive.png"));
    openGameFolderIcon = new ImageIcon(getClass().getResource("/images/mm-gamefolder-open.png"));
    closedGameFolderIcon = new ImageIcon(getClass().getResource("/images/mm-gamefolder-closed.png"));
    fileIcon = new ImageIcon(getClass().getResource("/images/mm-file.png"));

    // build module controls
    final JPanel moduleControls = new JPanel(new BorderLayout());
    modulePanelLayout = new CardLayout();
    moduleView = new JPanel(modulePanelLayout);
    buildTree();
    final JScrollPane scroll = new JScrollPane(tree);
    moduleView.add(scroll, "modules");

    final JEditorPane l = new JEditorPane("text/html", Resources.getString("ModuleManager.quickstart"));
    l.setEditable(false);

    // Try to get background color and font from LookAndFeel;
    // otherwise, use dummy JLabel to get color and font.
    Color bg = UIManager.getColor("control");
    Font font = UIManager.getFont("Label.font");

    if (bg == null || font == null) {
        final JLabel dummy = new JLabel();
        if (bg == null)
            bg = dummy.getBackground();
        if (font == null)
            font = dummy.getFont();
    }

    l.setBackground(bg);
    ((HTMLEditorKit) l.getEditorKit()).getStyleSheet()
            .addRule("body { font: " + font.getFamily() + " " + font.getSize() + "pt }");

    l.addHyperlinkListener(BrowserSupport.getListener());

    // FIXME: use MigLayout for this!
    // this is necessary to get proper vertical alignment
    final JPanel p = new JPanel(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    p.add(l, c);

    moduleView.add(p, "quickStart");
    modulePanelLayout.show(moduleView, getModuleCount() == 0 ? "quickStart" : "modules");
    moduleControls.add(moduleView, BorderLayout.CENTER);
    moduleControls.setBorder(new TitledBorder(Resources.getString("ModuleManager.recent_modules")));

    add(moduleControls);

    // build server status controls
    final ServerStatusView serverStatusControls = new ServerStatusView(new CgiServerStatus());
    serverStatusControls.setBorder(new TitledBorder(Resources.getString("Chat.server_status")));

    serverStatusView = new ComponentSplitter().splitRight(moduleControls, serverStatusControls, false);
    serverStatusView.revalidate();

    // show the server status controls according to the prefs
    if (serverStatusConfig.booleanValue()) {
        serverStatusView.showComponent();
    }

    setDividerLocation(getPreferredDividerLocation());
    serverStatusView.addPropertyChangeListener("dividerLocation", new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent e) {
            setPreferredDividerLocation((Integer) e.getNewValue());
        }
    });

    final Rectangle r = Info.getScreenBounds(this);
    serverStatusControls.setPreferredSize(new Dimension((int) (r.width / 3.5), 0));

    setSize(3 * r.width / 4, 3 * r.height / 4);

    // Save/load the window position and size in prefs
    final PositionOption option = new PositionOption(PositionOption.key + "ModuleManager", this);
    Prefs.getGlobalPrefs().addOption(option);
}