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

public BookTestFrame() {
    setTitle("BookTest");

    text = new JTextField();
    add(text, BorderLayout.NORTH);

    attributes = new HashPrintRequestAttributeSet();

    JPanel buttonPanel = new JPanel();

    JButton printButton = new JButton("Print");
    buttonPanel.add(printButton);//from w  ww . ja  v a  2 s .  c  o  m
    printButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            try {
                PrinterJob job = PrinterJob.getPrinterJob();
                job.setPageable(makeBook());
                if (job.printDialog(attributes)) {
                    job.print(attributes);
                }
            } catch (PrinterException e) {
                JOptionPane.showMessageDialog(BookTestFrame.this, e);
            }
        }
    });

    JButton pageSetupButton = new JButton("Page setup");
    buttonPanel.add(pageSetupButton);
    pageSetupButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            PrinterJob job = PrinterJob.getPrinterJob();
            pageFormat = job.pageDialog(attributes);
        }
    });

    JButton printPreviewButton = new JButton("Print preview");
    buttonPanel.add(printPreviewButton);
    printPreviewButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent event) {
            PrintPreviewDialog dialog = new PrintPreviewDialog(makeBook());
            dialog.setVisible(true);
        }
    });

    add(buttonPanel, BorderLayout.SOUTH);
    pack();
}

From source file:com.stefanbrenner.droplet.utils.UiUtilsTest.java

@Test
public void testSetEnabledRecursive() {
    JPanel testPanel = new JPanel();

    JButton btnTest = new JButton();
    testPanel.add(btnTest);/*from   w w w. ja  va  2s . c  o  m*/
    JTextField txtTest = new JTextField();
    testPanel.add(txtTest);

    JPanel testPanel2 = new JPanel();
    JCheckBox chTest = new JCheckBox();
    testPanel2.add(chTest);

    testPanel.add(testPanel2);

    List<JComponent> allComps = Arrays
            .asList(new JComponent[] { testPanel, btnTest, txtTest, testPanel2, chTest });

    // disable all components
    UiUtils.setEnabledRecursive(testPanel, false);
    for (JComponent comp : allComps) {
        assertEquals(false, comp.isEnabled());
    }
    // re-enable all components
    UiUtils.setEnabledRecursive(testPanel, true);
    for (JComponent comp : allComps) {
        assertEquals(true, comp.isEnabled());
    }

    // disable all except txtTest
    UiUtils.setEnabledRecursive(testPanel, false, txtTest);
    for (JComponent comp : allComps) {
        if (ObjectUtils.notEqual(comp, txtTest)) {
            assertEquals(false, comp.isEnabled());
        } else {
            assertEquals(true, comp.isEnabled());
        }
    }
    // re-enable all components
    UiUtils.setEnabledRecursive(testPanel, true);
    for (JComponent comp : allComps) {
        assertEquals(true, comp.isEnabled());
    }

    // disable all except chTest in testPanel2
    UiUtils.setEnabledRecursive(testPanel, false, chTest);
    for (JComponent comp : allComps) {
        if (ObjectUtils.notEqual(comp, chTest)) {
            assertEquals(false, comp.isEnabled());
        } else {
            assertEquals(true, comp.isEnabled());
        }
    }
    // re-enable all components
    UiUtils.setEnabledRecursive(testPanel, true);
    for (JComponent comp : allComps) {
        assertEquals(true, comp.isEnabled());
    }

    // disable all except txtTest in testPanel and chTest in testPanel2
    JComponent[] except = new JComponent[] { txtTest, chTest };
    UiUtils.setEnabledRecursive(testPanel, false, except);
    for (JComponent comp : allComps) {
        if (!Arrays.asList(except).contains(comp)) {
            assertEquals(false, comp.isEnabled());
        } else {
            assertEquals(true, comp.isEnabled());
        }
    }
    // re-enable all components
    UiUtils.setEnabledRecursive(testPanel, true);
    for (JComponent comp : allComps) {
        assertEquals(true, comp.isEnabled());
    }

}

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

