Example usage for java.awt.event ItemListener ItemListener

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

Introduction

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

Prototype

ItemListener

Source Link

Usage

From source file:shuffle.fwk.service.roster.EditRosterService.java

private JPanel createRosterComponent(Species s) {
    JPanel ret = new JPanel(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 1;/*w ww .  j  a v  a 2s.  co  m*/
    c.gridy = 1;
    c.anchor = GridBagConstraints.CENTER;

    MouseAdapter ma = new PressOrClickMouseAdapter() {

        @Override
        protected void onRight(MouseEvent e) {
            onLeft(e);
        }

        @Override
        protected void onLeft(MouseEvent e) {
            setSelected(s, ret);
            selectedDisplayLabel.repaint();
        }

        @Override
        protected void onEnter() {
            // Do nothing
        }
    };
    SpeciesPaint sp = new SpeciesPaint(s, false, getMegaFilter());
    ImageIcon icon = getUser().getImageManager().getImageFor(sp);
    JLabel iconLabel = new JLabel(icon);
    iconLabel.addMouseListener(ma);
    ret.add(iconLabel, c);
    c.gridy += 1;
    JLabel jLabel = new JLabel(s.getLocalizedName(getMegaFilter()));
    jLabel.setHorizontalTextPosition(SwingConstants.CENTER);
    jLabel.setHorizontalAlignment(SwingConstants.CENTER);
    jLabel.addMouseListener(ma);
    ret.add(jLabel, c);
    JComboBox<Integer> level = new JComboBox<Integer>();
    for (int i = 0; i <= Species.MAX_LEVEL; i++) {
        level.addItem(i);
    }
    Integer thisLevel = getLevelFor(s);
    level.setSelectedItem(thisLevel);
    level.setToolTipText(getString(KEY_POKEMON_LEVEL_TOOLTIP));
    c.gridy += 1; // put the level selector below the icon.
    ret.add(level, c);
    level.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            int index = level.getSelectedIndex();
            myData.setLevelForSpecies(s, index);
            rebuildSelectedLabel();
        }
    });
    return ret;
}

From source file:com.lp.client.frame.component.PanelDokumentenablage.java

