Example usage for javax.swing JTextField JTextField

List of usage examples for javax.swing JTextField JTextField

Introduction

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

Prototype

public JTextField() 

Source Link

Document

Constructs a new TextField.

Usage

From source file:rhinova.gui.dataentry.link.LinkDataEditPannel.java

private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
    // Generated using JFormDesigner non-commercial license
    label1 = new JLabel();
    label2 = new JLabel();
    lblId = new JLabel();
    label3 = new JLabel();
    txtName = new JTextField();
    label8 = new JLabel();
    txtCapacity = new JTextField();
    label4 = new JLabel();
    txtSurvivalRate = new JTextField();
    label5 = new JLabel();
    comboReserve1 = new JComboBox<>();
    label6 = new JLabel();
    comboReserve2 = new JComboBox<>();

    //======== this ========
    setLayout(new GridBagLayout());
    ((GridBagLayout) getLayout()).columnWidths = new int[] { 54, 0, 0 };
    ((GridBagLayout) getLayout()).rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
    ((GridBagLayout) getLayout()).columnWeights = new double[] { 0.0, 0.0, 1.0E-4 };
    ((GridBagLayout) getLayout()).rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4 };

    //---- label1 ----
    label1.setText("Link Properties");
    label1.setFont(new Font("Tahoma", Font.PLAIN, 16));
    add(label1, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 15, 0), 0, 0));

    //---- label2 ----
    label2.setText("id");
    add(label2, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(lblId, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH,
            new Insets(0, 0, 15, 0), 0, 0));

    //---- label3 ----
    label3.setText("name");
    add(label3, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtName, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label8 ----
    label8.setText("capacity");
    add(label8, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtCapacity, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label4 ----
    label4.setText("survival rate");
    add(label4, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(txtSurvivalRate, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label5 ----
    label5.setText("reserve 1");
    add(label5, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 15, 15), 0, 0));
    add(comboReserve1, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 15, 0), 0, 0));

    //---- label6 ----
    label6.setText("reserve 2");
    add(label6, new GridBagConstraints(0, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.VERTICAL, new Insets(0, 0, 0, 15), 0, 0));
    add(comboReserve2, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
    // JFormDesigner - End of component initialization  //GEN-END:initComponents
}

From source file:qmod.generator.MainWindow.java

