Example usage for java.awt.event KeyAdapter KeyAdapter

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

Introduction

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

Prototype

KeyAdapter

Source Link

Usage

From source file:gtu._work.ui.TextScanUI.java

private void initGUI() {
    try {/*from w  w w . ja  va  2s .  c o  m*/
        BorderLayout thisLayout = new BorderLayout();
        getContentPane().setLayout(thisLayout);
        this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        this.addComponentListener(new ComponentAdapter() {
            public void componentResized(ComponentEvent evt) {
                thisComponentResized(evt);
            }
        });
        this.addWindowStateListener(new WindowStateListener() {
            public void windowStateChanged(WindowEvent evt) {
                System.out.println("this.windowStateChanged, event=" + evt);
                // TODO add your code for this.windowStateChanged
            }
        });
        this.addWindowListener(new WindowAdapter() {
            public void windowIconified(WindowEvent evt) {
                System.out.println("this.windowIconified, event=" + evt);
                // TODO add your code for this.windowIconified
            }
        });
        this.setTitle(TITLE);
        {
            jPanel1 = new JPanel();
            getContentPane().add(jPanel1, BorderLayout.NORTH);
            GroupLayout jPanel1Layout = new GroupLayout((JComponent) jPanel1);
            jPanel1.setLayout(jPanel1Layout);
            jPanel1.setPreferredSize(new java.awt.Dimension(521, 89));
            jPanel1.setBounds(0, 0, 521, 89);
            {
                jButton1 = new JButton();
                jButton1.setText("File");
                jButton1.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jButton1ActionPerformed(evt);
                    }
                });
            }
            {
                jButton2 = new JButton();
                jButton2.setText("Clipboard");
                jButton2.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jButton2ActionPerformed(evt);
                    }
                });
            }
            {
                contentFilter = new JTextField();
                contentFilter.getDocument().addDocumentListener(new DocumentListener() {
                    public void insertUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }

                    public void removeUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }

                    public void changedUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField2filterAgain();
                    }
                });
            }
            {
                fileFilter = new JTextField();
                fileFilter.getDocument().addDocumentListener(new DocumentListener() {
                    public void insertUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }

                    public void removeUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }

                    public void changedUpdate(DocumentEvent paramDocumentEvent) {
                        jTextField1DocumentListener(paramDocumentEvent);
                    }
                });
            }
            {
                totalLabel = new JLabel();
            }
            {
                matchLabel = new JLabel();
            }
            {
                jLabel4 = new JLabel();
                jLabel4.setText("Match : ");
            }
            {
                jLabel2 = new JLabel();
                jLabel2.setText("Total : ");
            }
            {
                ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "All", "Match" });
                contextFilter = new JComboBox();
                contextFilter.setModel(jComboBox1Model);
                contextFilter.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        jTextField2filterAgain();
                    }
                });
            }
            {
                ComboBoxModel jComboBox1Model = new DefaultComboBoxModel(new String[] { "Regex", "find" });
                fileChk = new JComboBox();
                fileChk.setModel(jComboBox1Model);
                fileChk.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        fileChkActionPerformed(evt);
                    }
                });
            }
            {
                jScrollPane2 = new JScrollPane();
                {
                    ListModel groupListModel = new DefaultComboBoxModel();
                    groupList = new JList();
                    jScrollPane2.setViewportView(groupList);
                    groupList.setModel(groupListModel);
                    groupList.addKeyListener(new KeyAdapter() {
                        public void keyPressed(KeyEvent evt) {
                            groupListKeyPressed(evt);
                        }
                    });
                }
            }
            jPanel1Layout.setVerticalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(16, 16)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                    .addGroup(jPanel1Layout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton1, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(fileFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel2, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(fileChk, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE))
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel1Layout.createParallelGroup().addGroup(jPanel1Layout
                                            .createParallelGroup(GroupLayout.Alignment.BASELINE)
                                            .addComponent(jButton2, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(contentFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE)
                                            .addComponent(jLabel4, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                            .addComponent(contextFilter, GroupLayout.Alignment.BASELINE,
                                                    GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                                    GroupLayout.PREFERRED_SIZE))
                                            .addComponent(matchLabel, GroupLayout.Alignment.LEADING,
                                                    GroupLayout.PREFERRED_SIZE, 24,
                                                    GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel1Layout.createParallelGroup()
                                    .addComponent(totalLabel, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 24, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jScrollPane2, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 61, GroupLayout.PREFERRED_SIZE)))
                    .addContainerGap(12, 12));
            jPanel1Layout.setHorizontalGroup(jPanel1Layout.createSequentialGroup().addContainerGap(12, 12)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(contextFilter, GroupLayout.Alignment.LEADING,
                                    GroupLayout.PREFERRED_SIZE, 87, GroupLayout.PREFERRED_SIZE)
                            .addComponent(fileChk, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    87, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(jLabel4, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    45, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(matchLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    67, GroupLayout.PREFERRED_SIZE)
                            .addComponent(totalLabel, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    67, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(contentFilter, GroupLayout.Alignment.LEADING,
                                    GroupLayout.PREFERRED_SIZE, 266, GroupLayout.PREFERRED_SIZE)
                            .addComponent(fileFilter, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    266, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
                    .addGroup(jPanel1Layout.createParallelGroup()
                            .addComponent(jButton1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    91, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton2, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE,
                                    91, GroupLayout.PREFERRED_SIZE))
                    .addGap(19)
                    .addComponent(jScrollPane2, GroupLayout.PREFERRED_SIZE, 36, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(16, 16));
        }
        {
            jScrollPane1 = new JScrollPane();
            getContentPane().add(jScrollPane1, BorderLayout.CENTER);
            jScrollPane1.setPreferredSize(new java.awt.Dimension(581, 235));
            {
                ListModel jList1Model = new DefaultComboBoxModel();
                matchList = new JList();
                jScrollPane1.setViewportView(matchList);

                // matchList.setPreferredSize(new java.awt.Dimension(575,
                // 232));// ???
                // ??
                // XXX
                // TODO
                // IMPORT
                // !!!!

                matchList.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent evt) {
                        jList1MouseClicked(evt);
                    }
                });
                matchList.setModel(jList1Model);
            }
        }
        this.setSize(697, 440);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.p_vcd.ui.VcdDialog.java

public VcdDialog() {
    setSize(700, 450);/*  w w  w  .j  a  v a  2 s. c o  m*/
    setTitle("P-VCD - Video Copy Detection");
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.currentStep = 1;

    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    contentPanel.setLayout(new CardLayout(0, 0));
    {
        JPanel panel_Step1 = new JPanel();
        contentPanel.add(panel_Step1, "card_step1");
        panel_Step1.setLayout(new BorderLayout(0, 0));
        JLabel lblTitle = new JLabel("STEP 1 - Video Database (the \"known\")");
        panel_Step1.add(lblTitle, BorderLayout.NORTH);
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));

        JPanel panel_1 = new JPanel();
        panel_Step1.add(panel_1, BorderLayout.CENTER);
        panel_1.setLayout(new MigLayout("", "[250px,grow][20px][250px,grow]", "[][][230px,grow][][][]"));

        JLabel lblNewLabel = new JLabel("Please select the video databases to search in:");
        panel_1.add(lblNewLabel, "cell 0 0");

        panel_1.add(lbl_refDbTitle, "cell 2 1");

        JScrollPane scrollPane_1 = new JScrollPane();
        panel_1.add(scrollPane_1, "cell 0 1 1 3,grow");
        panel_refDatabasesList.setBackground(Color.WHITE);

        scrollPane_1.setViewportView(panel_refDatabasesList);
        panel_refDatabasesList.setLayout(new MigLayout("gapy 10", "[200px]", "[][]"));

        JScrollPane scrollPane = new JScrollPane();
        scrollPane.setBorder(null);
        panel_1.add(scrollPane, "cell 2 2,grow");

        scrollPane.setViewportView(lbl_refDbFiles);

        panel_1.add(lbl_refDbMetadata, "cell 2 3");

        JButton btnNewDatabase = new JButton("New database...");
        panel_1.add(btnNewDatabase, "cell 0 4");
        btnNewDatabase.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                newDatabaseButton();
            }
        });
    }
    {
        JPanel panel_Step2 = new JPanel();
        contentPanel.add(panel_Step2, "card_step2");
        panel_Step2.setLayout(new BorderLayout(0, 0));
        JLabel lblTitle = new JLabel("STEP 2 - Query (the \"unknown\")");
        panel_Step2.add(lblTitle, BorderLayout.NORTH);
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));

        JPanel panel = new JPanel();
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Query",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel_Step2.add(panel, BorderLayout.CENTER);
        panel.setLayout(
                new MigLayout("", "[160px][grow]", "[25px][grow,top][25px][grow,top][25px][grow,top][grow]"));

        ButtonGroup queryButtonGroup = new ButtonGroup();

        queryButtonGroup.add(radio_queryFile);
        radio_queryFile.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryFile, "cell 0 0");

        lbl_queryFile.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                radio_queryFile.setSelected(true);
            }
        });
        panel.add(lbl_queryFile, "flowy,cell 1 0");

        JButton btnSelectFile = new JButton("Select File...");
        btnSelectFile.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                selectFileButton();
            }
        });
        panel.add(btnSelectFile, "cell 1 0");

        JLabel lblIumageOrVideo = new JLabel("Select an image or video in the local machine.");
        panel.add(lblIumageOrVideo, "cell 1 1");

        queryButtonGroup.add(radio_queryUrl);
        radio_queryUrl.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryUrl, "cell 0 2");

        txt_queryUrl.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.addMouseListener(new MouseAdapter() {
            @Override
            public void mouseClicked(MouseEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.addFocusListener(new FocusAdapter() {
            @Override
            public void focusGained(FocusEvent e) {
                radio_queryUrl.setSelected(true);
            }
        });
        txt_queryUrl.setText("http://");
        panel.add(txt_queryUrl, "flowy,cell 1 2");
        txt_queryUrl.setColumns(50);

        JLabel lblUrlToA = new JLabel(
                "<html>Enter the URL to download an image or video.<br>You can use a URL like: http://www.youtube.com/watch?v=... </html>");
        panel.add(lblUrlToA, "flowy,cell 1 3");

        queryButtonGroup.add(radio_queryDb);
        radio_queryDb.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_queryDb, "cell 0 4");

        comboBox_queryDb.setMaximumRowCount(12);
        comboBox_queryDb.setPreferredSize(new Dimension(100, 20));
        comboBox_queryDb.setMinimumSize(new Dimension(100, 20));
        comboBox_queryDb.addPropertyChangeListener(new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent evt) {
                if (comboBox_queryDb.getSelectedIndex() > 0)
                    radio_queryDb.setSelected(true);
                updateQueryDbDetail();
            }
        });
        comboBox_queryDb.addKeyListener(new KeyAdapter() {
            @Override
            public void keyReleased(KeyEvent e) {
                if (comboBox_queryDb.getSelectedIndex() > 0)
                    radio_queryDb.setSelected(true);
                updateQueryDbDetail();
            }
        });

        panel.add(comboBox_queryDb, "flowx,cell 1 4");

        panel.add(lbl_queryDb, "cell 1 4");

        JLabel lblPleaseNopteThe = new JLabel("<html>A search is run for each video in the database.</html>");
        panel.add(lblPleaseNopteThe, "cell 1 5");

    }
    {
        JPanel panel_Step3 = new JPanel();
        contentPanel.add(panel_Step3, "card_step3");
        panel_Step3.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 3 - Search Options");
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        panel_Step3.add(lblTitle, BorderLayout.NORTH);

        JPanel panel2 = new JPanel();
        panel2.setLayout(new FlowLayout());
        panel_Step3.add(panel2, BorderLayout.CENTER);
        JPanel panel = new JPanel();
        panel2.add(panel);
        panel.setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Basic Options",
                TitledBorder.LEADING, TitledBorder.TOP, null, null));
        panel.setLayout(new MigLayout("gapy 5px", "[30px][101px]", "[][][][][][][20px]"));

        ButtonGroup buttonGroup = new ButtonGroup();

        buttonGroup.add(radio_searchByGlobal);
        radio_searchByGlobal.setFont(new Font("Tahoma", Font.PLAIN, 13));
        radio_searchByGlobal.setSelected(true);
        panel.add(radio_searchByGlobal, "cell 0 0 2 1,alignx left,aligny top");

        JLabel lblNewLabel_2 = new JLabel(
                "Detects most of the copies that are visually alike to the original.");
        panel.add(lblNewLabel_2, "cell 1 1");

        JButton btnOptions = new JButton("Advanced Options...");
        btnOptions.setEnabled(false);
        panel.add(btnOptions, "cell 1 2");

        buttonGroup.add(radio_searchByLocal);
        radio_searchByLocal.setFont(new Font("Tahoma", Font.PLAIN, 13));
        panel.add(radio_searchByLocal, "cell 0 4 2 1,alignx left,aligny top");

        JLabel lblNewLabel_3 = new JLabel(
                "Requires more resources (disk space, search time, memory) but can detect more copies.");
        panel.add(lblNewLabel_3, "cell 1 5");

        JButton btnOptions_1 = new JButton("Advanced Options...");
        btnOptions_1.setEnabled(false);
        panel.add(btnOptions_1, "cell 1 6");

    }
    {
        JPanel panel_Step4 = new JPanel();
        contentPanel.add(panel_Step4, "card_step4");
        panel_Step4.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 4 - Search");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        panel_Step4.add(lblTitle, BorderLayout.NORTH);

        JScrollPane scrollPane = new JScrollPane();
        panel_Step4.add(scrollPane, BorderLayout.CENTER);

        textConsole.setFont(new Font("Monospaced", Font.PLAIN, 11));
        textConsole.setForeground(Color.WHITE);
        textConsole.setBackground(Color.BLACK);
        textConsole.setEditable(false);
        textConsole.setCursor(new Cursor(Cursor.TEXT_CURSOR));
        textConsole.setText(
                "Press 'Next' button to start the search...\nNote: Depending on the selected options, the search may take up to several hours.");
        scrollPane.setViewportView(textConsole);

        JPanel panel = new JPanel();
        panel_Step4.add(panel, BorderLayout.SOUTH);
        panel.setLayout(new GridLayout(0, 1, 0, 0));

        JSeparator separator = new JSeparator();
        separator.setPreferredSize(new Dimension(0, 1));
        panel.add(separator);
        progressBar.setStringPainted(true);
        progressBar.setPreferredSize(new Dimension(350, 20));
        panel.add(progressBar);

        lblProgress.setHorizontalAlignment(SwingConstants.CENTER);
        lblProgress.setFont(new Font("Tahoma", Font.PLAIN, 14));
        panel.add(lblProgress);
    }
    {
        JPanel panel_Step5 = new JPanel();
        contentPanel.add(panel_Step5, "card_step5");
        panel_Step5.setLayout(new BorderLayout(0, 0));

        JLabel lblTitle = new JLabel("STEP 5 - Results");
        lblTitle.setHorizontalAlignment(SwingConstants.CENTER);
        lblTitle.setFont(new Font("Tahoma", Font.PLAIN, 18));
        panel_Step5.add(lblTitle, BorderLayout.NORTH);

        JScrollPane scrollPane = new JScrollPane();
        panel_Step5.add(scrollPane, BorderLayout.CENTER);

        scrollPane.setViewportView(panelResults);
        panelResults.setLayout(new MigLayout("gapy 10, gapx 20",
                "[120px,center][150px,center,grow][150px,center,grow]", "[25px][]"));

    }
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton prevButton = new JButton("Previous");
            prevButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    previousButton();
                }
            });
            prevButton.setActionCommand("Previous");
            buttonPane.add(prevButton);
        }
        {
            JButton okButton = new JButton("Next");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    nextButton();
                }
            });
            okButton.setActionCommand("OK");
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    cancelButton();
                }
            });
            cancelButton.setActionCommand("Cancel");
            buttonPane.add(cancelButton);
        }
    }
    this.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosed(WindowEvent e) {
            closeWindow();
        }
    });
    updateDatabases(null);
}

