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:FileTree3.java

public FileTree3() {
    super("Directories Tree [Tool Tips]");
    setSize(400, 300);//w  w w  .  j  a va 2 s .  c  om

    DefaultMutableTreeNode top = new DefaultMutableTreeNode(new IconData(ICON_COMPUTER, null, "Computer"));

    DefaultMutableTreeNode node;
    File[] roots = File.listRoots();
    for (int k = 0; k < roots.length; k++) {
        node = new DefaultMutableTreeNode(new IconData(ICON_DISK, null, new FileNode(roots[k])));
        top.add(node);
        node.add(new DefaultMutableTreeNode(new Boolean(true)));
    }

    m_model = new DefaultTreeModel(top);
    // NEW
    m_tree = new JTree(m_model) {
        public String getToolTipText(MouseEvent ev) {
            if (ev == null)
                return null;
            TreePath path = m_tree.getPathForLocation(ev.getX(), ev.getY());
            if (path != null) {
                FileNode fnode = getFileNode(getTreeNode(path));
                if (fnode == null)
                    return null;
                File f = fnode.getFile();
                return (f == null ? null : f.getPath());
            }
            return null;
        }
    };
    ToolTipManager.sharedInstance().registerComponent(m_tree);

    m_tree.putClientProperty("JTree.lineStyle", "Angled");

    TreeCellRenderer renderer = new IconCellRenderer();
    m_tree.setCellRenderer(renderer);

    m_tree.addTreeExpansionListener(new DirExpansionListener());

    m_tree.addTreeSelectionListener(new DirSelectionListener());

    m_tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    m_tree.setShowsRootHandles(true);
    m_tree.setEditable(false);

    JScrollPane s = new JScrollPane();
    s.getViewport().add(m_tree);
    getContentPane().add(s, BorderLayout.CENTER);

    m_display = new JTextField();
    m_display.setEditable(false);
    getContentPane().add(m_display, BorderLayout.NORTH);

    m_popup = new JPopupMenu();
    m_action = new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
            if (m_clickedPath == null)
                return;
            if (m_tree.isExpanded(m_clickedPath))
                m_tree.collapsePath(m_clickedPath);
            else
                m_tree.expandPath(m_clickedPath);
        }
    };
    m_popup.add(m_action);
    m_popup.addSeparator();

    Action a1 = new AbstractAction("Delete") {
        public void actionPerformed(ActionEvent e) {
            m_tree.repaint();
            JOptionPane.showMessageDialog(FileTree3.this, "Delete option is not implemented", "Info",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    };
    m_popup.add(a1);

    Action a2 = new AbstractAction("Rename") {
        public void actionPerformed(ActionEvent e) {
            m_tree.repaint();
            JOptionPane.showMessageDialog(FileTree3.this, "Rename option is not implemented", "Info",
                    JOptionPane.INFORMATION_MESSAGE);
        }
    };
    m_popup.add(a2);
    m_tree.add(m_popup);
    m_tree.addMouseListener(new PopupTrigger());

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

    setVisible(true);
}

From source file:com.sun.jersey.client.apache.config.DefaultCredentialsProvider.java

public Credentials getCredentials(AuthScheme scheme, String host, int port, boolean proxy)
        throws CredentialsNotAvailableException {
    if (scheme == null) {
        return null;
    }//from   w ww. ja  v a  2s.com

    try {
        JTextField userField = new JTextField();
        JPasswordField passwordField = new JPasswordField();
        int response;

        if (scheme instanceof NTLMScheme) {
            JTextField domainField = new JTextField();
            Object[] msg = { host + ":" + port + " requires Windows authentication", "Domain", domainField,
                    "User Name", userField, "Password", passwordField };
            response = JOptionPane.showConfirmDialog(null, msg, "Authenticate", JOptionPane.OK_CANCEL_OPTION);

            if ((response == JOptionPane.CANCEL_OPTION) || (response == JOptionPane.CLOSED_OPTION)) {
                throw new CredentialsNotAvailableException("User cancled windows authentication.");
            }

            return new NTCredentials(userField.getText(), new String(passwordField.getPassword()), host,
                    domainField.getText());

        } else if (scheme instanceof RFC2617Scheme) {
            Object[] msg = {
                    host + ":" + port + " requires authentication with the realm '" + scheme.getRealm() + "'",
                    "User Name", userField, "Password", passwordField };

            response = JOptionPane.showConfirmDialog(null, msg, "Authenticate", JOptionPane.OK_CANCEL_OPTION);

            if ((response == JOptionPane.CANCEL_OPTION) || (response == JOptionPane.CLOSED_OPTION)) {
                throw new CredentialsNotAvailableException("User cancled windows authentication.");
            }

            return new UsernamePasswordCredentials(userField.getText(),
                    new String(passwordField.getPassword()));

        } else {

            throw new CredentialsNotAvailableException(
                    "Unsupported authentication scheme: " + scheme.getSchemeName());

        }
    } catch (IOException ioe) {

        throw new CredentialsNotAvailableException(ioe.getMessage(), ioe);

    }
}

From source file:ca.sfu.federation.viewer.propertysheet.AssemblyPropertySheet.java

/** 
 * AssemblyPropertySheet constructor/* w  w  w . j  av  a 2  s .c o  m*/
 */
public AssemblyPropertySheet() {
    lblINamedObject = new JLabel();
    lblName = new JLabel();
    lblDescription = new JLabel();
    lblCanonicalName = new JLabel();
    lblClass = new JLabel();
    lblParentContext = new JLabel();
    lblX = new JLabel();
    lblY = new JLabel();
    lblZ = new JLabel();
    jtfClass = new JTextField();
    jtfName = new JTextField();
    jtfCanonicalName = new JTextField();
    jtfDescription = new JTextField();
    jtfParentContext = new JTextField();
    jtfX = new JTextField();
    jtfY = new JTextField();
    jtfZ = new JTextField();

    lblINamedObject.setFont(new java.awt.Font("Tahoma", 0, 14));
    lblINamedObject.setText("jLabel1");
    lblName.setText("Name");
    lblDescription.setText("Description");
    lblCanonicalName.setText("Canonical Name");
    lblClass.setText("Class");
    lblX.setText("X Coordinate");
    lblY.setText("Y Coordinate");
    lblZ.setText("Z Coordinate");
    lblParentContext.setText("Parent Context");

    jtfCanonicalName.setEditable(false);
    jtfClass.setEditable(false);
    jtfParentContext.setEditable(false);

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout
                    .createSequentialGroup().addContainerGap().add(
                            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(lblINamedObject)
                                    .add(layout
                                            .createSequentialGroup().add(layout
                                                    .createParallelGroup(
                                                            org.jdesktop.layout.GroupLayout.LEADING)
                                                    .add(lblCanonicalName).add(lblClass).add(lblName).add(
                                                            lblDescription)
                                                    .add(lblParentContext).add(lblX).add(lblZ).add(lblY))
                                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                            .add(layout
                                                    .createParallelGroup(
                                                            org.jdesktop.layout.GroupLayout.LEADING)
                                                    .add(jtfName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            221, Short.MAX_VALUE)
                                                    .add(jtfClass, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            221, Short.MAX_VALUE)
                                                    .add(jtfDescription,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                                            Short.MAX_VALUE)
                                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout
                                                            .createSequentialGroup()
                                                            .addPreferredGap(
                                                                    org.jdesktop.layout.LayoutStyle.RELATED)
                                                            .add(jtfCanonicalName,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE))
                                                    .add(jtfParentContext,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                                            Short.MAX_VALUE)
                                                    .add(jtfX, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            221, Short.MAX_VALUE)
                                                    .add(jtfY, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            221, Short.MAX_VALUE)
                                                    .add(jtfZ, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                            221, Short.MAX_VALUE))))
                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap().add(lblINamedObject)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfClass, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblClass))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblName))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblCanonicalName)
                            .add(jtfCanonicalName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblDescription).add(jtfDescription,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblParentContext)
                            .add(jtfParentContext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(lblX).add(
                            jtfX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblY))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfZ, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblZ))
                    .addContainerGap(64, Short.MAX_VALUE)));

    // disable non editable fields
    this.jtfCanonicalName.setEditable(false);
    this.jtfClass.setEditable(false);
    this.jtfParentContext.setEditable(false);

    // set field values
    this.setValues();

    // add action listeners
    jtfName.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfNameActionListener(evt);
        }
    });
    jtfDescription.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfDescriptionActionListener(evt);
        }
    });
    jtfX.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfXActionListener(evt);
        }
    });
    jtfY.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfYActionListener(evt);
        }
    });
    jtfZ.addActionListener(new java.awt.event.ActionListener() {
        @Override
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfZActionListener(evt);
        }
    });
}