@SuppressWarnings("unchecked")
public MainWindow() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setTitle("Quick Mod Generator");

    JLabel lblAuthors = new JLabel("Authors:");

    authorField1 = new JTextField();
    authorField1.setColumns(25);/*from   w w w.  j  av a2 s.  co m*/

    JButton btnGenerateFile = new JButton("Generate File");
    btnGenerateFile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            writeFiles();
        }
    });

    authCombo1.setFont(new Font("Dialog", Font.BOLD, 8));
    authCombo1.setModel(
            (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" }));
    authCombo1.setSelectedIndex(0);

    authCombo2.setFont(new Font("Dialog", Font.BOLD, 8));
    authCombo2.setModel(
            (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" }));
    authCombo2.setSelectedIndex(0);

    authorField2 = new JTextField();
    authorField2.setColumns(25);

    authCombo3.setFont(new Font("Dialog", Font.BOLD, 8));
    authCombo3.setModel(
            (ComboBoxModel<Object>) new DefaultComboBoxModel<Object>(new String[] { "Author", "Maintainer" }));
    authCombo3.setSelectedIndex(0);

    authorField3 = new JTextField();
    authorField3.setColumns(25);

    JLabel lblCategories = new JLabel("Categories:");

    categoriesField = new JTextField();
    categoriesField.setColumns(10);

    JLabel lblDescription = new JLabel("Description:");

    JEditorPane descriptionField = new JEditorPane();

    JLabel lblLicense = new JLabel("License:");

    licenseField = new JTextField();
    licenseField.setColumns(10);
    GroupLayout groupLayout = new GroupLayout(getContentPane());
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addContainerGap()
                    .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout
                            .createSequentialGroup()
                            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout
                                    .createParallelGroup(Alignment.TRAILING).addComponent(btnGenerateFile)
                                    .addGroup(groupLayout.createSequentialGroup().addComponent(lblAuthors)
                                            .addPreferredGap(ComponentPlacement.RELATED).addGroup(groupLayout
                                                    .createParallelGroup(Alignment.LEADING).addGroup(groupLayout
                                                            .createSequentialGroup()
                                                            .addComponent(
                                                                    authCombo2, GroupLayout.PREFERRED_SIZE, 81,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addGap(6).addComponent(authorField2,
                                                                    GroupLayout.PREFERRED_SIZE, 192,
                                                                    GroupLayout.PREFERRED_SIZE))
                                                    .addGroup(groupLayout.createSequentialGroup().addComponent(
                                                            authCombo1, GroupLayout.PREFERRED_SIZE, 81,
                                                            GroupLayout.PREFERRED_SIZE).addPreferredGap(
                                                                    ComponentPlacement.RELATED)
                                                            .addComponent(
                                                                    authorField1, GroupLayout.DEFAULT_SIZE, 264,
                                                                    Short.MAX_VALUE))
                                                    .addGroup(groupLayout.createSequentialGroup()
                                                            .addComponent(authCombo3,
                                                                    GroupLayout.PREFERRED_SIZE, 81,
                                                                    GroupLayout.PREFERRED_SIZE)
                                                            .addGap(6).addGroup(groupLayout.createParallelGroup(
                                                                    Alignment.LEADING).addComponent(
                                                                            descriptionField)
                                                                    .addGroup(groupLayout
                                                                            .createParallelGroup(
                                                                                    Alignment.LEADING, false)
                                                                            .addComponent(categoriesField)
                                                                            .addComponent(
                                                                                    authorField3,
                                                                                    GroupLayout.DEFAULT_SIZE,
                                                                                    192, Short.MAX_VALUE))
                                                                    .addGroup(groupLayout
                                                                            .createSequentialGroup()
                                                                            .addComponent(licenseField,
                                                                                    GroupLayout.DEFAULT_SIZE,
                                                                                    192, Short.MAX_VALUE)
                                                                            .addPreferredGap(
                                                                                    ComponentPlacement.RELATED)))))))
                                    .addComponent(lblCategories).addComponent(lblDescription))
                            .addGap(84))
                            .addGroup(groupLayout.createSequentialGroup().addComponent(lblLicense)
                                    .addContainerGap(377, Short.MAX_VALUE)))));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING).addGroup(groupLayout
            .createSequentialGroup().addContainerGap()
            .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE).addComponent(lblAuthors)
                    .addComponent(authorField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(authCombo1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(authCombo2, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGroup(groupLayout.createSequentialGroup().addGap(3).addComponent(authorField2,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addComponent(authCombo3, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addGroup(groupLayout.createSequentialGroup().addGap(3).addComponent(authorField3,
                            GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblCategories)
                    .addComponent(categoriesField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(ComponentPlacement.RELATED)
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING).addComponent(lblDescription)
                    .addComponent(descriptionField, GroupLayout.PREFERRED_SIZE, 100,
                            GroupLayout.PREFERRED_SIZE))
            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addGroup(groupLayout.createSequentialGroup().addGap(9).addComponent(lblLicense))
                    .addGroup(groupLayout.createSequentialGroup().addPreferredGap(ComponentPlacement.RELATED)
                            .addComponent(licenseField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                                    GroupLayout.PREFERRED_SIZE)))
            .addPreferredGap(ComponentPlacement.RELATED, 322, Short.MAX_VALUE).addComponent(btnGenerateFile)
            .addContainerGap()));
    getContentPane().setLayout(groupLayout);

    JMenuBar menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    JMenu mnFile = new JMenu("File");
    mnFile.setMnemonic('F');
    menuBar.add(mnFile);

    JMenuItem mntmNew = new JMenuItem("New");
    mntmNew.setMnemonic(KeyEvent.VK_N);
    mnFile.add(mntmNew);

    JMenuItem mntmOpen = new JMenuItem("Open");
    mnFile.add(mntmOpen);

    JMenuItem mntmSave = new JMenuItem("Save");
    mnFile.add(mntmSave);

    JMenuItem mntmExit = new JMenuItem("Exit");
    mntmExit.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            System.exit(0);
        }
    });
    mntmExit.setMnemonic(KeyEvent.VK_X);
    mnFile.add(mntmExit);
}

