Example usage for java.awt BorderLayout LINE_END

List of usage examples for java.awt BorderLayout LINE_END

Introduction

In this page you can find the example usage for java.awt BorderLayout LINE_END.

Prototype

String LINE_END

To view the source code for java.awt BorderLayout LINE_END.

Click Source Link

Document

The component goes at the end of the line direction for the layout.

Usage

From source file:FormattedTextFieldDemo.java

public FormattedTextFieldDemo() {
    super(new BorderLayout());
    setUpFormats();//from   ww w . j  av a2s.  c  o  m
    double payment = computePayment(amount, rate, numPeriods);

    // Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    // Create the text fields and set them up.
    amountField = new JFormattedTextField(amountFormat);
    amountField.setValue(new Double(amount));
    amountField.setColumns(10);
    amountField.addPropertyChangeListener("value", this);

    rateField = new JFormattedTextField(percentFormat);
    rateField.setValue(new Double(rate));
    rateField.setColumns(10);
    rateField.addPropertyChangeListener("value", this);

    numPeriodsField = new JFormattedTextField();
    numPeriodsField.setValue(new Integer(numPeriods));
    numPeriodsField.setColumns(10);
    numPeriodsField.addPropertyChangeListener("value", this);

    paymentField = new JFormattedTextField(paymentFormat);
    paymentField.setValue(new Double(payment));
    paymentField.setColumns(10);
    paymentField.setEditable(false);
    paymentField.setForeground(Color.red);

    // Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    // Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    // Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    // Put the panels in this panel, labels on left,
    // text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
}

From source file:com.raphfrk.craftproxyclient.gui.CraftProxyGUI.java

public CraftProxyGUI(String buildId) {

    pf = new PropertiesFile("CraftProxyClientGUI.txt");

    try {//w  w  w  .  ja  v  a 2  s .c  om
        pf.load();
    } catch (IOException e) {
        JOptionPane.showMessageDialog(CraftProxyGUI.this, "Unable to open settings file");
    }

    String defaultHostname = pf.getString("connect_hostname", "");
    int defaultPort = pf.getInt("connect_port", 20000);
    int listenPort = pf.getInt("listen_port", 25565);
    int desired = pf.getInt("cache_size", 48);

    try {
        pf.save();
    } catch (IOException e) {
        JOptionPane.showMessageDialog(CraftProxyGUI.this, "Unable to save settings file");
    }

    setTitle("CraftProxyClient Local (" + buildId + ")");
    setSize(500, 375);
    setLocation(40, 150);

    topPanel.setLayout(new BorderLayout());
    topPanel.setBorder(new TitledBorder("Remote Server"));
    topPanel.setBackground(Color.WHITE);
    secondPanel.setLayout(new BorderLayout());
    secondPanel.setBorder(new TitledBorder("Local Server"));
    secondPanel.setBackground(Color.WHITE);

    serverName = new JTextField(defaultHostname, 20);
    TitledBorder border = new TitledBorder("Name");
    serverName.setBorder(border);
    serverName.addActionListener(this);

    portNum = new JTextField(Integer.toString(defaultPort), 6);
    border = new TitledBorder("Port");
    portNum.setBorder(border);
    portNum.addActionListener(this);

    localServerName = new JLabel("localhost");
    localServerName.setBackground(Color.GRAY);
    border = new TitledBorder("Name");
    localServerName.setBorder(border);

    localServerPortnum = new JTextField(Integer.toString(listenPort), 6);
    border = new TitledBorder("Port");
    localServerPortnum.setBorder(border);
    localServerPortnum.addActionListener(this);

    topPanel.add(serverName, BorderLayout.CENTER);
    topPanel.add(portNum, BorderLayout.LINE_END);

    secondPanel.setLayout(new BorderLayout());
    secondPanel.add(localServerName, BorderLayout.CENTER);
    secondPanel.add(localServerPortnum, BorderLayout.LINE_END);

    combinedTop.setLayout(new BorderLayout());
    combinedTop.add(topPanel, BorderLayout.CENTER);
    combinedTop.add(secondPanel, BorderLayout.SOUTH);

    currentSize = new JTextField("Unknown");
    currentSize.setBorder(new TitledBorder("Current Size (MB)"));
    currentSize.setEditable(false);

    desiredSize = new JTextField(Integer.toString(desired));
    desiredSize.setBorder(new TitledBorder("Max Size (MB)"));

    connect = new JButton(buttonText);
    connect.addActionListener(this);

    filePanel = new JPanel();
    filePanel.setLayout(new BorderLayout());
    JPanel fileLinePanel = new JPanel();
    fileLinePanel.setBorder(new TitledBorder("Cache Size"));
    fileLinePanel.setLayout(new GridLayout(1, 3));
    fileLinePanel.add(currentSize);
    fileLinePanel.add(desiredSize);
    filePanel.add(fileLinePanel, BorderLayout.CENTER);
    filePanel.add(connect, BorderLayout.PAGE_END);

    info = new JLabel();
    border = new TitledBorder("Status");
    info.setBorder(border);

    setLayout(new BorderLayout());
    add(combinedTop, BorderLayout.PAGE_START);
    add(info, BorderLayout.CENTER);
    add(filePanel, BorderLayout.PAGE_END);

    this.setResizable(false);
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.addWindowListener(this);

}