From source file:DecimalFormatDemo.java

public DecimalFormatDemo() {

    availableLocales = new LocaleGroup();
    inputFormatter = NumberFormat.getNumberInstance();

    String[] patternExamples = { "##.##", "###,###.##", "##,##,##.##", "#", "000,000.0000", "##.0000",
            "'hello'###.##" };

    currentPattern = patternExamples[0];

    // Set up the UI for entering a number.
    JLabel numberLabel = new JLabel("Enter the number to format:");
    numberLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JTextField numberField = new JTextField();
    numberField.setEditable(true);//w ww .  j av  a 2  s.com
    numberField.setAlignmentX(Component.LEFT_ALIGNMENT);
    NumberListener numberListener = new NumberListener();
    numberField.addActionListener(numberListener);

    // Set up the UI for selecting a pattern.
    JLabel patternLabel1 = new JLabel("Enter the pattern string or");
    JLabel patternLabel2 = new JLabel("select one from the list:");
    patternLabel1.setAlignmentX(Component.LEFT_ALIGNMENT);
    patternLabel2.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox patternList = new JComboBox(patternExamples);
    patternList.setSelectedIndex(0);
    patternList.setEditable(true);
    patternList.setAlignmentX(Component.LEFT_ALIGNMENT);
    PatternListener patternListener = new PatternListener();
    patternList.addActionListener(patternListener);

    // Set up the UI for selecting a locale.
    JLabel localeLabel = new JLabel("Select a Locale from the list:");
    localeLabel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JComboBox localeList = new JComboBox(availableLocales.getStrings());
    localeList.setSelectedIndex(0);
    localeList.setAlignmentX(Component.LEFT_ALIGNMENT);
    LocaleListener localeListener = new LocaleListener();
    localeList.addActionListener(localeListener);

    // Create the UI for displaying result.
    JLabel resultLabel = new JLabel("Result", JLabel.LEFT);
    resultLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
    result = new JLabel(" ");
    result.setForeground(Color.black);
    result.setAlignmentX(Component.LEFT_ALIGNMENT);
    result.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLineBorder(Color.black),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    // Lay out everything
    JPanel numberPanel = new JPanel();
    numberPanel.setLayout(new GridLayout(0, 1));
    numberPanel.add(numberLabel);
    numberPanel.add(numberField);

    JPanel patternPanel = new JPanel();
    patternPanel.setLayout(new BoxLayout(patternPanel, BoxLayout.Y_AXIS));
    patternPanel.add(patternLabel1);
    patternPanel.add(patternLabel2);
    patternPanel.add(patternList);

    JPanel localePanel = new JPanel();
    localePanel.setLayout(new BoxLayout(localePanel, BoxLayout.Y_AXIS));
    localePanel.add(localeLabel);
    localePanel.add(localeList);

    JPanel resultPanel = new JPanel();
    resultPanel.setLayout(new GridLayout(0, 1));
    resultPanel.add(resultLabel);
    resultPanel.add(result);

    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    patternPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    numberPanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    localePanel.setAlignmentX(Component.CENTER_ALIGNMENT);
    resultPanel.setAlignmentX(Component.CENTER_ALIGNMENT);

    add(numberPanel);
    add(Box.createVerticalStrut(10));
    add(patternPanel);
    add(Box.createVerticalStrut(10));
    add(localePanel);
    add(Box.createVerticalStrut(10));
    add(resultPanel);

    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    reformat();
    numberField.setText(result.getText());

}