From source file:client.ui.UploadFileWindow.java

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor./*from   w ww.ja  v  a  2 s .c o  m*/
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {

    filePathLabel = new JLabel();
    pathField = new JTextField();
    pathButton = new JButton();
    filenameLabel = new JLabel();
    filenameField = new JTextField();
    confirmButton = new JButton();
    filenameTip = new JLabel();

    FormListener formListener = new FormListener();

    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setTitle("");
    setResizable(false);

    filePathLabel.setFont(new Font("", 0, 12)); // NOI18N
    filePathLabel.setText("");

    pathField.setFont(new Font("", 0, 12)); // NOI18N

    pathButton.setFont(new Font("", 0, 12)); // NOI18N
    pathButton.setText("?");
    pathButton.addActionListener(formListener);

    filenameLabel.setFont(new Font("", 0, 12)); // NOI18N
    filenameLabel.setText("??");

    filenameField.setFont(new Font("", 0, 12)); // NOI18N

    confirmButton.setFont(new Font("", 0, 12)); // NOI18N
    confirmButton.setText("");
    confirmButton.addActionListener(formListener);

    filenameTip.setFont(new Font("", 0, 12)); // NOI18N
    filenameTip.setForeground(new Color(153, 153, 153));
    filenameTip.setText("???");

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
            .createSequentialGroup()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
                    .createSequentialGroup().addGap(19, 19, 19)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(filePathLabel).addComponent(filenameLabel))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING)
                            .addComponent(filenameTip)
                            .addGroup(layout.createSequentialGroup()
                                    .addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING, false)
                                            .addComponent(pathField, GroupLayout.DEFAULT_SIZE, 213,
                                                    Short.MAX_VALUE)
                                            .addComponent(filenameField))
                                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(pathButton))))
                    .addGroup(layout.createSequentialGroup().addGap(167, 167, 167).addComponent(confirmButton)))
            .addContainerGap(33, Short.MAX_VALUE)));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout
            .createSequentialGroup().addContainerGap()
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(filePathLabel)
                    .addComponent(pathField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addComponent(pathButton))
            .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
            .addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(filenameLabel)
                    .addComponent(filenameField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(filenameTip)
            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 19, Short.MAX_VALUE)
            .addComponent(confirmButton).addContainerGap()));

    pack();
}

From source file:layout.Find.java

public Find() {
    JLabel label = new JLabel("Find What:");
    ;/* ww w.  jav  a2 s.  c  om*/
    JTextField textField = new JTextField();
    JCheckBox caseCheckBox = new JCheckBox("Match Case");
    JCheckBox wrapCheckBox = new JCheckBox("Wrap Around");
    JCheckBox wholeCheckBox = new JCheckBox("Whole Words");
    JCheckBox backCheckBox = new JCheckBox("Search Backwards");
    JButton findButton = new JButton("Find");
    JButton cancelButton = new JButton("Cancel");

    // remove redundant default border of check boxes - they would hinder
    // correct spacing and aligning (maybe not needed on some look and feels)
    caseCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wrapCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wholeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    backCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(label)
            .addGroup(layout.createParallelGroup(LEADING).addComponent(textField)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(LEADING).addComponent(caseCheckBox)
                                    .addComponent(wholeCheckBox))
                            .addGroup(layout.createParallelGroup(LEADING).addComponent(wrapCheckBox)
                                    .addComponent(backCheckBox))))
            .addGroup(layout.createParallelGroup(LEADING).addComponent(findButton).addComponent(cancelButton)));

    layout.linkSize(SwingConstants.HORIZONTAL, findButton, cancelButton);

    layout.setVerticalGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(BASELINE).addComponent(label).addComponent(textField)
                    .addComponent(findButton))
            .addGroup(layout.createParallelGroup(LEADING)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(BASELINE).addComponent(caseCheckBox)
                                    .addComponent(wrapCheckBox))
                            .addGroup(layout.createParallelGroup(BASELINE).addComponent(wholeCheckBox)
                                    .addComponent(backCheckBox)))
                    .addComponent(cancelButton)));

    setTitle("Find");
    pack();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}

From source file:TextComponentTest.java