From source file:org.ut.biolab.medsavant.client.project.ProjectWizard.java

private AbstractWizardPage getNamePage() {

    //setup page//from  w  ww.  ja v  a  2s  .com
    final DefaultWizardPage page = new DefaultWizardPage(PAGENAME_NAME) {
        @Override
        public void setupWizardButtons() {
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.FINISH);
            fireButtonEvent(ButtonEvent.HIDE_BUTTON, ButtonNames.BACK);
            if (projectName == null || projectName.equals("")) {
                fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT);
            } else {
                fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
            }
        }
    };
    page.addText("Choose a name for the project. \n" + "The name cannot already be in use. ");

    //setup text field
    final JTextField namefield = new JTextField();
    namefield.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (namefield.getText() != null && !namefield.getText().equals("")) {
                projectName = namefield.getText();
                page.fireButtonEvent(ButtonEvent.ENABLE_BUTTON, ButtonNames.NEXT);
            } else {
                page.fireButtonEvent(ButtonEvent.DISABLE_BUTTON, ButtonNames.NEXT);
            }
        }
    });
    page.addComponent(namefield);
    if (modify) {
        namefield.setText(projectName);
    }

    return page;
}

From source file:org.openmicroscopy.shoola.agents.dataBrowser.view.SearchPanel.java