From source file:com.microsoft.alm.plugin.idea.common.ui.common.tabs.TabFormImpl.java

/**
 * Create the tab view if not already done
 *///w  ww.java 2s.co m
protected void ensureInitialized() {
    if (!initialized) {
        createCustomView();
        createFilterToolbar();

        //toolbars
        final JPanel toolBarPanel;
        if (ApplicationManager.getApplication() != null) {
            final ActionToolbar prActionsToolbar = createToolbar(createActionsGroup());
            final ActionToolbar feedbackActionsToolbar = createToolbar(createFeedbackGroup());
            final ActionToolbar optionsActionsToolbar = createToolbar(createOptionsGroup());

            // left panel of the top toolbar
            final FlowLayout flowLayout = new FlowLayout(FlowLayout.LEFT, 0, JBUI.scale(3)); // give vertical padding
            final JPanel toolBarPanelLeft = new JPanel(flowLayout);
            toolBarPanelLeft.add(prActionsToolbar.getComponent());
            toolBarPanelLeft.add(searchFilter);
            addCustomTools(toolBarPanelLeft);

            // middle panel of the top toolbar
            final FlowLayout flowLayout2 = new FlowLayout(FlowLayout.LEFT, 0, JBUI.scale(3)); // give vertical padding
            final JPanel toolBarPanelMiddle = new JPanel(flowLayout2);
            toolBarPanelMiddle.add(optionsActionsToolbar.getComponent());
            SwingHelper.setMargin(toolBarPanelMiddle, new Insets(JBUI.scale(2), JBUI.scale(15), 0, 0));

            //entire top toolbar
            toolBarPanel = new JPanel(new BorderLayout());
            toolBarPanel.add(toolBarPanelLeft, BorderLayout.LINE_START);
            toolBarPanel.add(toolBarPanelMiddle, BorderLayout.CENTER);
            toolBarPanel.add(feedbackActionsToolbar.getComponent(), BorderLayout.LINE_END);
        } else {
            //skip setup when called from unit tests
            toolBarPanel = new JPanel();
        }

        //status panel with label and link
        final JPanel statusPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        statusLabel = new JLabel();
        statusLink = new Hyperlink();
        statusLink.setActionCommand(CMD_STATUS_LINK);
        statusPanel.add(statusLabel);
        statusPanel.add(statusLink);

        //tabPanel
        tabPanel = new JPanel(new BorderLayout());
        tabPanel.add(toolBarPanel, BorderLayout.PAGE_START);
        tabPanel.add(scrollPanel, BorderLayout.CENTER);
        tabPanel.add(statusPanel, BorderLayout.PAGE_END);
        this.initialized = true;
    }
}

From source file:jatoo.proxy.dialog.ProxyDialog.java

/**
 * Shows the dialog relative to the specified owner.
 *//* w w  w  . j  a va  2 s  . co  m*/