From source file:com.opendoorlogistics.core.utils.ui.FileBrowserPanel.java

private static JTextField createTextField(String initialFilename,
        final FilenameChangeListener filenameChangeListener) {
    JTextField textField = new JTextField();
    if (initialFilename != null) {
        textField.setText(initialFilename);
    }// ww w.j  av  a 2  s .c  o  m

    if (filenameChangeListener != null) {
        textField.getDocument().addDocumentListener(new DocumentListener() {

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

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

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

            private void fire() {
                filenameChangeListener.filenameChanged(textField.getText());
            }
        });
    }
    return textField;
}

From source file:ca.sfu.federation.viewer.propertysheet.LinePropertySheet.java

/**
 * ParametricModelSheet constructor.//  ww  w.j a  v a2s.  c o  m
 */
public LinePropertySheet() {
    lblINamedObject = new JLabel();
    lblName = new JLabel();
    lblDescription = new JLabel();
    jtfClass = new JTextField();
    jtfName = new JTextField();
    jtfCanonicalName = new JTextField();
    lblCanonicalName = new JLabel();
    lblClass = new JLabel();
    jtfDescription = new JTextField();
    lblParentContext = new JLabel();
    jtfParentContext = new JTextField();
    lblStartPoint = new JLabel();
    lblMidPoint = new JLabel();
    lblEndPoint = new JLabel();
    jtfStartPoint = new JTextField();
    jtfMidPoint = new JTextField();
    jtfEndPoint = new JTextField();
    lblUpdateMethod = new JLabel();
    jcbUpdateMethod = new JComboBox();
    jspUpdateMethodInputs = new JPanel();
    lblLength = new JLabel();
    jtfLength = new JTextField();
    lblDirection = new javax.swing.JLabel();
    jtfDirection = new javax.swing.JTextField();

    lblINamedObject.setFont(new java.awt.Font("Tahoma", 0, 14));
    lblINamedObject.setText("jLabel1");
    lblName.setText("Name");
    lblDescription.setText("Description");
    lblCanonicalName.setText("Canonical Name");
    lblClass.setText("Class");
    lblParentContext.setText("Parent Context");
    lblStartPoint.setText("StartPoint");
    lblMidPoint.setText("MidPoint");
    lblEndPoint.setText("EndPoint");
    lblUpdateMethod.setText("Update Method");
    lblLength.setText("Length");
    lblDirection.setText("Direction");

    jtfClass.setEditable(false);
    jtfCanonicalName.setEditable(false);
    jtfParentContext.setEditable(false);
    jtfStartPoint.setEditable(false);
    jtfMidPoint.setEditable(false);
    jtfEndPoint.setEditable(false);
    jtfLength.setEditable(false);
    jtfDirection.setEditable(false);

    jspUpdateMethodInputs.setLayout(new BorderLayout());
    jspUpdateMethodInputs.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING).add(layout
            .createSequentialGroup().addContainerGap()
            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jspUpdateMethodInputs,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 301, Short.MAX_VALUE)
                    .add(lblINamedObject)
                    .add(layout.createSequentialGroup()
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(lblCanonicalName).add(lblClass).add(lblName).add(lblDescription)
                                    .add(lblParentContext).add(lblStartPoint).add(lblEndPoint).add(lblMidPoint)
                                    .add(lblDirection).add(lblLength))
                            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jtfName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfClass, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfDescription, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                            layout.createSequentialGroup()
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                    .add(jtfCanonicalName,
                                                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                                            Short.MAX_VALUE))
                                    .add(jtfParentContext, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfStartPoint, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfMidPoint, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfEndPoint, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfLength, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)
                                    .add(jtfDirection, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 221,
                                            Short.MAX_VALUE)))
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                            .add(lblUpdateMethod).add(6, 6, 6).add(jcbUpdateMethod, 0, 221, Short.MAX_VALUE)))
            .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap().add(lblINamedObject)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfClass, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblClass))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblName))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblCanonicalName)
                            .add(jtfCanonicalName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblDescription).add(jtfDescription,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblParentContext)
                            .add(jtfParentContext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(lblStartPoint)
                            .add(jtfStartPoint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfMidPoint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblMidPoint))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfEndPoint, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblEndPoint))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfLength, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblLength))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfDirection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblDirection))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jcbUpdateMethod, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblUpdateMethod))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jspUpdateMethodInputs,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 242, Short.MAX_VALUE)
                    .addContainerGap()));

    // disable non editable fields
    this.jtfCanonicalName.setEditable(false);
    this.jtfClass.setEditable(false);
    this.jtfParentContext.setEditable(false);

    // set field values
    this.setValues();

    // set action listeners
    jtfName.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfNameActionListener(evt);
        }
    });
    jtfDescription.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfDescriptionActionListener(evt);
        }
    });
    jcbUpdateMethod.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcbUpdateMethodActionListener(evt);
        }
    });

}