/** Initializes the components composing the display. */
private void initComponents() {
    usersBox = new JComboBox();
    groupsBox = createGroupBox();//from  w  w w  . j  a  v a  2  s  .c  o m
    scopes = new HashMap<Integer, JCheckBox>(model.getNodes().size());
    types = new HashMap<Integer, JCheckBox>(model.getTypes().size());
    IconManager icons = IconManager.getInstance();
    fromDate = UIUtilities.createDatePicker(true, EditorUtil.DATE_PICKER_FORMAT);
    fromDate.setBackground(UIUtilities.BACKGROUND_COLOR);
    fromDate.addPropertyChangeListener("date", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Date d = (Date) evt.getNewValue();
            if (d != null) {
                if (d.after(new Date())) {
                    UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier();
                    un.notifyWarning("Invalid Date", "Selecting a future 'From' date doesn't make any sense.");
                    fromDate.setDate(null);
                }
                if (toDate.getDate() != null && d.after(toDate.getDate())) {
                    UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier();
                    un.notifyWarning("Invalid Date",
                            "Cannot set a 'From' date which is more recent than the 'To' date.");
                    fromDate.setDate(null);
                }
            }
        }
    });
    fromDate.setToolTipText(DATE_TOOLTIP);

    toDate = UIUtilities.createDatePicker(true, EditorUtil.DATE_PICKER_FORMAT);
    toDate.setBackground(UIUtilities.BACKGROUND_COLOR);
    toDate.setToolTipText(DATE_TOOLTIP);
    toDate.addPropertyChangeListener("date", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            Date d = (Date) evt.getNewValue();
            if (d != null) {
                if (fromDate.getDate() != null && d.before(fromDate.getDate())) {
                    UserNotifier un = DataBrowserAgent.getRegistry().getUserNotifier();
                    un.notifyWarning("Invalid Date",
                            "Cannot set a 'To' date which is prior to the 'From' date.");
                    toDate.setDate(null);
                }
            }
        }
    });

    clearDate = new JButton(icons.getIcon(IconManager.CLOSE));
    clearDate.setToolTipText("Reset the dates");
    UIUtilities.unifiedButtonLookAndFeel(clearDate);
    clearDate.setBackground(UIUtilities.BACKGROUND_COLOR);
    clearDate.setActionCommand("" + SearchComponent.RESET_DATE);
    clearDate.addActionListener(model);

    fullTextArea = new JTextField(AREA_COLUMNS);
    fullTextArea.addKeyListener(new KeyAdapter() {

        /** Finds the phrase. */
        public void keyPressed(KeyEvent e) {
            Object source = e.getSource();
            if (source != fullTextArea)
                return;
            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER:
                model.search();
            }
        }
    });

    helpBasicButton = new JButton(icons.getIcon(IconManager.HELP));
    helpBasicButton.setToolTipText("Search Tips.");
    helpBasicButton.setBackground(UIUtilities.BACKGROUND_COLOR);
    UIUtilities.unifiedButtonLookAndFeel(helpBasicButton);
    helpBasicButton.addActionListener(model);
    helpBasicButton.setActionCommand("" + SearchComponent.HELP);

    SearchContext ctx = model.getSearchContext();
    if (ctx == null)
        return;
}