public static synchronized void show(Component owner) {

    JDialog dialogTmp;

    if (owner == null) {
        dialogTmp = new JDialog();
    } else {
        dialogTmp = new JDialog(SwingUtilities.getWindowAncestor(owner));
    }

    final JDialog dialog = dialogTmp;

    //
    // the panel

    final ProxyDialogPanel dialogPanel = PROXY_DIALOG_PANEL_FACTORY.createDialogPanel();

    try {

        Proxy proxy = new Proxy();
        proxy.load();

        dialogPanel.setProxyEnabled(proxy.isEnabled());
        dialogPanel.setHost(proxy.getHost());
        dialogPanel.setPort(proxy.getPort());
        dialogPanel.setProxyRequiringAuthentication(proxy.isRequiringAuthentication());
        dialogPanel.setUsername(proxy.getUsername());
        dialogPanel.setPassword(proxy.getPassword());
    }

    catch (FileNotFoundException e) {
        // do nothing, maybe is the first time and the file is missing
    }

    catch (Exception e) {
        logger.error("Failed to load the properties.", e);
    }

    //
    // buttons

    JButton okButton = new JButton("Ok");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {

            try {

                if (dialogPanel.isProxyEnabled()) {

                    if (dialogPanel.isProxyRequiringAuthentication()) {
                        ProxyUtils.setProxy(dialogPanel.getHost(), dialogPanel.getPort(),
                                dialogPanel.getUsername(), dialogPanel.getPassword());
                    } else {
                        ProxyUtils.setProxy(dialogPanel.getHost(), dialogPanel.getPort());
                    }
                }

                else {
                    ProxyUtils.removeProxy();
                }

                dialog.dispose();
            }

            catch (Exception e) {
                JOptionPane.showMessageDialog(dialog, "Failed to set the proxy:\n" + e.toString());
                return;
            }

            try {

                Proxy proxy = new Proxy();

                proxy.setEnabled(dialogPanel.isProxyEnabled());
                proxy.setUsername(dialogPanel.getUsername());
                proxy.setPassword(dialogPanel.getPassword());
                proxy.setRequiringAuthentication(dialogPanel.isProxyRequiringAuthentication());
                proxy.setHost(dialogPanel.getHost());
                proxy.setPort(dialogPanel.getPort());

                proxy.store();
            }

            catch (Exception e) {
                logger.error("Failed to save the properties.", e);
            }
        }
    });

    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dialog.dispose();
        }
    });

    //
    // layout dialog

    dialogPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    JPanel buttonsGroup = new JPanel(new GridLayout(1, 2, 5, 5));
    buttonsGroup.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    buttonsGroup.add(okButton);
    buttonsGroup.add(cancelButton);

    JPanel buttonsPanel = new JPanel(new BorderLayout());
    buttonsPanel.add(buttonsGroup, BorderLayout.LINE_END);

    JPanel contentPane = new JPanel(new BorderLayout());
    contentPane.add(dialogPanel, BorderLayout.CENTER);
    contentPane.add(buttonsPanel, BorderLayout.PAGE_END);

    //
    // setup dialog

    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    dialog.setTitle("Proxy Settings");
    dialog.setContentPane(contentPane);
    dialog.pack();
    dialog.setLocationRelativeTo(dialog.getOwner());
    dialog.setModal(true);

    //
    // and show

    dialog.setVisible(true);
}

From source file:FormattedTextFieldDemo.java

public FormattedTextFieldDemo() {
    super(new BorderLayout());
    setUpFormats();//from  w w  w  .j a  v  a2 s . c o m
    double payment = computePayment(amount, rate, numPeriods);

    //Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    //Create the text fields and set them up.
    amountField = new JFormattedTextField(amountFormat);
    amountField.setValue(new Double(amount));
    amountField.setColumns(10);
    amountField.addPropertyChangeListener("value", this);

    rateField = new JFormattedTextField(percentFormat);
    rateField.setValue(new Double(rate));
    rateField.setColumns(10);
    rateField.addPropertyChangeListener("value", this);

    numPeriodsField = new JFormattedTextField();
    numPeriodsField.setValue(new Integer(numPeriods));
    numPeriodsField.setColumns(10);
    numPeriodsField.addPropertyChangeListener("value", this);

    paymentField = new JFormattedTextField(paymentFormat);
    paymentField.setValue(new Double(payment));
    paymentField.setColumns(10);
    paymentField.setEditable(false);
    paymentField.setForeground(Color.red);

    //Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    //Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    //Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    //Put the panels in this panel, labels on left,
    //text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
}

From source file:InputVerificationDemo.java