private void initGUI() {
    try {//from  w w  w  .  j av a  2  s.co m
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("CronExpression", null, jPanel1, null);
                {
                    jPanel2 = new JPanel();
                    jPanel1.add(jPanel2, BorderLayout.NORTH);
                    jPanel2.setPreferredSize(new java.awt.Dimension(439, 34));
                    {
                        cronText = new JTextField();
                        jPanel2.add(cronText);
                        cronText.setText("");
                        cronText.setPreferredSize(new java.awt.Dimension(229, 27));
                    }
                    {
                        executeBtn = new JButton();
                        jPanel2.add(executeBtn);
                        executeBtn.setText("execute");
                        executeBtn.setPreferredSize(new java.awt.Dimension(85, 28));
                        executeBtn.addActionListener(new ActionListener() {
                            public void actionPerformed(ActionEvent evt) {
                                //XXX
                                try {
                                    CronExpression cexp = new CronExpression(cronText.getText());
                                    Date current = new Date();
                                    setTitle(DateFormatUtils.format(current, "yyyy/MM/dd HH:mm:ss"));

                                    DefaultListModel cronListModel = new DefaultListModel();
                                    for (int ii = 0, total = Integer
                                            .parseInt(limitText.getText()); ii < total; ii++) {
                                        current = cexp.getNextValidTimeAfter(current);
                                        if (current == null) {
                                            break;
                                        }
                                        cronListModel.addElement(ii + " : "
                                                + DateFormatUtils.format(current, "yyyy/MM/dd HH:mm:ss"));
                                    }
                                    cronList.setModel(cronListModel);
                                } catch (Exception e) {
                                    e.printStackTrace();
                                    JCommonUtil.handleException(e);
                                    return;
                                }
                            }
                        });
                    }
                    {
                        limitText = new JTextField();
                        jPanel2.add(limitText);
                        limitText.setText("2000");
                        limitText.setPreferredSize(new java.awt.Dimension(61, 24));
                    }
                }
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(439, 253));
                    {
                        DefaultListModel cronListModel = new DefaultListModel();
                        cronList = new JList();
                        jScrollPane1.setViewportView(cronList);
                        cronList.setModel(cronListModel);
                    }
                }
            }
        }
        pack();
        this.setSize(460, 354);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

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

/** 
 * CoordinateSystemPropertySheet constructor
 *///  www  . java 2  s. c  o m
public CoordinateSystemPropertySheet() {
    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");
    lblCanonicalName.setText("Canonical Name");
    lblClass.setText("Class");
    lblParentContext.setText("Parent Context");
    lblX.setText("X Coordinate");
    lblY.setText("Y Coordinate");
    lblZ.setText("Z Coordinate");
    lblUpdateMethod.setText("Update Method");

    jtfParentContext.setEditable(false);
    jtfClass.setEditable(false);
    jtfCanonicalName.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(lblX).add(lblZ).add(lblY)
                                                            .add(lblUpdateMethod).add(lblParentContext))
                                                    .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.BASELINE)
                            .add(jtfParentContext, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
                                    org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
                                    org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblParentContext))
                    .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()));

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

    // set field values
    this.setValues();

    // add action listener
    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.genericworkflownodes.knime.nodes.io.OutputFileNodeDialog.java

/**
 * New pane for configuring MimeFileExporter node dialog.
 *//*www.  jav  a  2  s. com*/
public OutputFileNodeDialog(final String settingsName) {
    this.settingsName = settingsName;
    dialogPanel = new JPanel();
    componentContainer = new JPanel();
    textField = new JTextField();
    textField.setPreferredSize(new Dimension(300, textField.getPreferredSize().height));
    searchButton = new JButton("Browse");
    searchButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser jfc = new JFileChooser();
            if (!"".equals(textField.getText().trim())
                    && new File(textField.getText().trim()).getParent() != null) {
                jfc.setCurrentDirectory(new File(textField.getText().trim()).getParentFile());
            }

            jfc.setAcceptAllFileFilterUsed(false);
            jfc.setFileFilter(extensionFilter);

            // int returnVal = jfc.showSaveDialog(dialogPanel);
            jfc.setFileSelectionMode(JFileChooser.FILES_ONLY);
            int returnVal = jfc.showDialog(dialogPanel, "Select output file");
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                // validate extension
                if (!extensionFilter.accept(jfc.getSelectedFile())) {
                    String message = "The selected output file has an invalid file extension.\n";
                    if (extensionFilter.getExtensions().length == 1) {
                        message += "Please choose a file with extension: " + extensionFilter.getExtensions()[0];
                    } else {
                        message += "Please choose a file with on of the following extensions: ";
                        message += StringUtils.join(extensionFilter.getExtensions(), ", ");
                    }
                    JOptionPane.showMessageDialog(getPanel(), message, "Selected Output File is invalid.",
                            JOptionPane.WARNING_MESSAGE);
                }
                textField.setText(jfc.getSelectedFile().getAbsolutePath());
            }
        }
    });
    setLayout();
    addComponents();

    addTab("Choose File", dialogPanel);
}