From source file:net.pms.newgui.GeneralTab.java

public JComponent build() {
    // Apply the orientation for the locale
    Locale locale = new Locale(configuration.getLanguage());
    ComponentOrientation orientation = ComponentOrientation.getOrientation(locale);
    String colSpec = FormLayoutUtil.getColSpec(COL_SPEC, orientation);

    FormLayout layout = new FormLayout(colSpec, ROW_SPEC);
    PanelBuilder builder = new PanelBuilder(layout);
    builder.setBorder(Borders.DLU4_BORDER);
    builder.setOpaque(true);/*from   w  ww .  ja v a  2  s .  c  om*/

    CellConstraints cc = new CellConstraints();

    smcheckBox = new JCheckBox(Messages.getString("NetworkTab.3"));
    smcheckBox.setContentAreaFilled(false);
    smcheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setMinimized((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    if (configuration.isMinimized()) {
        smcheckBox.setSelected(true);
    }

    JComponent cmp = builder.addSeparator(Messages.getString("NetworkTab.5"),
            FormLayoutUtil.flip(cc.xyw(1, 1, 9), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));
    builder.addLabel(Messages.getString("NetworkTab.0"),
            FormLayoutUtil.flip(cc.xy(1, 7), colSpec, orientation));
    final KeyedComboBoxModel kcbm = new KeyedComboBoxModel(
            new Object[] { "ar", "bg", "ca", "zhs", "zht", "cz", "da", "nl", "en", "fi", "fr", "de", "el", "iw",
                    "is", "it", "ja", "ko", "no", "pl", "pt", "br", "ro", "ru", "sl", "es", "sv", "tr" },
            new Object[] { "Arabic", "Bulgarian", "Catalan", "Chinese (Simplified)", "Chinese (Traditional)",
                    "Czech", "Danish", "Dutch", "English", "Finnish", "French", "German", "Greek", "Hebrew",
                    "Icelandic", "Italian", "Japanese", "Korean", "Norwegian", "Polish", "Portuguese",
                    "Portuguese (Brazilian)", "Romanian", "Russian", "Slovenian", "Spanish", "Swedish",
                    "Turkish" });
    langs = new JComboBox(kcbm);
    langs.setEditable(false);
    String defaultLang = null;
    if (configuration.getLanguage() != null && configuration.getLanguage().length() > 0) {
        defaultLang = configuration.getLanguage();
    } else {
        defaultLang = Locale.getDefault().getLanguage();
    }
    if (defaultLang == null) {
        defaultLang = "en";
    }
    kcbm.setSelectedKey(defaultLang);
    if (langs.getSelectedIndex() == -1) {
        langs.setSelectedIndex(0);
    }

    langs.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setLanguage((String) kcbm.getSelectedKey());

            }
        }
    });

    builder.add(langs, FormLayoutUtil.flip(cc.xyw(3, 7, 7), colSpec, orientation));

    builder.add(smcheckBox, FormLayoutUtil.flip(cc.xyw(1, 9, 9), colSpec, orientation));

    JButton service = new JButton(Messages.getString("NetworkTab.4"));
    service.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (PMS.get().installWin32Service()) {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.11") + Messages.getString("NetworkTab.12"),
                        Messages.getString("Dialog.Information"), JOptionPane.INFORMATION_MESSAGE);

            } else {
                JOptionPane.showMessageDialog(
                        (JFrame) (SwingUtilities.getWindowAncestor((Component) PMS.get().getFrame())),
                        Messages.getString("NetworkTab.14"), Messages.getString("Dialog.Error"),
                        JOptionPane.ERROR_MESSAGE);
            }
        }
    });

    builder.add(service, FormLayoutUtil.flip(cc.xy(1, 11), colSpec, orientation));

    if (System.getProperty(LooksFrame.START_SERVICE) != null || !Platform.isWindows()) {
        service.setEnabled(false);
    }

    JButton checkForUpdates = new JButton(Messages.getString("NetworkTab.8"));

    checkForUpdates.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            LooksFrame frame = (LooksFrame) PMS.get().getFrame();
            frame.checkForUpdates();
        }
    });

    builder.add(checkForUpdates, FormLayoutUtil.flip(cc.xy(1, 13), colSpec, orientation));

    autoUpdateCheckBox = new JCheckBox(Messages.getString("NetworkTab.9"));
    autoUpdateCheckBox.setContentAreaFilled(false);
    autoUpdateCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setAutoUpdate((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    if (configuration.isAutoUpdate()) {
        autoUpdateCheckBox.setSelected(true);
    }

    builder.add(autoUpdateCheckBox, FormLayoutUtil.flip(cc.xyw(7, 13, 3), colSpec, orientation));

    if (!Build.isUpdatable()) {
        checkForUpdates.setEnabled(false);
        autoUpdateCheckBox.setEnabled(false);
    }

    host = new JTextField(configuration.getServerHostname());
    host.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setHostname(host.getText());
        }
    });

    port = new JTextField(configuration.getServerPort() != 5001 ? "" + configuration.getServerPort() : "");
    port.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            try {
                String p = port.getText();
                if (StringUtils.isEmpty(p)) {
                    p = "5001";
                }
                int ab = Integer.parseInt(p);
                configuration.setServerPort(ab);
            } catch (NumberFormatException nfe) {
                logger.debug("Could not parse port from \"" + port.getText() + "\"");
            }

        }
    });

    cmp = builder.addSeparator(Messages.getString("NetworkTab.22"),
            FormLayoutUtil.flip(cc.xyw(1, 21, 9), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    final KeyedComboBoxModel networkInterfaces = createNetworkInterfacesModel();
    networkinterfacesCBX = new JComboBox(networkInterfaces);
    networkInterfaces.setSelectedKey(configuration.getNetworkInterface());
    networkinterfacesCBX.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                configuration.setNetworkInterface((String) networkInterfaces.getSelectedKey());
            }
        }
    });

    ip_filter = new JTextField(configuration.getIpFilter());
    ip_filter.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            configuration.setIpFilter(ip_filter.getText());
        }
    });

    maxbitrate = new JTextField(configuration.getMaximumBitrate());
    maxbitrate.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            PMS.getConfiguration().setMaximumBitrate(maxbitrate.getText());
        }
    });

    builder.addLabel(Messages.getString("NetworkTab.20"),
            FormLayoutUtil.flip(cc.xy(1, 23), colSpec, orientation));
    builder.add(networkinterfacesCBX, FormLayoutUtil.flip(cc.xyw(3, 23, 7), colSpec, orientation));
    builder.addLabel(Messages.getString("NetworkTab.23"),
            FormLayoutUtil.flip(cc.xy(1, 25), colSpec, orientation));
    builder.add(host, FormLayoutUtil.flip(cc.xyw(3, 25, 7), colSpec, orientation));
    builder.addLabel(Messages.getString("NetworkTab.24"),
            FormLayoutUtil.flip(cc.xy(1, 27), colSpec, orientation));
    builder.add(port, FormLayoutUtil.flip(cc.xyw(3, 27, 7), colSpec, orientation));
    builder.addLabel(Messages.getString("NetworkTab.30"),
            FormLayoutUtil.flip(cc.xy(1, 29), colSpec, orientation));
    builder.add(ip_filter, FormLayoutUtil.flip(cc.xyw(3, 29, 7), colSpec, orientation));
    builder.addLabel(Messages.getString("NetworkTab.35"),
            FormLayoutUtil.flip(cc.xy(1, 31), colSpec, orientation));
    builder.add(maxbitrate, FormLayoutUtil.flip(cc.xyw(3, 31, 7), colSpec, orientation));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.31"),
            FormLayoutUtil.flip(cc.xyw(1, 33, 9), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    newHTTPEngine = new JCheckBox(Messages.getString("NetworkTab.32"));
    newHTTPEngine.setSelected(configuration.isHTTPEngineV2());
    newHTTPEngine.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setHTTPEngineV2((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(newHTTPEngine, FormLayoutUtil.flip(cc.xyw(1, 35, 9), colSpec, orientation));

    preventSleep = new JCheckBox(Messages.getString("NetworkTab.33"));
    preventSleep.setSelected(configuration.isPreventsSleep());
    preventSleep.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setPreventsSleep((e.getStateChange() == ItemEvent.SELECTED));
        }
    });
    builder.add(preventSleep, FormLayoutUtil.flip(cc.xyw(1, 37, 9), colSpec, orientation));

    JCheckBox fdCheckBox = new JCheckBox(Messages.getString("NetworkTab.38"));
    fdCheckBox.setContentAreaFilled(false);
    fdCheckBox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            configuration.setRendererForceDefault((e.getStateChange() == ItemEvent.SELECTED));
        }
    });

    if (configuration.isRendererForceDefault()) {
        fdCheckBox.setSelected(true);
    }

    builder.addLabel(Messages.getString("NetworkTab.36"),
            FormLayoutUtil.flip(cc.xy(1, 39), colSpec, orientation));

    ArrayList<RendererConfiguration> allConfs = RendererConfiguration.getAllRendererConfigurations();
    ArrayList<Object> keyValues = new ArrayList<Object>();
    ArrayList<Object> nameValues = new ArrayList<Object>();
    keyValues.add("");
    nameValues.add(Messages.getString("NetworkTab.37"));

    if (allConfs != null) {
        for (RendererConfiguration renderer : allConfs) {
            if (renderer != null) {
                keyValues.add(renderer.getRendererName());
                nameValues.add(renderer.getRendererName());
            }
        }
    }

    final KeyedComboBoxModel renderersKcbm = new KeyedComboBoxModel(
            (Object[]) keyValues.toArray(new Object[keyValues.size()]),
            (Object[]) nameValues.toArray(new Object[nameValues.size()]));
    renderers = new JComboBox(renderersKcbm);
    renderers.setEditable(false);
    String defaultRenderer = configuration.getRendererDefault();
    renderersKcbm.setSelectedKey(defaultRenderer);

    if (renderers.getSelectedIndex() == -1) {
        renderers.setSelectedIndex(0);
    }

    builder.add(renderers, FormLayoutUtil.flip(cc.xyw(3, 39, 7), colSpec, orientation));

    builder.add(fdCheckBox, FormLayoutUtil.flip(cc.xyw(1, 41, 9), colSpec, orientation));

    cmp = builder.addSeparator(Messages.getString("NetworkTab.34"),
            FormLayoutUtil.flip(cc.xyw(1, 43, 9), colSpec, orientation));
    cmp = (JComponent) cmp.getComponent(0);
    cmp.setFont(cmp.getFont().deriveFont(Font.BOLD));

    pPlugins = new JPanel(new GridLayout());
    builder.add(pPlugins, FormLayoutUtil.flip(cc.xyw(1, 45, 9), colSpec, orientation));

    JPanel panel = builder.getPanel();

    // Apply the orientation to the panel and all components in it
    panel.applyComponentOrientation(orientation);

    JScrollPane scrollPane = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

    return scrollPane;
}