public InputVerificationDemo() {
    super(new BorderLayout());
    setUpFormats();//from  w  ww.  j  a  va 2 s.  c om
    double payment = computePayment(DEFAULT_AMOUNT, DEFAULT_RATE, DEFAULT_PERIOD);

    //Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    //Create the text fields and set them up.
    amountField = new JTextField(moneyFormat.format(DEFAULT_AMOUNT), 10);
    amountField.setInputVerifier(verifier);

    rateField = new JTextField(percentFormat.format(DEFAULT_RATE), 10);
    rateField.setInputVerifier(verifier);

    numPeriodsField = new JTextField(decimalFormat.format(DEFAULT_PERIOD), 10);
    numPeriodsField.setInputVerifier(verifier);

    paymentField = new JTextField(paymentFormat.format(payment), 10);
    paymentField.setInputVerifier(verifier);
    paymentField.setEditable(false);
    //Remove this component from the focus cycle.
    paymentField.setFocusable(false);
    paymentField.setForeground(Color.red);

    //Register an action listener to handle Return.
    amountField.addActionListener(verifier);
    rateField.addActionListener(verifier);
    numPeriodsField.addActionListener(verifier);

    //Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    //Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    //Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    //Put the panels in this panel, labels on left,
    //text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
}

From source file:InputVerificationDialogDemo.java

public InputVerificationDialogDemo() {
    super(new BorderLayout());
    setUpFormats();// w  w w.  j  av  a2s. co m
    double payment = computePayment(DEFAULT_AMOUNT, DEFAULT_RATE, DEFAULT_PERIOD);

    //Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    //Create the text fields and set them up.
    amountField = new JTextField(moneyFormat.format(DEFAULT_AMOUNT), 10);
    amountField.setInputVerifier(verifier);

    rateField = new JTextField(percentFormat.format(DEFAULT_RATE), 10);
    rateField.setInputVerifier(verifier);

    numPeriodsField = new JTextField(decimalFormat.format(DEFAULT_PERIOD), 10);
    numPeriodsField.setInputVerifier(verifier);

    paymentField = new JTextField(paymentFormat.format(payment), 10);
    paymentField.setInputVerifier(verifier);
    paymentField.setEditable(false);
    //Remove this component from the focus cycle.
    paymentField.setFocusable(false);
    paymentField.setForeground(Color.red);

    //Register an action listener to handle Return.
    amountField.addActionListener(verifier);
    rateField.addActionListener(verifier);
    numPeriodsField.addActionListener(verifier);

    //Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    //Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    //Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    //Put the panels in this panel, labels on left,
    //text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
}