From source file:gtu.zcognos.SimpleUI.java

private void initGUI() {
    try {/*from   w  w w.j  a  v a  2  s .  c  o m*/

        final SwingActionUtil swingUtil = (SwingActionUtil) SwingActionUtil.newInstance(this);
        {
            GroupLayout thisLayout = new GroupLayout((JComponent) getContentPane());
            getContentPane().setLayout(thisLayout);
            this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
            {
                projectId = new JTextField();
            }
            {
                packageId = new JTextField();
            }
            {
                jLabel1 = new JLabel();
                jLabel1.setText("PROJECT_ID");
            }
            {
                jLabel2 = new JLabel();
                jLabel2.setText("PACKAGE_ID");
            }
            {
                jLabel3 = new JLabel();
                jLabel3.setText("DATATABLE");
            }
            {
                jScrollPane1 = new JScrollPane();
                {
                    dataTable = new JTextArea();
                    jScrollPane1.setViewportView(dataTable);
                }
            }
            {
                create = new JButton();
                create.setText("create");
                create.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent evt) {
                        swingUtil.invokeAction("create.actionPerformed", evt);
                    }
                });
            }
            thisLayout.setVerticalGroup(thisLayout.createSequentialGroup().addContainerGap(16, 16)
                    .addGroup(thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                            .addComponent(projectId, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE,
                                    GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(thisLayout.createParallelGroup().addGroup(GroupLayout.Alignment.LEADING,
                            thisLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
                                    .addComponent(packageId, GroupLayout.Alignment.BASELINE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel2, GroupLayout.Alignment.BASELINE,
                                            GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                                            GroupLayout.PREFERRED_SIZE))
                            .addGroup(GroupLayout.Alignment.LEADING,
                                    thisLayout.createSequentialGroup()
                                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0,
                                                    Short.MAX_VALUE)
                                            .addComponent(create, GroupLayout.PREFERRED_SIZE, 22,
                                                    GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jLabel3, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 217, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap());
            thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup().addContainerGap(31, 31).addGroup(
                    thisLayout.createParallelGroup().addGroup(GroupLayout.Alignment.LEADING, thisLayout
                            .createSequentialGroup()
                            .addGroup(thisLayout.createParallelGroup()
                                    .addComponent(jLabel2, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel1, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel3, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(thisLayout.createParallelGroup()
                                    .addComponent(packageId, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE)
                                    .addComponent(projectId, GroupLayout.Alignment.LEADING,
                                            GroupLayout.PREFERRED_SIZE, 204, GroupLayout.PREFERRED_SIZE))
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(create, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, Short.MAX_VALUE))
                            .addGroup(thisLayout.createSequentialGroup()
                                    .addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 417,
                                            GroupLayout.PREFERRED_SIZE)
                                    .addGap(0, 0, Short.MAX_VALUE)))
                    .addContainerGap(17, 17));
        }
        this.setSize(473, 356);

        swingUtil.addAction("create.actionPerformed", new Action() {
            public void action(EventObject evt) throws Exception {
                String project = projectId.getText();
                String dataTab = dataTable.getText();
                Validate.notEmpty(project);
                Validate.notEmpty(dataTab);
                String pkgId = StringUtils.defaultIfEmpty(packageId.getText(), project);

                List<String> dataTableList = new ArrayList<String>();
                StringTokenizer tok = new StringTokenizer(dataTab);
                for (int ii = 0; tok.hasMoreElements(); ii++) {
                    String column = (String) tok.nextElement();
                    System.out.format("%d -- %s\n", ii, column);
                    if (StringUtils.isBlank(column)) {
                        continue;
                    }
                    dataTableList.add(column.trim());
                }

                File destDir = new File(CREATE_DEST + "\\" + project);
                destDir.mkdirs();

                Map<String, Object> map = new HashMap<String, Object>();
                map.put("PROJECT_ID", project);
                map.put("PACKAGE_ID", pkgId);
                map.put("DATATABLE", dataTableList);

                ConfigCopy.getInstance().applyBaseDir(new File(CREATE_DEST)).applyProjectId(project).execute();

                Simple.getInstance()//
                        .applyDestDir(destDir.getAbsolutePath())//
                        .applyParameter(map)//
                        .execute();

                JOptionPaneUtil.newInstance().iconInformationMessage()
                        .showMessageDialog(pkgId + " create completed!!\r\n dir : " //
                                + destDir.getAbsolutePath(), pkgId);

                Desktop.getDesktop().open(destDir);
            }
        });

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

From source file:gov.nih.nci.nbia.StandaloneDM.java

private JPanel constructLoginPanel() {
    JPanel contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(null);//from  w  w w. j av  a2s . com

    JLabel lblNewLabel_2 = new JLabel();
    lblNewLabel_2.setBounds(20, 11, 100, 100);
    contentPane.add(lblNewLabel_2);
    ImageIcon iconLogo = new ImageIcon("Images/global.logo");
    lblNewLabel_2.setIcon(iconLogo);
    statusLbl = new JLabel(
            "<html>Some or all of the images you are about to download are from<br>private collection(s). Please log in first.</html>");
    contentPane.add(statusLbl);
    statusLbl.setBounds(110, 11, 500, 42);
    JLabel lblNewLabel = new JLabel("User Name");
    contentPane.add(lblNewLabel);
    lblNewLabel.setBounds(110, 79, 77, 31);

    userNameFld = new JTextField();
    contentPane.add(userNameFld);
    userNameFld.setBounds(187, 75, 333, 36);
    userNameFld.setColumns(10);

    JButton submitBtn = new JButton(SubmitBtnLbl);
    submitBtn.addActionListener(new BtnListener());
    contentPane.add(submitBtn);
    submitBtn.setBounds(249, 200, 139, 36);

    passwdFld = new JPasswordField();
    contentPane.add(passwdFld);
    passwdFld.setBounds(187, 129, 333, 36);

    userNameFld.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            passwdFld.requestFocus();
        }
    });

    passwdFld.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            userId = userNameFld.getText();
            password = passwdFld.getText();
            if ((userId.length() < 1) || (password.length() < 1)) {
                statusLbl.setText("Please enter a valid user name and password.");
                statusLbl.setForeground(Color.red);
            } else
                submitUserCredential(userId, password);
        }
    });

    JLabel lblNewLabel_1 = new JLabel("Password");
    contentPane.add(lblNewLabel_1);
    lblNewLabel_1.setBounds(110, 129, 77, 36);

    return contentPane;
}