From source file:edu.ku.brc.af.ui.db.TextFieldWithQuery.java

/**
 * /*w w w.  j a v a 2 s .  c om*/
 */
public void createUI() {
    //setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    setLayout(new BorderLayout());
    setOpaque(false);

    textField = new JTextField(10);
    // we are going to handle focus traversal manually
    // so that we can do searches when 'tab' is pressed
    textField.setFocusTraversalKeysEnabled(false);
    setControlSize(textField);

    ImageIcon img = IconManager.getIcon("DropDownArrow", IconManager.IconSize.NonStd); //$NON-NLS-1$
    dbBtn = UIHelper.isMacOS() ? new MacGradiantBtn(img) : new JButton(img);
    dbBtn.setFocusable(false);

    PanelBuilder pb = new PanelBuilder(new FormLayout("f:d:g,p", "f:p:g"), this); //$NON-NLS-1$ //$NON-NLS-2$
    CellConstraints cc = new CellConstraints();

    pb.add(textField, cc.xy(1, 1));
    pb.add(dbBtn, cc.xy(2, 1));

    textField.addKeyListener(new KeyAdapter() {
        @Override
        public void keyReleased(KeyEvent e) {
            if (ignoreTab && e.getKeyCode() == KeyEvent.VK_TAB) {
                ignoreTab = false;
            } else {
                cbxKeyReleased(e);
            }
            super.keyReleased(e);
        }

        @Override
        public void keyPressed(KeyEvent e) {
            if (popupMenu != null && popupMenu.isVisible()) {
                popupMenu.setVisible(false);
            }
            super.keyReleased(e);
        }
    });

    textField.getDocument().addDocumentListener(new DocumentAdaptor() {
        @Override
        protected void changed(DocumentEvent e) {
            prevEnteredText = textField.getText();
            boolean oldWasCleared = wasCleared;
            if (!ignoreDocChange) {
                wasCleared = wasCleared || selectedId != null;

                idList.clear();
                list.clear();
                selectedId = null;
                if (oldWasCleared != wasCleared && wasCleared) {
                    notifyListenersOfChange(
                            StringUtils.isEmpty(prevEnteredText) ? null : TextFieldWithQuery.this);
                }
            }
        }
    });

    StringBuilder sb = new StringBuilder();
    for (String k : keyColumns) {
        String title = k;
        DBFieldInfo fi = tableInfo.getFieldByName(k);
        if (fi != null) {
            title = fi.getTitle();
        }
        if (sb.length() > 0)
            sb.append(", ");
        sb.append(title);
    }
    textField.setToolTipText(UIRegistry.getFormattedResStr("TFWQ_SEARCHES_FLDS", sb.toString()));

    textField.addFocusListener(new FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
            if (e instanceof CausedFocusEvent) {
                switch (((CausedFocusEvent) e).getCause()) {
                case TRAVERSAL:
                case TRAVERSAL_BACKWARD:
                case TRAVERSAL_FORWARD:
                case TRAVERSAL_UP:
                case TRAVERSAL_DOWN:
                    ignoreTab = true;
                }
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            int len = textField.getText().length();
            if (len < 1) {

                setText(""); //$NON-NLS-1$

                ///////////////////////////////////////////////////////////////////////////////////
                // We only want to generate a change event if it once had a value and then it is
                // cleared and the user tabs to a new control. - rods 02/28/08
                ///////////////////////////////////////////////////////////////////////////////////
                if (wasCleared || selectedId != null) {
                    notifyListenersOfChange(TextFieldWithQuery.this);
                }
            }
            textField.setCaretPosition(0);
        }
    });

    dbBtn.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (popupMenu != null && popupMenu.isVisible()) {
                popupMenu.setVisible(false);
            }

            log.debug("currentText: " + currentText);
            doQuery(currentText, currentText, 0);
        }
    });
}