private void jbInit() throws Throwable {
    if (LPMain.getInstance().getDesktop()
            .darfAnwenderAufZusatzfunktionZugreifen(MandantFac.ZUSATZFUNKTION_DOKUMENTENABLAGE)) {
        if (!(new HeliumDocPath()).equals(fullDocPath)) {
            bHatDokumentenablage = true;
        }/*from   www .  j a  va2 s.c  o  m*/
    }
    if (bShowExitButton) {
        String[] aWhichButtonIUse = new String[] { PanelBasis.ACTION_NEW, PanelBasis.ACTION_UPDATE,
                PanelBasis.ACTION_SAVE, PanelBasis.ACTION_DISCARD };
        enableToolsPanelButtons(aWhichButtonIUse);
        createAndSaveAndShowButton("/com/lp/client/res/scanner.png", "TWAIN-Import", BUTTON_SCAN, null);
    }
    dropArea.setCenterText(LPMain.getTextRespectUISPr("lp.datei.draganddrop.ablegen"));
    dropArea.setBackground(Color.LIGHT_GRAY);
    dropArea.setSupportFiles(true);
    dropArea.addDropListener(this);
    dropArea.setMinimumSize(new Dimension(200, 100));

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);

    JPanel leftPane = new JPanel();
    JPanel rightPane = new JPanel();

    JLayeredPane rightLayered = new JLayeredPane();
    rightLayered.setLayout(new GridBagLayout());
    rightLayered.add(rightPane, new GridBagConstraints(1, 1, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    // rightLayered.setLayer(rightPane, 0, 1);
    if (bShowExitButton && bHatDokumentenablage)
        rightLayered.add(dropArea, new GridBagConstraints(1, 2, 1, 1, 1, 1, GridBagConstraints.CENTER,
                GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    // rightLayered.setLayer(dropArea, 1, 1);

    rightPane.setLayout(new GridBagLayout());

    tree = new WrapperJTree(treeModel);
    tree.setEditable(false);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);
    tree.setRowHeight(0);

    tree.setCellRenderer(new ToolTipCellRenderer());
    ToolTipManager.sharedInstance().registerComponent(tree);

    tree.addTreeSelectionListener(this);

    refresh();

    personalDto = DelegateFactory.getInstance().getPersonalDelegate()
            .personalFindByPrimaryKey(LPMain.getTheClient().getIDPersonal());
    dokumentbelegartDto = DelegateFactory.getInstance().getJCRDocDelegate()
            .dokumentbelegartfindbyMandant(LPMain.getTheClient().getMandant());
    for (int i = 0; i < dokumentbelegartDto.length; i++) {
        if (!JCRDocFac.DEFAULT_ARCHIV_BELEGART.equals(dokumentbelegartDto[i].getCNr()))
            wcbBelegart.addItem(dokumentbelegartDto[i].getCNr());
    }
    dokumentgruppierungDto = DelegateFactory.getInstance().getJCRDocDelegate()
            .dokumentgruppierungfindbyMandant(LPMain.getTheClient().getMandant());
    for (int i = 0; i < dokumentgruppierungDto.length; i++) {
        if (!JCRDocFac.DEFAULT_ARCHIV_GRUPPE.equals(dokumentgruppierungDto[i].getCNr())
                || !JCRDocFac.DEFAULT_KOPIE_GRUPPE.equals(dokumentgruppierungDto[i].getCNr())
                || !JCRDocFac.DEFAULT_VERSANDAUFTRAG_GRUPPE.equals(dokumentgruppierungDto[i].getCNr())) {
            wcbGruppierung.addItem(dokumentgruppierungDto[i].getCNr());
        }
    }

    // Listen for when the selection changes.
    tree.addTreeExpansionListener(this);

    wcbVersteckteAnzeigen.setEnabled(true);
    wcbVersteckteAnzeigen.addActionListener(actionListener);

    wtfSuche.setEditable(true);
    wbuSuche.setEnabled(true);
    wbuSuche.addActionListener(actionListener);
    wbuPartner = new WrapperButton();

    wbuPartner.setText(LPMain.getTextRespectUISPr("button.partner"));
    wbuPartner.setToolTipText(LPMain.getTextRespectUISPr("button.partner.tooltip"));

    wbuPartner.setActionCommand(ACTION_SPECIAL_PARTNER);
    wbuPartner.addActionListener(this);
    wbuChooseDoc.setActionCommand(ACTION_SPECIAL_CHOOSE);
    wbuChooseDoc.addActionListener(this);
    wbuShowDoc.setActionCommand(ACTION_SPECIAL_SHOW);
    wbuShowDoc.addActionListener(this);
    wbuSaveDoc.setActionCommand(ACTION_SPECIAL_SAVE);
    wbuSaveDoc.addActionListener(this);

    wtfPartner = new WrapperTextField();
    wtfPartner.setColumnsMax(Facade.MAX_UNBESCHRAENKT);
    wtfPartner.setActivatable(false);
    wtfAnleger.setActivatable(false);
    wdfZeitpunkt.setActivatable(false);
    wtfBelegnummer.setActivatable(false);
    wtfTable.setActivatable(false);
    wtfRow.setActivatable(false);
    wtfFilename.setActivatable(false);
    wtfFilename.setColumnsMax(100);
    wtfMIME.setActivatable(false);
    wcbVersteckt.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            wtfSchlagworte.setMandatoryField(!wcbVersteckt.isSelected());
        }
    });

    if (bHatStufe0) {
        wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_NONE);
    }
    if (bHatStufe1) {
        wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_LOW);
    }
    if (bHatStufe2) {
        wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_MEDIUM);
    }
    if (bHatStufe3) {
        wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_HIGH);
    }
    if (bHatStufe99) {
        wcbSicherheitsstufe.addItem(JCRDocFac.SECURITY_ARCHIV);
    }

    wtfTable.setMandatoryField(true);
    wtfName.setMandatoryField(true);
    wtfName.setColumnsMax(200);
    wtfBelegnummer.setMandatoryField(true);
    wtfRow.setMandatoryField(true);
    wtfFilename.setMandatoryField(true);
    wtfMIME.setMandatoryField(true);
    wtfAnleger.setMandatoryField(true);
    wtfSchlagworte.setMandatoryField(true);
    wtfSchlagworte.setColumnsMax(300);
    wdfZeitpunkt.setMandatoryField(true);
    wtfPartner.setMandatoryField(true);

    treeView = new JScrollPane(tree);
    treeView.setMinimumSize(new Dimension(200, 10));
    treeView.setPreferredSize(new Dimension(200, 10));

    iZeile = 0;
    if (!bShowExitButton) {
        jpaWorkingOn.add(wtfSuche, new GridBagConstraints(0, iZeile, 1, 1, 0.2, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
        jpaWorkingOn.add(wbuSuche, new GridBagConstraints(1, iZeile, 1, 1, 0.1, 0.0, GridBagConstraints.WEST,
                GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
        iZeile++;
    }
    jpaWorkingOn.add(wcbVersteckteAnzeigen, new GridBagConstraints(0, iZeile, 1, 1, 1, 0.0,
            GridBagConstraints.EAST, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    iZeile++;
    leftPane.add(treeView);

    jpaWorkingOn.add(splitPane, new GridBagConstraints(0, iZeile, 3, 1, 1.0, 1.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    iZeile = 0;
    rightPane.add(wlaName, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.WEST,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    rightPane.add(wtfName, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    rightPane.add(wlaTable, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wtfTable, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    iZeile++;
    rightPane.add(wlaSchlagworte, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wtfSchlagworte, new GridBagConstraints(1, iZeile, 6, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    iZeile++;
    rightPane.add(wlaZeitpunkt, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wdfZeitpunkt, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wlaSicherheitsstufe, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wcbSicherheitsstufe, new GridBagConstraints(5, iZeile, 1, 1, 1.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wcbVersteckt, new GridBagConstraints(6, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    iZeile++;
    rightPane.add(wlaBelegnummer, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wtfBelegnummer, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wlaRow, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wtfRow, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    iZeile++;
    rightPane.add(wlaFilename, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wtfFilename, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wlaMIME, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wtfMIME, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    iZeile++;
    rightPane.add(wlaBelegart, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wcbBelegart, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wlaGruppierung, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wcbGruppierung, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    iZeile++;
    rightPane.add(wbuPartner, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wtfPartner, new GridBagConstraints(1, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wlaAnleger, new GridBagConstraints(4, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wtfAnleger, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    iZeile++;

    rightPane.add(wbuChooseDoc, new GridBagConstraints(0, iZeile, 3, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));

    rightPane.add(wbuShowDoc, new GridBagConstraints(3, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    rightPane.add(wbuSaveDoc, new GridBagConstraints(5, iZeile, 2, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    iZeile++;
    rightPane.add(wlaVorschau, new GridBagConstraints(0, iZeile, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    iZeile++;
    rightPane.add(wmcMedia, new GridBagConstraints(0, iZeile, 7, 4, 1.0, 0.5, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(2, 2, 2, 2), 0, 0));
    splitPane.setLeftComponent(treeView);
    splitPane.setRightComponent(rightLayered);
}

From source file:org.geopublishing.atlasStyler.swing.PolygonSymbolEditGUI.java

/**
 * This method initializes jComboBox1//from  w w  w .ja  v a2 s. c  om
 * 
 * @return javax.swing.JComboBox
 */
private JComboBox getJComboBoxStrokeWidth() {
    if (jComboBoxStrokeWidth == null) {

        jComboBoxStrokeWidth = new JComboBox();

        jComboBoxStrokeWidth.setModel(new DefaultComboBoxModel(WIDTH_VALUES));
        jComboBoxStrokeWidth.setRenderer(WIDTH_VALUES_RENDERER);

        // TODO .. might not be in list...
        Stroke s = symbolizer.getStroke();
        if (s != null)
            if (s.getWidth() == null) {
                // Having a Stroke but no StrokeWidth doesn't make sense.
                s.setWidth(ASUtil.ff2.literal("1."));
            } else {

                ASUtil.selectOrInsert(jComboBoxStrokeWidth, s.getWidth());
            }
        else {
            jComboBoxStrokeWidth.setEnabled(false);
        }

        jComboBoxStrokeWidth.addItemListener(new ItemListener() {

            @Override
            public void itemStateChanged(ItemEvent e) {
                if (e.getStateChange() == ItemEvent.SELECTED) {

                    symbolizer.getStroke().setWidth(ASUtil.ff2.literal(e.getItem()));

                    PolygonSymbolEditGUI.this.firePropertyChange(PROPERTY_UPDATED, null, null);

                }
            }

        });

        SwingUtil.addMouseWheelForCombobox(jComboBoxStrokeWidth);
    }
    return jComboBoxStrokeWidth;
}

From source file:com.peterbochs.sourceleveldebugger.SourceLevelDebugger3.java

private void initGUI() {
    try {//from w  w  w  .j  a  v a  2s  .c  o  m
        this.setPreferredSize(new java.awt.Dimension(975, 563));
        {
            jMainSplitPane = new JSplitPane();
            this.add(getJErrorLabel(), "errorLabel");
            this.add(jMainSplitPane, "MAIN");
            jMainSplitPane.setDividerLocation(200);
            {
                jPanel4 = new JPanel();
                jMainSplitPane.add(jPanel4, JSplitPane.RIGHT);
                BorderLayout jPanel4Layout = new BorderLayout();
                jPanel4.setLayout(jPanel4Layout);
                {
                    jSplitPane3 = new JSplitPane();
                    jPanel4.add(jSplitPane3, BorderLayout.CENTER);
                    jSplitPane3.setOrientation(JSplitPane.VERTICAL_SPLIT);
                    jSplitPane3.setDividerLocation(500);
                    {
                        jPanel6 = new JPanel();
                        jSplitPane3.add(jPanel6, JSplitPane.TOP);
                        jSplitPane3.add(getJInfoTabbedPane(), JSplitPane.BOTTOM);
                        BorderLayout jPanel6Layout = new BorderLayout();
                        jPanel6.setLayout(jPanel6Layout);
                        {
                            jMainTabbedPane = new JMaximizableTabbedPane();
                            jPanel6.add(jMainTabbedPane, BorderLayout.CENTER);
                            {
                                jASMPanel = new JPanel();
                                jMainTabbedPane.addTab(MyLanguage.getString("ASM/C"), null, jASMPanel, null);
                                jMainTabbedPane.addTab("Dwarf", null, getJDwarfPanel(), null);
                                jMainTabbedPane.addTab("Code base", null, getCodeBasePanel(), null);
                                jMainTabbedPane.addTab("Call Graph", null, getCallGraphPanel(), null);
                                BorderLayout jASMPanelLayout = new BorderLayout();
                                jASMPanel.setLayout(jASMPanelLayout);
                                {
                                    instructionTableScrollPane = new JScrollPane();
                                    instructionTableScrollPane.getVerticalScrollBar()
                                            .addAdjustmentListener(new AdjustmentListener() {
                                                boolean isRunning;

                                                public void adjustmentValueChanged(AdjustmentEvent evt) {
                                                    /*   JScrollBar vbar = (JScrollBar) evt.getSource();
                                                            
                                                       if (evt.getValueIsAdjusting()) {
                                                          return;
                                                       }
                                                       if ((vbar.getValue() + vbar.getVisibleAmount()) == vbar.getMaximum()) {
                                                          if (!isRunning) {
                                                             try {
                                                                isRunning = true;
                                                                final CardLayout cl = (CardLayout) (peterBochsDebugger.jMainPanel.getLayout());
                                                                cl.show(peterBochsDebugger.jMainPanel, "Running Label");
                                                                //                                             new Thread("update instruction thread") {
                                                                //                                                public void run() {
                                                                //                                                   long address = Long.parseLong(instructionTable.getValueAt(instructionTable.getRowCount() - 1, 1).toString()
                                                                //                                                         .substring(2), 16);
                                                                //                                                   peterBochsDebugger.updateInstruction(address, true);
                                                                //                                                   peterBochsDebugger.updateBreakpointTableColor();
                                                                ////                                                   cl.show(peterBochsDebugger.jMainPanel, peterBochsDebugger.currentPanel);
                                                                //
                                                                //                                                   isRunning = false;
                                                                //                                                }
                                                                //                                             }.start();
                                                            
                                                             } catch (Exception ex) {
                                                             }
                                                          }
                                                            
                                                       }*/
                                                }

                                            });
                                    jASMPanel.add(instructionTableScrollPane, BorderLayout.CENTER);
                                    {
                                        instructionTable = new JTable();
                                        instructionTableScrollPane.setViewportView(instructionTable);
                                        instructionTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
                                        instructionTable
                                                .setModel(PeterBochsDebugger.instructionTable.getModel());
                                        instructionTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
                                        instructionTable.getTableHeader().setReorderingAllowed(false);
                                        instructionTable.getColumnModel().getColumn(0).setMaxWidth(20);
                                        instructionTable.getColumnModel().getColumn(1).setPreferredWidth(40);
                                        instructionTable.getColumnModel().getColumn(2).setPreferredWidth(200);
                                        instructionTable.getColumnModel().getColumn(3).setPreferredWidth(40);
                                        instructionTable.setShowGrid(false);
                                        instructionTable.setDefaultRenderer(String.class,
                                                new InstructionTableCellRenderer());
                                        instructionTable.addMouseListener(new MouseAdapter() {
                                            public void mouseClicked(MouseEvent evt) {
                                                instructionTableMouseClicked(evt);
                                            }
                                        });
                                    }
                                }
                                {
                                    jInstructionControlPanel = new JPanel();
                                    jASMPanel.add(jInstructionControlPanel, BorderLayout.NORTH);
                                    {
                                        jInstructionComboBox = new JComboBox();
                                        jInstructionControlPanel.add(jInstructionComboBox);
                                        jInstructionComboBox.setEditable(true);
                                        jInstructionComboBox.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                jInstructionComboBoxActionPerformed(evt);
                                            }
                                        });
                                    }
                                    {
                                        disassembleButton = new JButton();
                                        jInstructionControlPanel.add(disassembleButton);
                                        disassembleButton.setText(MyLanguage.getString("Disassemble"));
                                        disassembleButton.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                disassembleButtonActionPerformed(evt);
                                            }
                                        });
                                    }
                                    {
                                        disassembleCSEIPButton = new JButton();
                                        jInstructionControlPanel.add(disassembleCSEIPButton);
                                        disassembleCSEIPButton
                                                .setText(MyLanguage.getString("Disassemble") + " cs:eip");
                                        disassembleCSEIPButton.setEnabled(true);
                                        disassembleCSEIPButton.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                disassembleCSEIPButtonActionPerformed(evt);
                                            }
                                        });
                                    }
                                    {
                                        jInstructionUpTenButton = new JButton();
                                        jInstructionControlPanel.add(jInstructionUpTenButton);
                                        jInstructionUpTenButton
                                                .setIcon(new ImageIcon(getClass().getClassLoader().getResource(
                                                        "com/peterbochs/icons/famfam_icons/arrow_up10.png")));
                                        jInstructionUpTenButton.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                jInstructionUpTenButtonActionPerformed(evt);
                                            }
                                        });
                                    }
                                    {
                                        jInstructionUpButton = new JButton();
                                        jInstructionControlPanel.add(jInstructionUpButton);
                                        jInstructionUpButton
                                                .setIcon(new ImageIcon(getClass().getClassLoader().getResource(
                                                        "com/peterbochs/icons/famfam_icons/arrow_up1.png")));
                                        jInstructionUpButton.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                jInstructionUpButtonActionPerformed(evt);
                                            }
                                        });
                                    }
                                    {
                                        jInstructionDownButton = new JButton();
                                        jInstructionControlPanel.add(jInstructionDownButton);
                                        jInstructionDownButton
                                                .setIcon(new ImageIcon(getClass().getClassLoader().getResource(
                                                        "com/peterbochs/icons/famfam_icons/arrow_down.png")));
                                        jInstructionDownButton.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                jInstructionDownButtonActionPerformed(evt);
                                            }
                                        });
                                    }
                                    {
                                        jDiskButton = new JButton();
                                        jInstructionControlPanel.add(jDiskButton);
                                        jDiskButton.setIcon(new ImageIcon(getClass().getClassLoader()
                                                .getResource("com/peterbochs/icons/famfam_icons/disk.png")));
                                        jDiskButton.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                jButton3ActionPerformed(evt);
                                            }
                                        });
                                    }
                                    {
                                        jExcelButton = new JButton();
                                        jInstructionControlPanel.add(jExcelButton);
                                        jInstructionControlPanel.add(getJSearchTextField());
                                        jExcelButton.setIcon(new ImageIcon(getClass().getClassLoader()
                                                .getResource("com/peterbochs/icons/famfam_icons/excel.gif")));
                                        {
                                            btnSearch = new JButton("Search");
                                            jInstructionControlPanel.add(btnSearch);
                                            btnSearch.addActionListener(new ActionListener() {
                                                public void actionPerformed(ActionEvent evt) {
                                                    btnSearchActionPerformed(evt);
                                                }
                                            });
                                        }
                                        {
                                            onOffButton = new OnOffButton();
                                            onOffButton.setSelected(true);
                                            onOffButton.addItemListener(new ItemListener() {
                                                public void itemStateChanged(ItemEvent e) {
                                                    InstructionTableModel model = (InstructionTableModel) PeterBochsDebugger.instructionTable
                                                            .getModel();
                                                    if (e.getStateChange() == ItemEvent.SELECTED) {
                                                        model.showAsmLevel = true;
                                                    } else {
                                                        model.showAsmLevel = false;
                                                    }
                                                    model.fireTableDataChanged();
                                                }
                                            });
                                            onOffButton.setPreferredSize(new Dimension(53, 18));
                                            jInstructionControlPanel.add(onOffButton);
                                        }
                                        jExcelButton.addActionListener(new ActionListener() {
                                            public void actionPerformed(ActionEvent evt) {
                                                jButton12ActionPerformed(evt);
                                            }
                                        });
                                    }
                                }
                            }
                        }
                    }
                }
            }
            {
                jPanel1 = new JPanel();
                jMainSplitPane.add(jPanel1, JSplitPane.LEFT);
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                {
                    jTabbedPane1 = new JMaximizableTabbedPane();
                    jPanel1.add(jTabbedPane1, BorderLayout.CENTER);
                    jTabbedPane1.addChangeListener(new ChangeListener() {
                        public void stateChanged(ChangeEvent evt) {
                            jTabbedPane1StateChanged(evt);
                        }
                    });
                    {
                        jPanel3 = new JPanel();
                        BorderLayout jPanel3Layout = new BorderLayout();
                        jPanel3.setLayout(jPanel3Layout);
                        jTabbedPane1.addTab("Symbol", null, getSymbolTablePanel(), null);
                        jTabbedPane1.addTab(MyLanguage.getString("Project"), null, jPanel3, null);
                        {
                            jScrollPane1 = new JScrollPane();
                            jPanel3.add(jScrollPane1, BorderLayout.CENTER);
                            jPanel3.add(getJProjectToolBar(), BorderLayout.NORTH);
                            {
                                projectTree = new JTree();
                                jScrollPane1.setViewportView(projectTree);
                                projectTree.setModel(projectFilterTreeModel);
                                projectTree.setShowsRootHandles(true);
                                projectTree.setCellRenderer(new ProjectTreeRenderer());
                                projectTree.addMouseListener(new MouseAdapter() {
                                    public void mouseClicked(MouseEvent evt) {
                                        projectTreeMouseClicked(evt);
                                    }
                                });
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner Evaluation license - Sasha aaa
    contentPanel = new JPanel();
    label16 = new JLabel();
    label17 = new JLabel();
    label18 = new JLabel();
    label1 = new JLabel();
    cbFilterType = new JComboBox();
    label5 = new JLabel();
    tbAParam = new JTextField();
    label2 = new JLabel();
    cbFilterForm = new JComboBox();
    label6 = new JLabel();
    tbBParam = new JTextField();
    label3 = new JLabel();
    tbName = new JTextField();
    label7 = new JLabel();
    tbCParam = new JTextField();
    label4 = new JLabel();
    panel2 = new JPanel();
    tbImage = new JTextField();
    btnUploadImage = new JButton();
    label8 = new JLabel();
    tbDParam = new JTextField();
    label19 = new JLabel();
    cbFilterStatus = new JComboBox();
    label9 = new JLabel();
    tbEParam = new JTextField();
    label15 = new JLabel();
    scrollPane1 = new JScrollPane();
    tbAdditionalInfo = new JTextArea();
    label10 = new JLabel();
    tbFParam = new JTextField();
    label11 = new JLabel();
    tbGParam = new JTextField();
    label12 = new JLabel();
    tbHParam = new JTextField();
    label13 = new JLabel();
    tbPbParam = new JTextField();
    label14 = new JLabel();
    tbNrParam = new JTextField();
    panel1 = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();
    CellConstraints cc = new CellConstraints();

    //======== this ========
    setModal(true);/*w  w  w. j  a va  2s. c  om*/
    setTitle("\u0424\u0438\u043b\u044c\u0442\u0440");
    Container contentPane = getContentPane();
    contentPane.setLayout(new FormLayout("default:grow", "fill:default:grow"));

    //======== contentPanel ========
    {

        // JFormDesigner evaluation mark
        contentPanel.setBorder(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),
                contentPanel.getBorder()));
        contentPanel.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent e) {
                if ("border".equals(e.getPropertyName()))
                    throw new RuntimeException();
            }
        });

        contentPanel.setLayout(new FormLayout(
                "$rgap, default, $lcgap, default:grow, $lcgap, right:20dlu, $lcgap, default:grow, $rgap",
                "13*(default, $lgap), fill:default:grow, $lgap, default"));

        //---- label16 ----
        label16.setText(
                "\u0412\u0432\u0435\u0434\u0438\u0442\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0444\u0438\u043b\u044c\u0442\u0440\u0435. ");
        contentPanel.add(label16, cc.xywh(2, 1, 7, 1));

        //---- label17 ----
        label17.setText(
                "\u041f\u043e\u043b\u044f, \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u0435 \u0437\u0432\u0435\u0437\u0434\u043e\u0447\u043a\u0430\u043c\u0438, \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f.");
        contentPanel.add(label17, cc.xywh(2, 3, 7, 1));

        //---- label18 ----
        label18.setText(
                "\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0438\u043f \u0438\u043b\u0438 \u0444\u043e\u0440\u043c\u0443 \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \"\u0418\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b\"->\"\u0422\u0438\u043f\u044b \u0438 \u0444\u043e\u0440\u043c\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\"");
        label18.setForeground(Color.blue);
        contentPanel.add(label18, cc.xywh(2, 5, 7, 1));

        //---- label1 ----
        label1.setText("\u0422\u0438\u043f*");
        contentPanel.add(label1, cc.xy(2, 7));
        contentPanel.add(cbFilterType, cc.xy(4, 7));

        //---- label5 ----
        label5.setText("A");
        contentPanel.add(label5, cc.xy(6, 7));
        contentPanel.add(tbAParam, cc.xy(8, 7));

        //---- label2 ----
        label2.setText("\u0424\u043e\u0440\u043c\u0430*");
        contentPanel.add(label2, cc.xy(2, 9));
        contentPanel.add(cbFilterForm, cc.xy(4, 9));

        //---- label6 ----
        label6.setText("B");
        contentPanel.add(label6, cc.xy(6, 9));
        contentPanel.add(tbBParam, cc.xy(8, 9));

        //---- label3 ----
        label3.setText("\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435*");
        contentPanel.add(label3, cc.xy(2, 11));

        //---- tbName ----
        tbName.addKeyListener(new KeyAdapter() {
            @Override
            public void keyTyped(KeyEvent e) {
                tbNameKeyTyped(e);
            }
        });
        tbName.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                tbNameFocusGained(e);
            }

            @Override
            public void focusLost(FocusEvent e) {
                tbNameFocusGained(e);
            }
        });
        contentPanel.add(tbName, cc.xy(4, 11));

        //---- label7 ----
        label7.setText("C");
        contentPanel.add(label7, cc.xy(6, 11));
        contentPanel.add(tbCParam, cc.xy(8, 11));

        //---- label4 ----
        label4.setText("\u0418\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435");
        contentPanel.add(label4, cc.xy(2, 13));

        //======== panel2 ========
        {
            panel2.setLayout(new FormLayout("default:grow, $lcgap, default", "default"));
            panel2.add(tbImage, cc.xy(1, 1));

            //---- btnUploadImage ----
            btnUploadImage.setText("...");
            btnUploadImage.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    btnUploadImageActionPerformed();
                }
            });
            panel2.add(btnUploadImage, cc.xy(3, 1));
        }
        contentPanel.add(panel2, cc.xy(4, 13));

        //---- label8 ----
        label8.setText("D");
        contentPanel.add(label8, cc.xy(6, 13));
        contentPanel.add(tbDParam, cc.xy(8, 13));

        //---- label19 ----
        label19.setText("\u0421\u0442\u0430\u0442\u0443\u0441");
        contentPanel.add(label19, cc.xy(2, 15));

        //---- cbFilterStatus ----
        cbFilterStatus.setModel(new DefaultComboBoxModel(new String[] {
                "\u0412 \u041f\u0420\u041e\u0418\u0417\u0412\u041e\u0414\u0421\u0422\u0412\u0415",
                "\u041f\u041e\u0421\u0422\u0410\u0412\u041b\u042f\u0415\u0422\u0421\u042f",
                "\u041d\u0415 \u041f\u041e\u0421\u0422\u0410\u0412\u041b\u042f\u0415\u0422\u0421\u042f" }));
        contentPanel.add(cbFilterStatus, cc.xy(4, 15));

        //---- label9 ----
        label9.setText("E");
        contentPanel.add(label9, cc.xy(6, 15));
        contentPanel.add(tbEParam, cc.xy(8, 15));

        //---- label15 ----
        label15.setText("\u0414\u043e\u043f. \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f");
        contentPanel.add(label15, cc.xy(2, 17));

        //======== scrollPane1 ========
        {
            scrollPane1.setViewportView(tbAdditionalInfo);
        }
        contentPanel.add(scrollPane1, cc.xywh(4, 17, 1, 11));

        //---- label10 ----
        label10.setText("F");
        contentPanel.add(label10, cc.xy(6, 17));
        contentPanel.add(tbFParam, cc.xy(8, 17));

        //---- label11 ----
        label11.setText("G");
        contentPanel.add(label11, cc.xy(6, 19));
        contentPanel.add(tbGParam, cc.xy(8, 19));

        //---- label12 ----
        label12.setText("H");
        contentPanel.add(label12, cc.xy(6, 21));
        contentPanel.add(tbHParam, cc.xy(8, 21));

        //---- label13 ----
        label13.setText("PB");
        contentPanel.add(label13, cc.xy(6, 23));
        contentPanel.add(tbPbParam, cc.xy(8, 23));

        //---- label14 ----
        label14.setText("NR");
        contentPanel.add(label14, cc.xy(6, 25));
        contentPanel.add(tbNrParam, cc.xy(8, 25));

        //======== panel1 ========
        {
            panel1.setLayout(new FormLayout("default:grow, 2*($lcgap, $button)", "default"));

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

            //---- cancelButton ----
            cancelButton.setText("\u041e\u0442\u043c\u0435\u043d\u0430");
            cancelButton.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    cancelButtonActionPerformed(e);
                }
            });
            panel1.add(cancelButton, cc.xy(5, 1));
        }
        contentPanel.add(panel1, cc.xywh(2, 29, 7, 1));
    }
    contentPane.add(contentPanel, cc.xy(1, 1));
    pack();
    setLocationRelativeTo(getOwner());
    // JFormDesigner - End of component initialization  //GEN-END:initComponents

    cbFilterType.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                SelectItem selectItem = (SelectItem) e.getItem();
                FilterType ft = carsService.getFilterTypeByCode(selectItem.getId());
                reReadFilterForms(ft.getCode());

            }
        }
    });

    cbFilterForm.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                adjustParameters();
                adjustButtonsEnabled();
            }
        }
    });
}