From source file:au.org.ala.delta.intkey.ui.WebSearchDialog.java

/**
 * Create the dialog.//  w w  w.  j  a v a  2s. c  o m
 */
public WebSearchDialog(Dialog owner) {

    super(owner);
    setName("WebSearchDialog");
    ResourceMap resourceMap = Application.getInstance().getContext().getResourceMap(WebSearchDialog.class);
    resourceMap.injectFields(this);
    ActionMap actionMap = Application.getInstance().getContext().getActionMap(WebSearchDialog.class, this);

    setTitle(websearchTitle);
    setBounds(100, 100, 450, 250);
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    getContentPane().add(contentPanel, BorderLayout.CENTER);
    {
        lblSearchFor = new JLabel(searchForLabel);
    }

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

    final JLabel lblUsing = new JLabel(usingLabel);

    cmbSearchEngine = new JComboBox();
    GroupLayout gl_contentPanel = new GroupLayout(contentPanel);
    gl_contentPanel.setHorizontalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
            .addGroup(gl_contentPanel.createSequentialGroup().addContainerGap()
                    .addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING)
                            .addComponent(lblSearchFor, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE)
                            .addComponent(cmbSearchEngine, 0, 404, Short.MAX_VALUE)
                            .addComponent(txtSearch, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE)
                            .addComponent(lblUsing, GroupLayout.DEFAULT_SIZE, 404, Short.MAX_VALUE))
                    .addContainerGap()));
    gl_contentPanel
            .setVerticalGroup(
                    gl_contentPanel.createParallelGroup(Alignment.LEADING)
                            .addGroup(gl_contentPanel.createSequentialGroup().addContainerGap()
                                    .addComponent(lblSearchFor).addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addComponent(txtSearch, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addGap(27).addComponent(lblUsing)
                                    .addPreferredGap(ComponentPlacement.UNRELATED)
                                    .addComponent(cmbSearchEngine, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                    .addContainerGap(41, Short.MAX_VALUE)));
    contentPanel.setLayout(gl_contentPanel);
    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.CENTER));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            JButton okButton = new JButton("[OK]");
            okButton.setAction(actionMap.get("WebSearchDialog_search"));
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("[Cancel]");
            cancelButton.setAction(actionMap.get("WebSearchDialog_cancel"));
            buttonPane.add(cancelButton);
        }
    }

    LocalConfigFiles files = new LocalConfigFiles("intkey");
    File f = files.getWebsearchIndexFile();
    if (f.exists()) {
        loadSearchEngines(f, cmbSearchEngine);
    }

    cmbSearchEngine.requestFocus();
}