public TextComponentFrame() {
    setTitle("TextComponentTest");
    setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);

    final JTextField textField = new JTextField();
    final JPasswordField passwordField = new JPasswordField();

    JPanel northPanel = new JPanel();
    northPanel.setLayout(new GridLayout(2, 2));
    northPanel.add(new JLabel("User name: ", SwingConstants.RIGHT));
    northPanel.add(textField);/*  ww w  .j a  v  a  2 s.  c om*/
    northPanel.add(new JLabel("Password: ", SwingConstants.RIGHT));
    northPanel.add(passwordField);

    add(northPanel, BorderLayout.NORTH);

    final JTextArea textArea = new JTextArea(8, 40);
    JScrollPane scrollPane = new JScrollPane(textArea);

    add(scrollPane, BorderLayout.CENTER);

    // add button to append text into the text area

    JPanel southPanel = new JPanel();

    JButton insertButton = new JButton("Insert");
    southPanel.add(insertButton);
    insertButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            textArea.append("User name: " + textField.getText() + " Password: "
                    + new String(passwordField.getPassword()) + "\n");
        }
    });

    add(southPanel, BorderLayout.SOUTH);

    // add a text area with scroll bars

}

From source file:ExpenseReport.java

public ExpenseReport() {
    super("Expense Report");
    setSize(570, 200);//from ww w . j a  va  2 s. c o  m

    m_data = new ExpenseReportData(this);

    m_table = new JTable();
    m_table.setAutoCreateColumnsFromModel(false);
    m_table.setModel(m_data);
    m_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    for (int k = 0; k < ExpenseReportData.m_columns.length; k++) {
        TableCellRenderer renderer;
        if (k == ExpenseReportData.COL_APPROVED)
            renderer = new CheckCellRenderer();
        else {
            DefaultTableCellRenderer textRenderer = new DefaultTableCellRenderer();
            textRenderer.setHorizontalAlignment(ExpenseReportData.m_columns[k].m_alignment);
            renderer = textRenderer;
        }

        TableCellEditor editor;

        if (k == ExpenseReportData.COL_CATEGORY)
            editor = new DefaultCellEditor(new JComboBox(ExpenseReportData.CATEGORIES));
        else if (k == ExpenseReportData.COL_APPROVED)
            editor = new DefaultCellEditor(new JCheckBox());
        else
            editor = new DefaultCellEditor(new JTextField());

        TableColumn column = new TableColumn(k, ExpenseReportData.m_columns[k].m_width, renderer, editor);
        m_table.addColumn(column);
    }

    JTableHeader header = m_table.getTableHeader();
    header.setUpdateTableInRealTime(false);

    JScrollPane ps = new JScrollPane();
    ps.setSize(550, 150);
    ps.getViewport().add(m_table);
    getContentPane().add(ps, BorderLayout.CENTER);

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

    ImageIcon penny = new ImageIcon("penny.gif");
    m_title = new JLabel("Total: $", penny, JButton.LEFT);
    m_title.setForeground(Color.black);
    m_title.setAlignmentY(0.5f);
    p.add(m_title);
    p.add(Box.createHorizontalGlue());

    JButton bt = new JButton("Insert before");
    bt.setMnemonic('b');
    bt.setAlignmentY(0.5f);
    ActionListener lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = m_table.getSelectedRow();
            m_data.insert(row);
            m_table.tableChanged(
                    new TableModelEvent(m_data, row, row, TableModelEvent.ALL_COLUMNS, TableModelEvent.INSERT));
            m_table.repaint();
        }
    };
    bt.addActionListener(lst);
    p.add(bt);

    bt = new JButton("Insert after");
    bt.setMnemonic('a');
    bt.setAlignmentY(0.5f);
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = m_table.getSelectedRow();
            m_data.insert(row + 1);
            m_table.tableChanged(new TableModelEvent(m_data, row + 1, row + 1, TableModelEvent.ALL_COLUMNS,
                    TableModelEvent.INSERT));
            m_table.repaint();
        }
    };
    bt.addActionListener(lst);
    p.add(bt);

    bt = new JButton("Delete row");
    bt.setMnemonic('d');
    bt.setAlignmentY(0.5f);
    lst = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int row = m_table.getSelectedRow();
            if (m_data.delete(row)) {
                m_table.tableChanged(new TableModelEvent(m_data, row, row, TableModelEvent.ALL_COLUMNS,
                        TableModelEvent.INSERT));
                m_table.repaint();
                calcTotal();
            }
        }
    };
    bt.addActionListener(lst);
    p.add(bt);

    getContentPane().add(p, BorderLayout.SOUTH);

    calcTotal();

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    setVisible(true);
}