From source file:com.openbravo.pos.epm.JEmployeeFinder.java

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

    jPanel2 = new javax.swing.JPanel();
    m_jKeys = new com.openbravo.editor.JEditorKeys();
    jPanel3 = new javax.swing.JPanel();
    jPanel5 = new javax.swing.JPanel();
    jPanel7 = new javax.swing.JPanel();
    jLabel5 = new javax.swing.JLabel();
    m_jtxtName = new com.openbravo.editor.JEditorString();
    jPanel6 = new javax.swing.JPanel();
    jButton1 = new javax.swing.JButton();
    jButton3 = new javax.swing.JButton();
    jPanel4 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    jListEmployees = new javax.swing.JList();
    jPanel8 = new javax.swing.JPanel();
    jPanel1 = new javax.swing.JPanel();
    jcmdOK = new javax.swing.JButton();
    jcmdCancel = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    setTitle(AppLocal.getIntString("form.customertitle")); // NOI18N

    jPanel2.setLayout(new java.awt.BorderLayout());
    jPanel2.add(m_jKeys, java.awt.BorderLayout.NORTH);

    getContentPane().add(jPanel2, java.awt.BorderLayout.LINE_END);

    jPanel3.setLayout(new java.awt.BorderLayout());

    jPanel5.setLayout(new java.awt.BorderLayout());

    jLabel5.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jLabel5.setText(AppLocal.getIntString("label.epm.employee")); // NOI18N

    m_jtxtName.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N

    javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
    jPanel7.setLayout(jPanel7Layout);
    jPanel7Layout.setHorizontalGroup(jPanel7Layout
            .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 126,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGap(18, 18, 18).addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, 220,
                            javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(15, Short.MAX_VALUE)));
    jPanel7Layout.setVerticalGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup().addContainerGap()
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                    javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(m_jtxtName, javax.swing.GroupLayout.PREFERRED_SIZE, 25,
                                    javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));

    jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER);

    jButton1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/reload.png"))); // NOI18N
    jButton1.setText(AppLocal.getIntString("button.clean")); // NOI18N
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });
    jPanel6.add(jButton1);

    jButton3.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N
    jButton3.setText(AppLocal.getIntString("button.executefilter")); // NOI18N
    jButton3.setFocusPainted(false);
    jButton3.setFocusable(false);
    jButton3.setRequestFocusEnabled(false);
    jButton3.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton3ActionPerformed(evt);
        }
    });
    jPanel6.add(jButton3);

    jPanel5.add(jPanel6, java.awt.BorderLayout.SOUTH);

    jPanel3.add(jPanel5, java.awt.BorderLayout.PAGE_START);

    jPanel4.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
    jPanel4.setLayout(new java.awt.BorderLayout());

    jListEmployees.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jListEmployees.setFocusable(false);
    jListEmployees.setRequestFocusEnabled(false);
    jListEmployees.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jListEmployeesMouseClicked(evt);
        }
    });
    jListEmployees.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
        public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
            jListEmployeesValueChanged(evt);
        }
    });
    jScrollPane1.setViewportView(jListEmployees);

    jPanel4.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    jPanel3.add(jPanel4, java.awt.BorderLayout.CENTER);

    jPanel8.setLayout(new java.awt.BorderLayout());

    jcmdOK.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jcmdOK.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/ok.png"))); // NOI18N
    jcmdOK.setText(AppLocal.getIntString("Button.OK")); // NOI18N
    jcmdOK.setEnabled(false);
    jcmdOK.setFocusPainted(false);
    jcmdOK.setFocusable(false);
    jcmdOK.setMargin(new java.awt.Insets(8, 16, 8, 16));
    jcmdOK.setRequestFocusEnabled(false);
    jcmdOK.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcmdOKActionPerformed(evt);
        }
    });
    jPanel1.add(jcmdOK);

    jcmdCancel.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
    jcmdCancel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/openbravo/images/cancel.png"))); // NOI18N
    jcmdCancel.setText(AppLocal.getIntString("Button.Cancel")); // NOI18N
    jcmdCancel.setFocusPainted(false);
    jcmdCancel.setFocusable(false);
    jcmdCancel.setMargin(new java.awt.Insets(8, 16, 8, 16));
    jcmdCancel.setRequestFocusEnabled(false);
    jcmdCancel.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jcmdCancelActionPerformed(evt);
        }
    });
    jPanel1.add(jcmdCancel);

    jPanel8.add(jPanel1, java.awt.BorderLayout.LINE_END);

    jPanel3.add(jPanel8, java.awt.BorderLayout.SOUTH);

    getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);

    java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 613) / 2, (screenSize.height - 495) / 2, 613, 495);
}

From source file:FormatterFactoryDemo.java