From source file:cz.lidinsky.editor.TableCellEditor.java

/**
 *  Initialize all of the components/*from ww  w. j  a v a 2s .  c o  m*/
 */
public TableCellEditor() {
    // color chooser
    button = new JButton();
    button.setActionCommand("edit");
    button.addActionListener(this);
    button.setBorderPainted(false);
    button.addFocusListener(this);
    colorChooser = new JColorChooser();
    colorChooser.addChooserPanel(new AliasChooser());
    colorChooser.addFocusListener(this);
    dialog = JColorChooser.createDialog(button, "Pick a Color", true, colorChooser, this, null);
    // text editor
    textField = new JTextField();
    textField.addFocusListener(this);
    // combo chooser
    comboBox = new JComboBox();
    comboBox.addFocusListener(this);
    // check box
    checkBox = new JCheckBox();
    checkBox.addFocusListener(this);
}

From source file:ca.sfu.federation.viewer.propertysheet.PlanePropertySheet.java

/** 
 * ParametricModelSheet constructors.// ww w  .  j  av  a  2s.  c  o  m
 */
public PlanePropertySheet() {
    lblINamedObject = new JLabel();
    lblName = new JLabel();
    lblDescription = new JLabel();
    jtfClass = new JTextField();
    jtfName = new JTextField();
    jtfCanonicalName = new JTextField();
    lblCanonicalName = new JLabel();
    lblClass = new JLabel();
    jtfDescription = new JTextField();
    lblParentContext = new JLabel();
    jtfParentContext = new JTextField();
    lblX = new JLabel();
    lblY = new JLabel();
    lblZ = new JLabel();
    jtfX = new JTextField();
    jtfY = new JTextField();
    jtfZ = new JTextField();
    lblUpdateMethod = new JLabel();
    jcbUpdateMethod = new JComboBox();
    jScrollPane1 = new JScrollPane();

    lblINamedObject.setFont(new java.awt.Font("Tahoma", 0, 14));
    lblINamedObject.setText("jLabel1");
    lblName.setText("Name");
    lblDescription.setText("Description");
    lblClass.setText("Class");
    lblCanonicalName.setText("Canonical Name");
    lblParentContext.setText("Parent Context");
    lblX.setText("X Coordinate");
    lblY.setText("Y Coordinate");
    lblZ.setText("Z Coordinate");
    lblUpdateMethod.setText("Update Method");

    this.jtfCanonicalName.setEditable(false);
    this.jtfClass.setEditable(false);
    this.jtfParentContext.setEditable(false);

    jScrollPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING,
                            layout.createSequentialGroup().addContainerGap()
                                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                    301, Short.MAX_VALUE)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, lblINamedObject)
                                            .add(org.jdesktop.layout.GroupLayout.LEADING, layout
                                                    .createSequentialGroup().add(layout
                                                            .createParallelGroup(
                                                                    org.jdesktop.layout.GroupLayout.LEADING)
                                                            .add(lblCanonicalName).add(
                                                                    lblClass)
                                                            .add(lblName).add(
                                                                    lblDescription)
                                                            .add(lblParentContext).add(lblX).add(lblZ).add(lblY)
                                                            .add(lblUpdateMethod))
                                                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                                    .add(layout
                                                            .createParallelGroup(
                                                                    org.jdesktop.layout.GroupLayout.LEADING)
                                                            .add(jcbUpdateMethod, 0, 221, Short.MAX_VALUE)
                                                            .add(jtfName,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfClass,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfDescription,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(org.jdesktop.layout.GroupLayout.TRAILING,
                                                                    layout.createSequentialGroup()
                                                                            .addPreferredGap(
                                                                                    org.jdesktop.layout.LayoutStyle.RELATED)
                                                                            .add(jtfCanonicalName,
                                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                                    221, Short.MAX_VALUE))
                                                            .add(jtfParentContext,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfX,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfY,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE)
                                                            .add(jtfZ,
                                                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                                                    221, Short.MAX_VALUE))))
                                    .addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup().addContainerGap().add(lblINamedObject)
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfClass, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblClass))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblName))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblCanonicalName)
                            .add(jtfCanonicalName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblDescription).add(jtfDescription,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblParentContext)
                            .add(jtfParentContext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE).add(lblX).add(
                            jtfX, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                            org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                            org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfY, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblY))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jtfZ, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblZ))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(jcbUpdateMethod, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblUpdateMethod))
                    .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 232, Short.MAX_VALUE)
                    .addContainerGap()));

    // set field values
    this.setValues();

    // add action listeners
    jtfName.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfNameActionListener(evt);
        }
    });
    jtfDescription.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfDescriptionActionListener(evt);
        }
    });
    jtfX.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfXActionListener(evt);
        }
    });
    jtfY.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfYActionListener(evt);
        }
    });
    jtfZ.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jtfZActionListener(evt);
        }
    });
    jcbUpdateMethod.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcbUpdateMethodActionListener(evt);
        }
    });

}