From source file:com.rapidminer.gui.properties.RegexpPropertyDialog.java

public RegexpPropertyDialog(final Collection<String> items, String predefinedRegexp, String description) {
    super(ApplicationFrame.getApplicationFrame(), "parameter.regexp", ModalityType.APPLICATION_MODAL,
            new Object[] {});
    this.items = items;
    this.supportsItems = items != null;
    this.infoText = "<html>" + I18N.getMessage(I18N.getGUIBundle(), getKey() + ".title") + ": <br/>"
            + description + "</html>";
    Dimension size = new Dimension(420, 500);
    this.setMinimumSize(size);
    this.setPreferredSize(size);

    JPanel panel = new JPanel(createGridLayout(1, supportsItems ? 2 : 1));

    // create regexp text field
    regexpTextField = new JTextField(predefinedRegexp);
    regexpTextField.setToolTipText(//from  ww w. ja v  a  2  s.  c  o  m
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.tip"));
    regexpTextField.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

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

        @Override
        public void keyTyped(KeyEvent e) {
        }

    });
    regexpTextField.requestFocus();

    // create replacement text field
    replacementTextField = new JTextField();
    replacementTextField.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.tip"));
    replacementTextField.addKeyListener(new KeyListener() {

        @Override
        public void keyPressed(KeyEvent e) {
        }

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

        @Override
        public void keyTyped(KeyEvent e) {
        }

    });

    // create inline search documents
    inlineSearchDocument = new RegexpSearchStyledDocument();
    inlineReplaceDocument = new RegexpReplaceStyledDocument();

    // create search results list
    DefaultListCellRenderer resultCellRenderer = new DefaultListCellRenderer() {

        private static final long serialVersionUID = 1L;

        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
                boolean cellHasFocus) {
            super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            setBackground(list.getBackground());
            setForeground(list.getForeground());
            setBorder(getNoFocusBorder());
            return this;
        }

        private Border getNoFocusBorder() {
            Border border = BorderFactory.createMatteBorder(0, 0, 1, 0, Color.gray);
            return border;
        }
    };

    JList<RegExpResult> regexpFindingsList = new JList<RegExpResult>(resultsListModel);
    regexpFindingsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    regexpFindingsList.setLayoutOrientation(JList.VERTICAL);
    regexpFindingsList.setCellRenderer(resultCellRenderer);

    // regexp panel on left side of dialog
    JPanel regexpPanel = new JPanel(new GridBagLayout());
    regexpPanel.setBorder(createTitledBorder(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.regular_expression.border")));
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(4, 4, 4, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    regexpPanel.add(regexpTextField, c);

    // make shortcut button
    final Action nullAction = new DefaultAction();
    PlainArrowDropDownButton autoWireDropDownButton = PlainArrowDropDownButton.makeDropDownButton(nullAction);

    for (String[] popupItem : (String[][]) ArrayUtils.addAll(regexpConstructs, regexpShortcuts)) {
        String shortcut = popupItem[0].length() > 14 ? popupItem[0].substring(0, 14) + "..." : popupItem[0];
        autoWireDropDownButton
                .add(new InsertionAction("<html><table border=0 cellpadding=0 cellspacing=0><tr><td width=100>"
                        + shortcut + "</td><td>" + popupItem[1] + "</td></tr></table></html>", popupItem[0]));
    }
    c.insets = new Insets(4, 0, 4, 0);
    c.gridx = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    regexpPanel.add(autoWireDropDownButton.getDropDownArrowButton(), c);

    // make delete button
    c.insets = new Insets(4, 0, 4, 4);
    c.gridx = 2;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    JButton clearRegexpTextFieldButton = new JButton(SwingTools.createIcon("16/delete2.png"));
    clearRegexpTextFieldButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            regexpTextField.setText("");
            fireRegularExpressionUpdated();
            regexpTextField.requestFocusInWindow();
        }
    });

    regexpPanel.add(clearRegexpTextFieldButton, c);

    errorMessage = new JLabel(NO_ERROR_MESSAGE, NO_ERROR_ICON, SwingConstants.LEFT);
    errorMessage.setFocusable(false);
    c.insets = new Insets(4, 8, 4, 4);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    regexpPanel.add(errorMessage, c);

    // create replacement panel
    JPanel replacementPanel = new JPanel(new GridBagLayout());
    replacementPanel.setBorder(createTitledBorder(
            I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.replacement.border")));

    JPanel testerPanel = new JPanel(new GridBagLayout());

    c.insets = new Insets(4, 4, 4, 0);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    replacementPanel.add(replacementTextField, c);

    // create inline search panel
    JPanel inlineSearchPanel = new JPanel(new GridBagLayout());

    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    inlineSearchPanel.add(
            new JLabel(
                    I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.search")),
            c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    inlineSearchPanel.add(new JScrollPane(new JTextPane(inlineSearchDocument)), c);

    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    inlineSearchPanel.add(
            new JLabel(
                    I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.inline_search.replaced")),
            c);

    c.insets = new Insets(0, 0, 0, 0);
    c.gridx = 0;
    c.gridy = 3;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    JTextPane replaceTextPane = new JTextPane(inlineReplaceDocument);
    replaceTextPane.setEditable(false);
    inlineSearchPanel.add(new JScrollPane(replaceTextPane), c);

    // create regexp options panel
    ItemListener defaultOptionListener = new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            fireRegexpOptionsChanged();
        }
    };

    cbCaseInsensitive = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive"));
    cbCaseInsensitive.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.case_insensitive.tip"));
    cbCaseInsensitive.addItemListener(defaultOptionListener);

    cbMultiline = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode"));
    cbMultiline.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.multiline_mode.tip"));
    cbMultiline.addItemListener(defaultOptionListener);

    cbDotall = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode"));
    cbDotall.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.dotall_mode.tip"));
    cbDotall.addItemListener(defaultOptionListener);

    cbUnicodeCase = new JCheckBox(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case"));
    cbUnicodeCase.setToolTipText(I18N.getMessage(I18N.getGUIBundle(),
            "gui.dialog.parameter.regexp.regular_expression.regexp_options.unicode_case.tip"));
    cbUnicodeCase.addItemListener(defaultOptionListener);

    JPanel regexpOptionsPanelWrapper = new JPanel(new BorderLayout());
    JPanel regexpOptionsPanel = new JPanel(new GridBagLayout());
    regexpOptionsPanelWrapper.add(regexpOptionsPanel, BorderLayout.NORTH);

    c.insets = new Insets(12, 4, 0, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    regexpOptionsPanel.add(cbMultiline, c);
    c.insets = new Insets(8, 4, 0, 4);
    c.gridy = 1;
    regexpOptionsPanel.add(cbCaseInsensitive, c);
    c.gridy = 2;
    regexpOptionsPanel.add(cbUnicodeCase, c);
    c.gridy = 3;
    regexpOptionsPanel.add(cbDotall, c);

    // create tabbed panel
    c.insets = new Insets(8, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    testExp = new JTabbedPane();
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.inline_search.title"),
            new JScrollPane(inlineSearchPanel));
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.result_list.title"),
            new JScrollPane(regexpFindingsList));
    testExp.add(
            I18N.getMessage(I18N.getGUIBundle(),
                    "gui.dialog.parameter.regexp.regular_expression.regexp_options.title"),
            regexpOptionsPanelWrapper);
    testerPanel.add(testExp, c);

    JPanel groupPanel = new JPanel(new GridBagLayout());
    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    groupPanel.add(regexpPanel, c);

    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    groupPanel.add(replacementPanel, c);

    c.insets = new Insets(4, 4, 4, 4);
    c.gridx = 0;
    c.gridy = 2;
    c.weightx = 1;
    c.weighty = 1;
    c.fill = GridBagConstraints.BOTH;
    groupPanel.add(testerPanel, c);

    panel.add(groupPanel, 1, 0);

    if (supportsItems) {
        // item shortcuts list
        itemShortcutsList = new JList<String>(items.toArray(new String[items.size()]));
        itemShortcutsList.setToolTipText(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.tip"));
        itemShortcutsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        itemShortcutsList.addMouseListener(new MouseListener() {

            @Override
            public void mouseClicked(MouseEvent e) {
                if (e.getClickCount() == 2) {
                    String text = regexpTextField.getText();
                    int cursorPosition = regexpTextField.getCaretPosition();
                    int index = itemShortcutsList.getSelectedIndex();
                    if (index > -1 && index < itemShortcutsList.getModel().getSize()) {
                        String insertionString = itemShortcutsList.getModel().getElementAt(index).toString();
                        String newText = text.substring(0, cursorPosition) + insertionString
                                + (cursorPosition < text.length() ? text.substring(cursorPosition) : "");
                        regexpTextField.setText(newText);
                        regexpTextField.setCaretPosition(cursorPosition + insertionString.length());
                        regexpTextField.requestFocus();
                        fireRegularExpressionUpdated();
                    }
                }
            }

            @Override
            public void mouseEntered(MouseEvent e) {
            }

            @Override
            public void mouseExited(MouseEvent e) {
            }

            @Override
            public void mousePressed(MouseEvent e) {
            }

            @Override
            public void mouseReleased(MouseEvent e) {
            }
        });
        JScrollPane itemShortcutsPane = new JScrollPane(itemShortcutsList);
        itemShortcutsPane.setBorder(createTitledBorder(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.item_shortcuts.border")));

        // matched items list
        matchedItemsListModel = new DefaultListModel<String>();
        JList<String> matchedItemsList = new JList<String>(matchedItemsListModel);
        matchedItemsList.setToolTipText(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.tip"));
        // add custom cell renderer to disallow selections
        matchedItemsList.setCellRenderer(new DefaultListCellRenderer() {

            private static final long serialVersionUID = -5795848004756768378L;

            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index,
                    boolean isSelected, boolean cellHasFocus) {
                return super.getListCellRendererComponent(list, value, index, false, false);
            }
        });
        JScrollPane matchedItemsPanel = new JScrollPane(matchedItemsList);
        matchedItemsPanel.setBorder(createTitledBorder(
                I18N.getMessage(I18N.getGUIBundle(), "gui.dialog.parameter.regexp.matched_items.border")));

        // item panel on right side of dialog
        JPanel itemPanel = new JPanel(createGridLayout(1, 2));
        itemPanel.add(itemShortcutsPane, 0, 0);
        itemPanel.add(matchedItemsPanel, 0, 1);

        panel.add(itemPanel, 0, 1);
    }

    okButton = makeOkButton("regexp_property_dialog_apply");
    fireRegularExpressionUpdated();

    layoutDefault(panel, supportsItems ? NORMAL : NARROW, okButton, makeCancelButton());
}

From source file:org.tellervo.desktop.tridasv2.ui.ComponentViewerOld.java

private void setupTreeGUI() {

    treeLayout = new TreeLayout<String, Integer>(graph);
    radialLayout = new BalloonLayout<String, Integer>(graph);

    radialLayout.setSize(new Dimension(600, 600));
    vv = new VisualizationViewer<String, Integer>(treeLayout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.E);
    rings = new Rings(radialLayout);

    Container content = tree2Panel;
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);/*w  w w.ja va 2s  .co  m*/

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Radial");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, treeLayout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout,
                        treeLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.removePreRenderPaintable(rings);
            }
            vv.repaint();
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);

    content.add(controls, BorderLayout.SOUTH);

}

From source file:org.ohdsi.whiteRabbit.WhiteRabbitMain.java

private JPanel createFakeDataPanel() {
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0.5;//from   w w w  . j a va  2s  .co  m

    JPanel folderPanel = new JPanel();
    folderPanel.setLayout(new BoxLayout(folderPanel, BoxLayout.X_AXIS));
    folderPanel.setBorder(BorderFactory.createTitledBorder("Scan report file"));
    scanReportFileField = new JTextField();
    scanReportFileField.setText((new File("ScanReport.xlsx").getAbsolutePath()));
    scanReportFileField.setToolTipText(
            "The path to the scan report that will be used as a template to generate the fake data");
    folderPanel.add(scanReportFileField);
    JButton pickButton = new JButton("Pick file");
    pickButton.setToolTipText("Pick a scan report file");
    folderPanel.add(pickButton);
    pickButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            pickScanReportFile();
        }
    });
    componentsToDisableWhenRunning.add(pickButton);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    panel.add(folderPanel, c);

    JPanel targetPanel = new JPanel();
    targetPanel.setLayout(new GridLayout(0, 2));
    targetPanel.setBorder(BorderFactory.createTitledBorder("Target data location"));
    targetPanel.add(new JLabel("Data type"));
    targetType = new JComboBox<String>(
            new String[] { "Delimited text files", "MySQL", "Oracle", "SQL Server", "PostgreSQL" });
    // targetType = new JComboBox(new String[] { "Delimited text files", "MySQL" });
    targetType.setToolTipText("Select the type of source data available");
    targetType.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent arg0) {
            targetIsFiles = arg0.getItem().toString().equals("Delimited text files");
            targetServerField.setEnabled(!targetIsFiles);
            targetUserField.setEnabled(!targetIsFiles);
            targetPasswordField.setEnabled(!targetIsFiles);
            targetDatabaseField.setEnabled(!targetIsFiles);
            targetCSVFormat.setEnabled(targetIsFiles);

            if (!targetIsFiles && arg0.getItem().toString().equals("Oracle")) {
                targetServerField.setToolTipText(
                        "For Oracle servers this field contains the SID, servicename, and optionally the port: '<host>/<sid>', '<host>:<port>/<sid>', '<host>/<service name>', or '<host>:<port>/<service name>'");
                targetUserField.setToolTipText(
                        "For Oracle servers this field contains the name of the user used to log in");
                targetPasswordField.setToolTipText(
                        "For Oracle servers this field contains the password corresponding to the user");
                targetDatabaseField.setToolTipText(
                        "For Oracle servers this field contains the schema (i.e. 'user' in Oracle terms) containing the source tables");
            } else if (!targetIsFiles && arg0.getItem().toString().equals("PostgreSQL")) {
                targetServerField.setToolTipText(
                        "For PostgreSQL servers this field contains the host name and database name (<host>/<database>)");
                targetUserField.setToolTipText("The user used to log in to the server");
                targetPasswordField.setToolTipText("The password used to log in to the server");
                targetDatabaseField.setToolTipText(
                        "For PostgreSQL servers this field contains the schema containing the source tables");
            } else if (!targetIsFiles) {
                targetServerField
                        .setToolTipText("This field contains the name or IP address of the database server");
                if (arg0.getItem().toString().equals("SQL Server"))
                    targetUserField.setToolTipText(
                            "The user used to log in to the server. Optionally, the domain can be specified as <domain>/<user> (e.g. 'MyDomain/Joe')");
                else
                    targetUserField.setToolTipText("The user used to log in to the server");
                targetPasswordField.setToolTipText("The password used to log in to the server");
                targetDatabaseField.setToolTipText("The name of the database containing the source tables");
            }
        }
    });
    targetPanel.add(targetType);

    targetPanel.add(new JLabel("Server location"));
    targetServerField = new JTextField("127.0.0.1");
    targetServerField.setEnabled(false);
    targetPanel.add(targetServerField);
    targetPanel.add(new JLabel("User name"));
    targetUserField = new JTextField("");
    targetUserField.setEnabled(false);
    targetPanel.add(targetUserField);
    targetPanel.add(new JLabel("Password"));
    targetPasswordField = new JPasswordField("");
    targetPasswordField.setEnabled(false);
    targetPanel.add(targetPasswordField);
    targetPanel.add(new JLabel("Database name"));
    targetDatabaseField = new JTextField("");
    targetDatabaseField.setEnabled(false);
    targetPanel.add(targetDatabaseField);

    targetPanel.add(new JLabel("CSV Format"));
    targetCSVFormat = new JComboBox<>(new String[] { "Default (comma, CRLF)", "TDF (tab, CRLF)",
            "MySQL (tab, LF)", "RFC4180", "Excel CSV" });
    targetCSVFormat.setToolTipText("The format of the output");
    targetCSVFormat.setEnabled(true);
    targetPanel.add(targetCSVFormat);

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    panel.add(targetPanel, c);

    JPanel fakeDataButtonPanel = new JPanel();
    fakeDataButtonPanel.setLayout(new BoxLayout(fakeDataButtonPanel, BoxLayout.X_AXIS));

    fakeDataButtonPanel.add(new JLabel("Max rows per table"));
    generateRowCount = new JSpinner();
    generateRowCount.setValue(10000);
    fakeDataButtonPanel.add(generateRowCount);
    fakeDataButtonPanel.add(Box.createHorizontalGlue());

    JButton testConnectionButton = new JButton("Test connection");
    testConnectionButton.setBackground(new Color(151, 220, 141));
    testConnectionButton.setToolTipText("Test the connection");
    testConnectionButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            testConnection(getTargetDbSettings());
        }
    });
    componentsToDisableWhenRunning.add(testConnectionButton);
    fakeDataButtonPanel.add(testConnectionButton);

    JButton fakeDataButton = new JButton("Generate fake data");
    fakeDataButton.setBackground(new Color(151, 220, 141));
    fakeDataButton.setToolTipText("Generate fake data based on the scan report");
    fakeDataButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            fakeDataRun();
        }
    });
    componentsToDisableWhenRunning.add(fakeDataButton);
    fakeDataButtonPanel.add(fakeDataButton);

    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    panel.add(fakeDataButtonPanel, c);

    return panel;
}