From source file:net.femtoparsec.jwhois.gui.JWhoIsQueryGUI.java

public JWhoIsQueryGUI(JWhoIsGUIModel<?> model) {
    Validate.notNull(model, "model");
    this.model = model;
    this.model.addSourceResultListener(this);
    this.resourceBundle = Utf8ResourceBundle.getBundle("JWhoIsQueryGUI");

    this.setLayout(new BorderLayout());

    this.queryField = new JTextField();
    queryField.setActionCommand(QUERY_FIELD_ACTION_NAME);
    queryField.addActionListener(this);
    queryField.addKeyListener(this);
    queryField.setPreferredSize(new Dimension(300, queryField.getHeight()));

    this.queryButton = new JButton(resourceBundle.getString("query.button.label"));
    queryButton.setActionCommand(QUERY_BUTTON_ACTION_NAME);
    queryButton.addActionListener(this);

    final String labelLabel = resourceBundle.getString("query.label.label");
    this.add(new JLabel(labelLabel), BorderLayout.WEST);
    this.add(this.queryField, BorderLayout.CENTER);
    this.add(this.queryButton, BorderLayout.EAST);

    this.queryField.setText(this.model.getQuery());
    this.updateButtonState();
}

From source file:Tree1.java

public Tree1() {
    super("Sample Tree [OID]");
    setSize(400, 300);/*from  w  ww.  j a v  a 2  s  . c o m*/

    Object[] nodes = new Object[5];
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(new OidNode(1, "ISO"));
    DefaultMutableTreeNode parent = top;
    nodes[0] = top;

    DefaultMutableTreeNode node = new DefaultMutableTreeNode(new OidNode(0, "standard"));
    parent.add(node);
    node = new DefaultMutableTreeNode(new OidNode(2, "member-body"));
    parent.add(node);
    node = new DefaultMutableTreeNode(new OidNode(3, "org"));
    parent.add(node);
    parent = node;
    nodes[1] = parent;

    node = new DefaultMutableTreeNode(new OidNode(6, "dod"));
    parent.add(node);
    parent = node;
    nodes[2] = parent;

    node = new DefaultMutableTreeNode(new OidNode(1, "internet"));
    parent.add(node);
    parent = node;
    nodes[3] = parent;

    node = new DefaultMutableTreeNode(new OidNode(1, "directory"));
    parent.add(node);
    node = new DefaultMutableTreeNode(new OidNode(2, "mgmt"));
    parent.add(node);
    nodes[4] = node;
    node.add(new DefaultMutableTreeNode(new OidNode(1, "mib-2")));
    node = new DefaultMutableTreeNode(new OidNode(3, "experimental"));
    parent.add(node);
    node = new DefaultMutableTreeNode(new OidNode(4, "private"));
    node.add(new DefaultMutableTreeNode(new OidNode(1, "enterprises")));
    parent.add(node);
    node = new DefaultMutableTreeNode(new OidNode(5, "security"));
    parent.add(node);
    node = new DefaultMutableTreeNode(new OidNode(6, "snmpV2"));
    parent.add(node);
    node = new DefaultMutableTreeNode(new OidNode(7, "mail"));
    parent.add(node);

    m_model = new DefaultTreeModel(top);
    m_tree = new JTree(m_model);

    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer();
    renderer.setOpenIcon(new ImageIcon("opened.gif"));
    renderer.setClosedIcon(new ImageIcon("closed.gif"));
    renderer.setLeafIcon(new ImageIcon("leaf.gif"));
    m_tree.setCellRenderer(renderer);

    m_tree.setShowsRootHandles(true);
    m_tree.setEditable(false);
    TreePath path = new TreePath(nodes);
    m_tree.setSelectionPath(path);

    m_tree.addTreeSelectionListener(new OidSelectionListener());

    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.SOUTH);

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

    setVisible(true);
}

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