From source file:com.declarativa.interprolog.gui.ListenerWindow.java

public ListenerWindow(AbstractPrologEngine e, boolean autoDisplay) throws IOException {

    try {/*from  www .  j av a 2  s.c  om*/
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(ListenerWindow.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(ListenerWindow.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(ListenerWindow.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(ListenerWindow.class.getName()).log(java.util.logging.Level.SEVERE,
                null, ex);
    }

    //        constructWindowContents();
    initComponents();

    graphComponents();

    /* 
     Forest<String, Integer> forest = new DelegateForest<>();
     forest = new GraphGenerator().createTree(forest);
            
     UpdategraphComponents(forest);
     //ObservableGraph g = new ObservableGraph(new BalloonLayoutDemo().createTree(forest));
     //ObservableGraph g = new ObservableGraph(new GraphGenerator().createTree(forest));
            
     */
    /// super("PrologEngine listener (Swing)");
    if (e != null) {
        engine = e;
    } else {
        throw new IPException("missing Prolog engine");
    }

    String VF = e.getImplementationPeer().visualizationFilename();
    if (engine.getLoadFromJar()) {
        engine.consultFromPackage(VF, ListenerWindow.class);
    } else {
        engine.consultRelative(VF, ListenerWindow.class);
    }
    engine.teachMoreObjects(guiExamples());

    if (engine == null) {
        dispose(); // no interface object permitted!
    } else {
        topLevelCount++;
    }
    debug = engine.isDebug();

    loadedFiles = new Vector();

    constructMenu();

    addWindowListener(this);

    prologInput.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                sendToProlog();
                e.consume();
            }
        }
    });
    //prologOutput.append("Welcome to an InterProlog top level\n" + e.getPrologVersion() + "\n\n");
    prologOutput.append("\n ARG ENGINE v18 ALPHA ");
    prologOutput.append("\t Argument Engine based on WFS \n\n");
    prologOutput.append("\t UIKM Group - Umea University \n\n");
    prologOutput.append("\t {esteban, jcnieves, helena}@cs.umu.se \n\n");

    if (autoDisplay) {
        setVisible(true);
        focusInput();
    }

    /**
     * *******************************************************************************************
     */
    this.setVisible(true);

}