From source file:org.mbs3.juniuploader.gui.pnlSettings.java

private void initGUI() {
    try {/*from   w  ww. j a  v a  2  s  . c  om*/
        GridBagLayout thisLayout = new GridBagLayout();
        thisLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                0.0, 0.0, 0.0, 0.0 };
        thisLayout.rowHeights = new int[] { 11, 20, 18, 22, 22, 23, 23, 20, 18, 23, 22, 24, 6, 26, 4, 30, 8 };
        thisLayout.columnWeights = new double[] { 0.0, 0.0, 0.0, 0.1, 0.1, 0.1, 0.0, 0.1, 0.0 };
        thisLayout.columnWidths = new int[] { 10, 106, 90, 20, 20, 7, 100, 20, 7 };
        this.setLayout(thisLayout);
        this.setPreferredSize(new java.awt.Dimension(659, 349));
        {
            {
                grpMain = new ButtonGroup();
            }
            {
                grpGUI = new ButtonGroup();
            }
            {
                grpObjects = new ButtonGroup();
            }
            {
                grpHTTP = new ButtonGroup();
            }
            {
            }
            {
            }
            lblGUI = new JLabel();
            this.add(lblGUI, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblGUI.setText("Graphical Interface");
        }
        {
            lblMain = new JLabel();
            this.add(lblMain, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblMain.setText("Main Program");
        }
        {
            lblObj = new JLabel();
            this.add(lblObj, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblObj.setText("Object Messages");
        }
        {
            lblLObj = new JLabel();
            this.add(lblLObj, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblLObj.setText("HTTP Messages");
        }
        {
            lblFatal = new JLabel();
            this.add(lblFatal, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblFatal.setText("Fatal Messages");
        }
        {
            lblError = new JLabel();
            this.add(lblError, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblError.setText("Errors");
        }
        {
            lblWarn = new JLabel();
            this.add(lblWarn, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblWarn.setText("Warnings");
        }
        {
            lblInfo = new JLabel();
            this.add(lblInfo, new GridBagConstraints(5, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblInfo.setText("Info Messages");
        }
        {
            lblDebug = new JLabel();
            this.add(lblDebug, new GridBagConstraints(6, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblDebug.setText("Debug Messages");
        }
        {
            lblTrace = new JLabel();
            this.add(lblTrace, new GridBagConstraints(7, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            lblTrace.setText("Trace Execution");
        }
        {
            btnMainFatal = new JRadioButton();
            this.add(btnMainFatal, new GridBagConstraints(2, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
        }
        grpMain.add(btnMainFatal);
        btnMainFatal.setActionCommand("fatal");
        btnMainFatal.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent evt) {
                logLevelBtnAction(evt);
            }
        });
        {
            btnMainError = new JRadioButton();
            this.add(btnMainError, new GridBagConstraints(3, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainError);
            btnMainError.setActionCommand("error");
            btnMainError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainWarn = new JRadioButton();
            this.add(btnMainWarn, new GridBagConstraints(4, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainWarn);
            btnMainWarn.setActionCommand("warn");
            btnMainWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainInfo = new JRadioButton();
            this.add(btnMainInfo, new GridBagConstraints(5, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainInfo);
            btnMainInfo.setActionCommand("info");
            btnMainInfo.setSelected(true);
            btnMainInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainDebug = new JRadioButton();
            this.add(btnMainDebug, new GridBagConstraints(6, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainDebug);
            btnMainDebug.setActionCommand("debug");
            btnMainDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnMainTrace = new JRadioButton();
            this.add(btnMainTrace, new GridBagConstraints(7, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpMain.add(btnMainTrace);
            btnMainTrace.setActionCommand("trace");
            btnMainTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIFatal = new JRadioButton();
            this.add(btnGUIFatal, new GridBagConstraints(2, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIFatal);
            btnGUIFatal.setActionCommand("fatal");
            btnGUIFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIError = new JRadioButton();
            this.add(btnGUIError, new GridBagConstraints(3, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIError);
            btnGUIError.setActionCommand("error");
            btnGUIError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIWarn = new JRadioButton();
            this.add(btnGUIWarn, new GridBagConstraints(4, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIWarn);
            btnGUIWarn.setActionCommand("warn");
            btnGUIWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIInfo = new JRadioButton();
            this.add(btnGUIInfo, new GridBagConstraints(5, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIInfo);
            btnGUIInfo.setActionCommand("info");
            btnGUIInfo.setSelected(true);
            btnGUIInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUIDebug = new JRadioButton();
            this.add(btnGUIDebug, new GridBagConstraints(6, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUIDebug);
            btnGUIDebug.setActionCommand("debug");
            btnGUIDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnGUITrace = new JRadioButton();
            this.add(btnGUITrace, new GridBagConstraints(7, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpGUI.add(btnGUITrace);
            btnGUITrace.setActionCommand("trace");
            btnGUITrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjFatal = new JRadioButton();
            this.add(btnObjFatal, new GridBagConstraints(2, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjFatal);
            btnObjFatal.setActionCommand("fatal");
            btnObjFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjError = new JRadioButton();
            this.add(btnObjError, new GridBagConstraints(3, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjError);
            btnObjError.setActionCommand("error");
            btnObjError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjWarn = new JRadioButton();
            this.add(btnObjWarn, new GridBagConstraints(4, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjWarn);
            btnObjWarn.setActionCommand("warn");
            btnObjWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjInfo = new JRadioButton();
            this.add(btnObjInfo, new GridBagConstraints(5, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjInfo);
            btnObjInfo.setActionCommand("info");
            btnObjInfo.setSelected(true);
            btnObjInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjDebug = new JRadioButton();
            this.add(btnObjDebug, new GridBagConstraints(6, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjDebug);
            btnObjDebug.setActionCommand("debug");
            btnObjDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnObjTrace = new JRadioButton();
            this.add(btnObjTrace, new GridBagConstraints(7, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpObjects.add(btnObjTrace);
            btnObjTrace.setActionCommand("trace");
            btnObjTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPFatal = new JRadioButton();
            this.add(btnHTTPFatal, new GridBagConstraints(2, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPFatal);
            btnHTTPFatal.setActionCommand("fatal");
            btnHTTPFatal.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPError = new JRadioButton();
            this.add(btnHTTPError, new GridBagConstraints(3, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPError);
            btnHTTPError.setActionCommand("error");
            btnHTTPError.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPWarn = new JRadioButton();
            this.add(btnHTTPWarn, new GridBagConstraints(4, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPWarn);
            btnHTTPWarn.setActionCommand("warn");
            btnHTTPWarn.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPInfo = new JRadioButton();
            this.add(btnHTTPInfo, new GridBagConstraints(5, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPInfo);
            btnHTTPInfo.setActionCommand("info");
            btnHTTPInfo.setSelected(true);
            btnHTTPInfo.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPDebug = new JRadioButton();
            this.add(btnHTTPDebug, new GridBagConstraints(6, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPDebug);
            btnHTTPDebug.setActionCommand("debug");
            btnHTTPDebug.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            btnHTTPTrace = new JRadioButton();
            this.add(btnHTTPTrace, new GridBagConstraints(7, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            grpHTTP.add(btnHTTPTrace);
            btnHTTPTrace.setActionCommand("trace");
            btnHTTPTrace.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    logLevelBtnAction(evt);
                }
            });
        }
        {
            lblLogLevel = new JLabel();
            this.add(lblLogLevel, new GridBagConstraints(1, 1, 7, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblLogLevel.setText("Set the level of logging for different parts of this application:");
        }
        {
            lblDeLF = new JLabel();
            this.add(lblDeLF, new GridBagConstraints(1, 8, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblDeLF.setText("Set the look and feel for the GUI of this application:");
        }
        {
            LookAndFeelInfo[] lfs = UIManager.getInstalledLookAndFeels();
            LookAndFeel lf = UIManager.getLookAndFeel();
            DefaultComboBoxModel cmbLFModel = new DefaultComboBoxModel();
            for (int i = 0; i < lfs.length; i++) {
                String n = lfs[i].getName();
                cmbLFModel.addElement(n);
                if (lf.getName().equals(lfs[i].getName()))
                    cmbLFModel.setSelectedItem(n);
            }
            cmbLF = new JComboBox();
            this.add(cmbLF, new GridBagConstraints(1, 9, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            cmbLF.setModel(cmbLFModel);
            cmbLF.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent evt) {
                    cmbLFItemStateChanged(evt);
                }
            });
        }
        {
            tfUserAgent = new JTextField(Util.getUserAgent());
            this.add(tfUserAgent, new GridBagConstraints(1, 11, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            tfUserAgent.addKeyListener(new KeyAdapter() {
                public void keyReleased(KeyEvent evt) {
                    tfUserAgentKeyReleased(evt);
                }
            });
        }
        {
            lblUserAgent = new JLabel();
            this.add(lblUserAgent, new GridBagConstraints(1, 10, 6, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            lblUserAgent.setText("User Agent");
        }
        {
            btnExport = new JToggleButton();
            this.add(btnExport, new GridBagConstraints(1, 15, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
            btnExport.setText("Export All Settings and Data to File");
            btnExport.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    btnExportActionPerformed(evt);
                }
            });
        }
        {
            txtWarn = new JTextPane();
            this.add(txtWarn, new GridBagConstraints(4, 15, 4, 1, 0.0, 0.0, GridBagConstraints.CENTER,
                    GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));
            txtWarn.setText(
                    "Note: This includes rules, form variables, sites, and ANYTHING else this program can remember from run to run.");
            txtWarn.setEditable(false);
            txtWarn.setBackground(new java.awt.Color(255, 255, 255));
            txtWarn.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(0, 0, 0)));
        }

    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.languagetool.gui.ConfigurationDialog.java

private void createOfficeElements(GridBagConstraints cons, JPanel portPanel) {
    int numParaCheck = config.getNumParasToCheck();
    JRadioButton[] radioButtons = new JRadioButton[3];
    ButtonGroup numParaGroup = new ButtonGroup();
    radioButtons[0] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckOnlyParagraph")));
    radioButtons[0].setActionCommand("ParagraphCheck");

    radioButtons[1] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckFullText")));
    radioButtons[1].setActionCommand("FullTextCheck");

    radioButtons[2] = new JRadioButton(Tools.getLabel(messages.getString("guiCheckNumParagraphs")));
    radioButtons[2].setActionCommand("NParagraphCheck");
    radioButtons[2].setSelected(true);/*from  w  w  w .j  a  v a  2s .  c  om*/

    JTextField numParaField = new JTextField(Integer.toString(5), 2);
    numParaField.setEnabled(radioButtons[2].isSelected());
    numParaField.setMinimumSize(new Dimension(30, 25));

    for (int i = 0; i < 3; i++) {
        numParaGroup.add(radioButtons[i]);
    }

    if (numParaCheck == 0) {
        radioButtons[0].setSelected(true);
        numParaField.setEnabled(false);
    } else if (numParaCheck < 0) {
        radioButtons[1].setSelected(true);
        numParaField.setEnabled(false);
    } else {
        radioButtons[2].setSelected(true);
        numParaField.setText(Integer.toString(numParaCheck));
        numParaField.setEnabled(true);
    }

    radioButtons[0].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            numParaField.setEnabled(false);
            config.setNumParasToCheck(0);
        }
    });

    radioButtons[1].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            numParaField.setEnabled(false);
            config.setNumParasToCheck(-1);
        }
    });

    radioButtons[2].addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int numParaCheck = Integer.parseInt(numParaField.getText());
            if (numParaCheck < 1)
                numParaCheck = 1;
            else if (numParaCheck > 99)
                numParaCheck = 99;
            config.setNumParasToCheck(numParaCheck);
            numParaField.setForeground(Color.BLACK);
            numParaField.setText(Integer.toString(numParaCheck));
            numParaField.setEnabled(true);
        }
    });

    numParaField.getDocument().addDocumentListener(new DocumentListener() {

        @Override
        public void insertUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void removeUpdate(DocumentEvent e) {
            changedUpdate(e);
        }

        @Override
        public void changedUpdate(DocumentEvent e) {
            try {
                int numParaCheck = Integer.parseInt(numParaField.getText());
                if (numParaCheck > 0 && numParaCheck < 99) {
                    numParaField.setForeground(Color.BLACK);
                    config.setNumParasToCheck(numParaCheck);
                } else {
                    numParaField.setForeground(Color.RED);
                }
            } catch (NumberFormatException ex) {
                numParaField.setForeground(Color.RED);
            }
        }
    });

    JLabel textChangedLabel = new JLabel(Tools.getLabel(messages.getString("guiTextChangeLabel")));
    cons.gridy++;
    portPanel.add(textChangedLabel, cons);

    cons.gridy++;
    cons.insets = new Insets(0, 30, 0, 0);
    for (int i = 0; i < 3; i++) {
        portPanel.add(radioButtons[i], cons);
        if (i < 2)
            cons.gridy++;
    }
    cons.gridx = 1;
    portPanel.add(numParaField, cons);

    JCheckBox noMultiResetbox = new JCheckBox(Tools.getLabel(messages.getString("guiNoMultiReset")));
    noMultiResetbox.setSelected(config.isNoMultiReset());
    noMultiResetbox.setEnabled(config.isResetCheck());
    noMultiResetbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            config.setNoMultiReset(noMultiResetbox.isSelected());
        }
    });

    JCheckBox resetCheckbox = new JCheckBox(Tools.getLabel(messages.getString("guiDoResetCheck")));
    resetCheckbox.setSelected(config.isResetCheck());
    resetCheckbox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            config.setDoResetCheck(resetCheckbox.isSelected());
            noMultiResetbox.setEnabled(resetCheckbox.isSelected());
        }
    });
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    //    JLabel dummyLabel = new JLabel(" ");
    //    cons.gridy++;
    //    portPanel.add(dummyLabel, cons);
    cons.gridy++;
    portPanel.add(resetCheckbox, cons);

    cons.insets = new Insets(0, 30, 0, 0);
    cons.gridx = 0;
    cons.gridy++;
    portPanel.add(noMultiResetbox, cons);

    JCheckBox fullTextCheckAtFirstBox = new JCheckBox(
            Tools.getLabel(messages.getString("guiCheckFullTextAtFirst")));
    fullTextCheckAtFirstBox.setSelected(config.doFullCheckAtFirst());
    fullTextCheckAtFirstBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            config.setFullCheckAtFirst(fullTextCheckAtFirstBox.isSelected());
        }
    });
    cons.insets = new Insets(0, 4, 0, 0);
    cons.gridx = 0;
    //    cons.gridy++;
    //    JLabel dummyLabel2 = new JLabel(" ");
    //    portPanel.add(dummyLabel2, cons);
    cons.gridy++;
    portPanel.add(fullTextCheckAtFirstBox, cons);

    JCheckBox isMultiThreadBox = new JCheckBox(Tools.getLabel(messages.getString("guiIsMultiThread")));
    isMultiThreadBox.setSelected(config.isMultiThread());
    isMultiThreadBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            config.setMultiThreadLO(isMultiThreadBox.isSelected());
        }
    });
    cons.gridy++;
    JLabel dummyLabel3 = new JLabel(" ");
    portPanel.add(dummyLabel3, cons);
    cons.gridy++;
    portPanel.add(isMultiThreadBox, cons);

}