public FormatterFactoryDemo() {
    super(new BorderLayout());
    setUpFormats();/*from  w  w  w  .  jav a 2  s .c  o  m*/
    double payment = computePayment(amount, rate, numPeriods);

    //Create the labels.
    amountLabel = new JLabel(amountString);
    rateLabel = new JLabel(rateString);
    numPeriodsLabel = new JLabel(numPeriodsString);
    paymentLabel = new JLabel(paymentString);

    //Create the text fields and set them up.
    amountField = new JFormattedTextField(new DefaultFormatterFactory(new NumberFormatter(amountDisplayFormat),
            new NumberFormatter(amountDisplayFormat), new NumberFormatter(amountEditFormat)));
    amountField.setValue(new Double(amount));
    amountField.setColumns(10);
    amountField.addPropertyChangeListener("value", this);

    NumberFormatter percentEditFormatter = new NumberFormatter(percentEditFormat) {
        public String valueToString(Object o) throws ParseException {
            Number number = (Number) o;
            if (number != null) {
                double d = number.doubleValue() * 100.0;
                number = new Double(d);
            }
            return super.valueToString(number);
        }

        public Object stringToValue(String s) throws ParseException {
            Number number = (Number) super.stringToValue(s);
            if (number != null) {
                double d = number.doubleValue() / 100.0;
                number = new Double(d);
            }
            return number;
        }
    };
    rateField = new JFormattedTextField(new DefaultFormatterFactory(new NumberFormatter(percentDisplayFormat),
            new NumberFormatter(percentDisplayFormat), percentEditFormatter));
    rateField.setValue(new Double(rate));
    rateField.setColumns(10);
    rateField.addPropertyChangeListener("value", this);

    numPeriodsField = new JFormattedTextField();
    numPeriodsField.setValue(new Integer(numPeriods));
    numPeriodsField.setColumns(10);
    numPeriodsField.addPropertyChangeListener("value", this);

    paymentField = new JFormattedTextField(paymentFormat);
    paymentField.setValue(new Double(payment));
    paymentField.setColumns(10);
    paymentField.setEditable(false);
    paymentField.setForeground(Color.red);

    //Tell accessibility tools about label/textfield pairs.
    amountLabel.setLabelFor(amountField);
    rateLabel.setLabelFor(rateField);
    numPeriodsLabel.setLabelFor(numPeriodsField);
    paymentLabel.setLabelFor(paymentField);

    //Lay out the labels in a panel.
    JPanel labelPane = new JPanel(new GridLayout(0, 1));
    labelPane.add(amountLabel);
    labelPane.add(rateLabel);
    labelPane.add(numPeriodsLabel);
    labelPane.add(paymentLabel);

    //Layout the text fields in a panel.
    JPanel fieldPane = new JPanel(new GridLayout(0, 1));
    fieldPane.add(amountField);
    fieldPane.add(rateField);
    fieldPane.add(numPeriodsField);
    fieldPane.add(paymentField);

    //Put the panels in this panel, labels on left,
    //text fields on right.
    setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
    add(labelPane, BorderLayout.CENTER);
    add(fieldPane, BorderLayout.LINE_END);
}

From source file:components.TextSamplerDemo.java

public TextSamplerDemo() {
    setLayout(new BorderLayout());

    //Create a regular text field.
    JTextField textField = new JTextField(10);
    textField.setActionCommand(textFieldString);
    textField.addActionListener(this);

    //Create a password field.
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setActionCommand(passwordFieldString);
    passwordField.addActionListener(this);

    //Create a formatted text field.
    JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime());
    ftf.setActionCommand(textFieldString);
    ftf.addActionListener(this);

    //Create some labels for the fields.
    JLabel textFieldLabel = new JLabel(textFieldString + ": ");
    textFieldLabel.setLabelFor(textField);
    JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": ");
    passwordFieldLabel.setLabelFor(passwordField);
    JLabel ftfLabel = new JLabel(ftfString + ": ");
    ftfLabel.setLabelFor(ftf);/*from  w  w w  . ja va2  s  .  c o m*/

    //Create a label to put messages during an action event.
    actionLabel = new JLabel("Type text in a field and press Enter.");
    actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    //Lay out the text controls and the labels.
    JPanel textControlsPane = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    textControlsPane.setLayout(gridbag);

    JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel };
    JTextField[] textFields = { textField, passwordField, ftf };
    addLabelTextRows(labels, textFields, gridbag, textControlsPane);

    c.gridwidth = GridBagConstraints.REMAINDER; //last
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 1.0;
    textControlsPane.add(actionLabel, c);
    textControlsPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Create a text area.
    JTextArea textArea = new JTextArea("This is an editable JTextArea. "
            + "A text area is a \"plain\" text component, " + "which means that although it can display text "
            + "in any font, all of the text is in the same font.");
    textArea.setFont(new Font("Serif", Font.ITALIC, 16));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(250, 250));
    areaScrollPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            areaScrollPane.getBorder()));

    //Create an editor pane.
    JEditorPane editorPane = createEditorPane();
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(250, 145));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    //Create a text pane.
    JTextPane textPane = createTextPane();
    JScrollPane paneScrollPane = new JScrollPane(textPane);
    paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    paneScrollPane.setPreferredSize(new Dimension(250, 155));
    paneScrollPane.setMinimumSize(new Dimension(10, 10));

    //Put the editor pane and the text pane in a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.5);
    JPanel rightPane = new JPanel(new GridLayout(1, 0));
    rightPane.add(splitPane);
    rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Put everything together.
    JPanel leftPane = new JPanel(new BorderLayout());
    leftPane.add(textControlsPane, BorderLayout.PAGE_START);
    leftPane.add(areaScrollPane, BorderLayout.CENTER);

    add(leftPane, BorderLayout.LINE_START);
    add(rightPane, BorderLayout.LINE_END);
}