From source file:com.archivas.clienttools.arcmover.gui.panels.ProfilePanel.java

private void initGuiComponents() {
    fileListModel = new FileListTableModel();
    fileList = new FileListTable(fileListModel);
    fileList.addKeyListener(new KeyAdapter() {
        @Override/*  ww w . j av  a  2 s .  c om*/
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                openSelectedFile();
                e.consume();
            }
        }
    });
    fileList.setAutoCreateColumnsFromModel(true);
    fileList.setDropMode(DropMode.ON_OR_INSERT_ROWS);
    fileList.setFillsViewportHeight(true);
    fileList.setGridColor(new Color(-1));

    fileListScrollPane = new JScrollPane(fileList);
    fileListScrollPane.setAutoscrolls(false);
    fileListScrollPane.setBackground(UIManager.getColor("TableHeader.background"));
    fileListScrollPane.setPreferredSize(new Dimension(100, 128));
    fileListScrollPane.setEnabled(false);

    //
    // toolbar
    //

    final JToolBar toolBar1 = new JToolBar();
    toolBar1.setBorderPainted(false);
    toolBar1.setFloatable(false);
    toolBar1.setRollover(true);
    toolBar1.putClientProperty("JToolBar.isRollover", Boolean.TRUE);

    homeDirectoryButton = new JButton();
    homeDirectoryButton.setHorizontalAlignment(2);
    homeDirectoryButton.setIcon(GUIHelper.HOME_ICON);
    homeDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    homeDirectoryButton.setText("");
    homeDirectoryButton.setToolTipText("Go to home directory");
    homeDirectoryButton.setEnabled(false);
    toolBar1.add(homeDirectoryButton);

    refreshButton = new JButton();
    refreshButton.setHorizontalAlignment(2);
    refreshButton.setIcon(new ImageIcon(getClass().getResource("/images/refresh.gif")));
    refreshButton.setMargin(new Insets(3, 3, 3, 3));
    refreshButton.setText("");
    refreshButton.setToolTipText("Refresh current directory listing");
    refreshButton.setEnabled(false);
    toolBar1.add(refreshButton);

    upDirectoryButton = new JButton();
    upDirectoryButton.setHideActionText(false);
    upDirectoryButton.setHorizontalAlignment(2);
    upDirectoryButton.setIcon(GUIHelper.UP_DIR_ICON);
    upDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    upDirectoryButton.setToolTipText("Up");
    upDirectoryButton.setEnabled(false);
    toolBar1.add(upDirectoryButton);

    browseDirectoryButton = new JButton();
    browseDirectoryButton.setHideActionText(false);
    browseDirectoryButton.setHorizontalAlignment(2);
    browseDirectoryButton.setIcon(GUIHelper.DIRECTORY_ICON);
    browseDirectoryButton.setMargin(new Insets(3, 3, 3, 3));
    browseDirectoryButton.setToolTipText(BROWSE_LFS_TEXT);
    browseDirectoryButton.setEnabled(false);
    toolBar1.add(browseDirectoryButton);

    profileModel = new ProfileComboBoxModel();
    profileSelectionCombo = new JComboBox(profileModel);
    profileSelectionCombo.setEnabled(false);
    profileSelectionCombo.setToolTipText("Select a namespace profile");
    profileSelectionCombo.setPrototypeDisplayValue("#");

    pathCombo = new JComboBox();
    pathCombo.setEditable(false);
    pathCombo.setEnabled(false);
    pathCombo.setToolTipText("Current directory path");
    pathCombo.setPrototypeDisplayValue("#");

    sslButton = new JButton();
    sslButton.setAlignmentY(0.0f);
    sslButton.setBorderPainted(false);
    sslButton.setHorizontalAlignment(2);
    sslButton.setHorizontalTextPosition(11);
    sslButton.setIcon(new ImageIcon(getClass().getResource("/images/lockedstate.gif")));
    sslButton.setMargin(new Insets(0, 0, 0, 0));
    sslButton.setMaximumSize(new Dimension(20, 20));
    sslButton.setMinimumSize(new Dimension(20, 20));
    sslButton.setPreferredSize(new Dimension(20, 20));
    sslButton.setText("");
    sslButton.setToolTipText("View certificate");
    sslButton.setEnabled(false);

    //
    // profile and toolbar buttons
    //
    JPanel profileAndToolbarPanel = new FixedHeightPanel();
    profileAndToolbarPanel.setLayout(new BoxLayout(profileAndToolbarPanel, BoxLayout.X_AXIS));
    profileAndToolbarPanel.add(profileSelectionCombo);
    profileAndToolbarPanel.add(Box.createHorizontalStrut(25));
    profileAndToolbarPanel.add(toolBar1);

    //
    // Path & SSLCert button
    //
    JPanel pathPanel = new FixedHeightPanel();
    pathPanel.setLayout(new BoxLayout(pathPanel, BoxLayout.X_AXIS));
    pathCombo.setAlignmentY(CENTER_ALIGNMENT);
    pathPanel.add(pathCombo);
    pathPanel.add(Box.createHorizontalStrut(5));
    sslButton.setAlignmentY(CENTER_ALIGNMENT);
    pathPanel.add(sslButton);

    //
    // Put it all together
    //
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    add(profileAndToolbarPanel);
    add(Box.createVerticalStrut(5));
    add(pathPanel);
    add(Box.createVerticalStrut(5));
    add(fileListScrollPane);
    setBorder(new EmptyBorder(12, 12, 12, 12));
}