From source file:lookandfeel.SynthDialog.java

public SynthDialog() {
    JLabel label = new JLabel("Find What:");
    ;//from   w w  w. j  ava 2s .c  o m
    JTextField textField = new JTextField();
    JCheckBox caseCheckBox = new JCheckBox("Match Case");
    JCheckBox wrapCheckBox = new JCheckBox("Wrap Around");
    JCheckBox wholeCheckBox = new JCheckBox("Whole Words");
    JCheckBox backCheckBox = new JCheckBox("Search Backwards");
    JButton findButton = new JButton("Find");
    JButton cancelButton = new JButton("Cancel");

    // remove redundant default border of check boxes - they would hinder
    // correct spacing and aligning (maybe not needed on some look and feels)
    caseCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wrapCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wholeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    backCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(layout.createSequentialGroup().addComponent(label)
            .addGroup(layout.createParallelGroup(LEADING).addComponent(textField)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(LEADING).addComponent(caseCheckBox)
                                    .addComponent(wholeCheckBox))
                            .addGroup(layout.createParallelGroup(LEADING).addComponent(wrapCheckBox)
                                    .addComponent(backCheckBox))))
            .addGroup(layout.createParallelGroup(LEADING).addComponent(findButton).addComponent(cancelButton)));

    layout.linkSize(SwingConstants.HORIZONTAL, findButton, cancelButton);

    layout.setVerticalGroup(layout.createSequentialGroup()
            .addGroup(layout.createParallelGroup(BASELINE).addComponent(label).addComponent(textField)
                    .addComponent(findButton))
            .addGroup(layout.createParallelGroup(LEADING)
                    .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(BASELINE).addComponent(caseCheckBox)
                                    .addComponent(wrapCheckBox))
                            .addGroup(layout.createParallelGroup(BASELINE).addComponent(wholeCheckBox)
                                    .addComponent(backCheckBox)))
                    .addComponent(cancelButton)));

    setTitle("Find");
    pack();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}

From source file:com.game.ui.views.UserDialog.java

public UserDialog(String message, JFrame frame) {
    setLayout(new BorderLayout(5, 5));
    setModalityType(ModalityType.APPLICATION_MODAL);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    setResizable(false);/*w  w  w .j  a v a 2s  .c  o m*/
    ImageIcon icon = null;
    try {
        icon = GameUtils.shrinkImage("warning.gif", 30, 30);
    } catch (IOException e) {
        System.out.println("Dialog : showDialogForMap(): Exception occured :" + e);
        e.printStackTrace();
    }
    JPanel panel = new JPanel();
    JLabel label = new JLabel(icon);
    panel.setLayout(new FlowLayout(FlowLayout.LEFT));
    label.setText(message);
    label.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    label.setHorizontalAlignment(0);
    panel.add(label);
    add(panel, BorderLayout.NORTH);
    JPanel contentPanel = new JPanel();
    contentPanel.setLayout(new BoxLayout(contentPanel, BoxLayout.Y_AXIS));
    txt = new JTextField();
    txt.setPreferredSize(new Dimension(150, 30));
    txt.setAlignmentX(.5f);
    txt.setMaximumSize(new Dimension(150, 30));
    contentPanel.add(txt);
    contentPanel.add(Box.createVerticalStrut(10));
    JButton btn = new JButton("Submit.");
    btn.setAlignmentX(.5f);
    btn.setPreferredSize(new Dimension(50, 25));
    btn.addActionListener(this);
    validationMess = new JLabel("All fields are mandatory");
    validationMess.setVisible(false);
    validationMess.setForeground(Color.red);
    validationMess.setAlignmentX(.5f);
    contentPanel.add(btn);
    contentPanel.add(Box.createVerticalStrut(10));
    contentPanel.add(validationMess);
    contentPanel.add(Box.createVerticalGlue());
    add(contentPanel, BorderLayout.CENTER);
    pack();
    setSize(new Dimension(300, 200));
    setLocationRelativeTo(frame);
    setVisible(true);
}

From source file:lookandfeel.SynthDialog.java