From source file:com.haulmont.cuba.desktop.LoginDialog.java

protected Container createContentPane() {
    MigLayout layout = new MigLayout("fillx, insets dialog", "[right][]");
    JPanel panel = new JPanel(layout);

    panel.add(new JLabel(messages.getMainMessage("loginWindow.loginField", resolvedLocale)));

    nameField = new JTextField();
    passwordField = new JPasswordField();

    String defaultName = desktopConfig.getLoginDialogDefaultUser();
    String lastLogin = loginProperties.loadLastLogin();
    if (!StringUtils.isBlank(lastLogin)) {
        nameField.setText(lastLogin);//from   w  w w. jav a  2  s .  c  o m
        SwingUtilities.invokeLater(() -> passwordField.requestFocus());
    } else if (!StringUtils.isBlank(defaultName)) {
        nameField.setText(defaultName);
    }

    panel.add(nameField, "width 150!, wrap");

    panel.add(new JLabel(messages.getMainMessage("loginWindow.passwordField", resolvedLocale)));
    String defaultPassword = desktopConfig.getLoginDialogDefaultPassword();
    if (!StringUtils.isBlank(defaultPassword))
        passwordField.setText(defaultPassword);
    panel.add(passwordField, "width 150!, wrap");

    Configuration configuration = AppBeans.get(Configuration.NAME);

    localeCombo = new JComboBox<>();
    initLocales(localeCombo);
    if (configuration.getConfig(GlobalConfig.class).getLocaleSelectVisible()) {
        panel.add(new JLabel(messages.getMainMessage("loginWindow.localesSelect", resolvedLocale)));
        panel.add(localeCombo, "width 150!, wrap");
    }

    loginBtn = new JButton(messages.getMainMessage("loginWindow.okButton", resolvedLocale));
    loginBtn.setIcon(App.getInstance().getResources().getIcon("icons/ok.png"));
    loginBtn.addActionListener(e -> doLogin());
    DesktopComponentsHelper.adjustSize(loginBtn);
    panel.add(loginBtn, "span, align center");

    getRootPane().setDefaultButton(loginBtn);

    assignTestIdsIfNeeded(panel);

    return panel;
}