private void initGUI() {
    try {/*from   w w  w .  ja va 2 s  .  co m*/
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                GridLayout jPanel1Layout = new GridLayout(10, 1);
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                {
                    jLabel1 = new JLabel();
                    jPanel1.add(jLabel1);
                    jLabel1.setText("java\u6a94");
                }
                {
                    javaSrcFileText = new JTextField();
                    jPanel1.add(javaSrcFileText);
                    JCommonUtil.jTextFieldSetFilePathMouseEvent(javaSrcFileText, false);
                }
                {
                    jLabel2 = new JLabel();
                    jPanel1.add(jLabel2);
                    jLabel2.setText("method\u958b\u59cb");
                }
                {
                    methodStartText = new JTextField();
                    methodStartText.setText("\"#. ${method} .s\"");
                    jPanel1.add(methodStartText);
                }
                {
                    jLabel3 = new JLabel();
                    jPanel1.add(jLabel3);
                    jLabel3.setText("method\u7d50\u675f");
                }
                {
                    methodEndText = new JTextField();
                    methodEndText.setText("\"#. ${method} .e\"");
                    jPanel1.add(methodEndText);
                }
                {
                    jLabel4 = new JLabel();
                    jPanel1.add(jLabel4);
                    jLabel4.setText(
                            "\u7528\u684c\u9762\u8a2d\u5b9a\u6a94\u6c7a\u5b9adebug\u958b\u8d77\u6216\u95dc\u9589");
                }
                {
                    ComboBoxModel onOffDebugSwitchComboBoxModel = new DefaultComboBoxModel(
                            new String[] { "false", "true" });
                    onOffDebugSwitchComboBox = new JComboBox();
                    jPanel1.add(onOffDebugSwitchComboBox);
                    onOffDebugSwitchComboBox.setModel(onOffDebugSwitchComboBoxModel);
                }
                {
                    executeBtn = new JButton();
                    jPanel1.add(executeBtn);
                    executeBtn.setText("\u57f7\u884c");
                    executeBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            executeBtnActionPerformed(evt);
                        }
                    });
                }
            }
        }
        pack();
        this.setSize(587, 404);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}