From source file:edu.ku.brc.specify.ui.DBObjSearchPanel.java

/**
 * Constructs a search dialog from form infor and from search info.
 * @param viewSetName the viewset name//from   w  ww  .  j a  v  a  2 s  .  c om
 * @param viewName the form name from the viewset
 * @param searchName the search name, this is looked up by name in the "search_config.xml" file
 * @param className the name of the class to be created from the selected results
 * @param idFieldName the name of the field in the clas that is the primary key which is filled in from the search table id
 * @throws HeadlessException an exception
 */
public DBObjSearchPanel(final String fieldName, final String className, final String idFieldName)
        throws HeadlessException {
    super(new BorderLayout());

    this.className = className;
    this.idFieldName = idFieldName;
    this.fieldName = fieldName;

    init();

    searchText = new JTextField(30);
    searchText.addActionListener(doQuery);
    searchText.addKeyListener(new KeyAdapter() {
        public void keyPressed(KeyEvent e) {
            if (searchText.getBackground() != textBGColor) {
                searchText.setBackground(textBGColor);
            }
        }
    });

    PanelBuilder pb = new PanelBuilder(new FormLayout("p,1dlu,p", "p,2dlu,p,2dlu,p"));
    CellConstraints cc = new CellConstraints();

    pb.add(searchText, cc.xy(1, 1));
    pb.add(searchBtn, cc.xy(3, 1));

    add(pb.getPanel(), BorderLayout.NORTH);

    createUI();
}

From source file:com.frostwire.gui.bittorrent.PartialFilesDialog.java

private void setupTextFilter() {
    GridBagConstraints c;//from  w w  w .  ja  v  a  2  s  . c  o m
    _filter = new LabeledTextField("Filter files", 30);
    _filter.setMinimumSize(_filter.getPreferredSize()); // fix odd behavior
    textBasedFilter = new RowFilterExtension(_filter, 2);

    _filter.addKeyListener(new KeyAdapter() {

        @Override
        public void keyReleased(KeyEvent e) {
            if (_filter.getText() == null || _filter.getText().equals("")) {
                _table.setRowSorter(null);
                return;
            }

            _checkBoxToggleAll.setSelected(false);

            TableRowSorter<TorrentTableModel> sorter = new TableRowSorter<TorrentTableModel>(_model);
            sorter.setRowFilter(textBasedFilter);
            _table.setRowSorter(sorter);
        }

    });

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 1.0;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(_filter, c);
}