public SynthDialog() {
   JLabel label = new JLabel("Find What:");;
    JTextField textField = new JTextField();
    JCheckBox caseCheckBox = new JCheckBox("Match Case");
    JCheckBox wrapCheckBox = new JCheckBox("Wrap Around");
    JCheckBox wholeCheckBox = new JCheckBox("Whole Words");
    JCheckBox backCheckBox = new JCheckBox("Search Backwards");
    JButton findButton = new JButton("Find");
    JButton cancelButton = new JButton("Cancel");

    // remove redundant default border of check boxes - they would hinder
    // correct spacing and aligning (maybe not needed on some look and feels)
    caseCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wrapCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    wholeCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    backCheckBox.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));

    GroupLayout layout = new GroupLayout(getContentPane());
    getContentPane().setLayout(layout);/* www.  ja  v  a 2s  . c o m*/
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    layout.setHorizontalGroup(layout.createSequentialGroup()
        .addComponent(label)
        .addGroup(layout.createParallelGroup(LEADING)
            .addComponent(textField)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(LEADING)
                    .addComponent(caseCheckBox)
                    .addComponent(wholeCheckBox))
                .addGroup(layout.createParallelGroup(LEADING)
                    .addComponent(wrapCheckBox)
                    .addComponent(backCheckBox))))
        .addGroup(layout.createParallelGroup(LEADING)
            .addComponent(findButton)
            .addComponent(cancelButton))
    );
       
    layout.linkSize(SwingConstants.HORIZONTAL, findButton, cancelButton);

    layout.setVerticalGroup(layout.createSequentialGroup()
        .addGroup(layout.createParallelGroup(BASELINE)
            .addComponent(label)
            .addComponent(textField)
            .addComponent(findButton))
        .addGroup(layout.createParallelGroup(LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(BASELINE)
                    .addComponent(caseCheckBox)
                    .addComponent(wrapCheckBox))
                .addGroup(layout.createParallelGroup(BASELINE)
                    .addComponent(wholeCheckBox)
                    .addComponent(backCheckBox)))
            .addComponent(cancelButton))
    );

    setTitle("Find");
    pack();
    setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}

From source file:com.github.thebigs.foscam.recorder.RecorderGUI.java

public RecorderGUI() {
    super();//w w w.  ja va2s .com
    getContentPane().setLayout(new MigLayout("", "[][131.00,grow][335.00,grow][grow][]", "[][][][grow][]"));

    lblCamName = new JLabel("Cam Name:");
    getContentPane().add(lblCamName, "flowx,cell 1 0,alignx right");

    txtCamName = new JTextField();
    getContentPane().add(txtCamName, "cell 2 0,growx");
    txtCamName.setColumns(10);

    JLabel lblCamUrl = new JLabel("Cam URL:");
    getContentPane().add(lblCamUrl, "flowx,cell 1 1,alignx right");

    txtCamUrl = new JTextField();
    getContentPane().add(txtCamUrl, "cell 2 1,growx");
    txtCamUrl.setColumns(10);

    btnConnect = new JButton("Connect");
    getContentPane().add(btnConnect, "cell 3 2");

    btnConnect.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            // Button says "Connect"
            if (connect) {
                if (recorder != null) {
                    recorder.shutdown();
                    recorderThread.interrupt();
                }
                camName = txtCamName.getText();
                if (StringUtils.isBlank(camName)) {
                    camName = "defaultCamera";
                }
                camUrl = txtCamUrl.getText();
                if (StringUtils.isBlank(camUrl)) {
                    // TODO: dialog this
                    System.err.println("Cam url is blank.");
                } else {
                    recorder = new Recorder(camUrl, camName, "recordings", 2L, 20L);

                    recorder.addWebCamImageListener(gui);
                    recorderThread = new Thread(new Runnable() {
                        @Override
                        public void run() {
                            recorder.run();
                        }
                    }, "Recorder thread");
                    recorderThread.start();
                    btnConnect.setText("Disconnect");
                    connect = false;
                }
            }
            // Button says "Disconnect"
            else {
                if (recorder != null) {
                    recorder.shutdown();
                    recorderThread.interrupt();
                }
                btnConnect.setText("Connect");
                connect = true;
            }
        }
    });

    JPanel panel = new JPanel();
    getContentPane().add(panel, "cell 1 3 3 1,grow");

    imageArea = new JLabel();
    panel.add(imageArea);
}