Example usage for javax.swing BorderFactory createTitledBorder

List of usage examples for javax.swing BorderFactory createTitledBorder

Introduction

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

Prototype

public static TitledBorder createTitledBorder(Border border) 

Source Link

Document

Creates a new titled border with an empty title, the specified border object, the default text position (determined by the current look and feel), the default justification (leading), and the default font and text color (determined by the current look and feel).

Usage

From source file:gate.creole.kea.CorpusImporter.java

protected void initGUIComponents() {
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridy = 0;/* w  w  w . ja  v a 2 s .  co m*/
    constraints.gridx = GridBagConstraints.RELATIVE;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.BOTH;

    JPanel inputPanel = new JPanel(new GridBagLayout());
    inputPanel.setBorder(BorderFactory.createTitledBorder("Input"));
    GridBagConstraints constraints2 = new GridBagConstraints();
    constraints2.gridy = 0;
    constraints2.gridx = GridBagConstraints.RELATIVE;
    constraints2.weighty = 0;
    constraints2.weightx = 0;
    constraints2.fill = GridBagConstraints.BOTH;
    constraints2.insets = new Insets(2, 2, 2, 2);

    JLabel label = new JLabel("Source directory:");
    inputPanel.add(label, constraints2);
    sourceDirTField = new JTextField(30);
    inputPanel.add(sourceDirTField, constraints2);
    JButton openButton = new JButton(new SelectDirectoryAction());
    inputPanel.add(openButton, constraints2);

    constraints2.gridy = 1;
    label = new JLabel("Extension for text files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    textExtensionTField = new JTextField(".txt");
    inputPanel.add(textExtensionTField, constraints2);
    constraints2.gridwidth = 1;

    constraints2.gridy = 2;
    label = new JLabel("Extension for keyphrase files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    keyExtensionTField = new JTextField(".key");
    inputPanel.add(keyExtensionTField, constraints2);
    constraints2.gridwidth = 1;

    constraints2.gridy = 3;
    label = new JLabel("Encoding for input files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    encodingTField = new JTextField("");
    inputPanel.add(encodingTField, constraints2);
    constraints2.gridwidth = 1;

    add(inputPanel, constraints);
    constraints.weightx = 1;
    add(Box.createHorizontalGlue(), constraints);
    constraints.weightx = 0;

    JPanel outputPanel = new JPanel();
    outputPanel.setLayout(new GridBagLayout());
    outputPanel.setBorder(BorderFactory.createTitledBorder("Output"));

    constraints2.gridy = 0;
    label = new JLabel("Corpus name:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    corpusNameTField = new JTextField("KEA Corpus");
    constraints2.weightx = 0;
    outputPanel.add(corpusNameTField, constraints2);

    constraints2.gridy = 1;
    label = new JLabel("Output annotation set:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    annotationSetTField = new JTextField("Key");
    constraints2.weightx = 0;
    outputPanel.add(annotationSetTField, constraints2);

    constraints2.gridy = 2;
    label = new JLabel("Keyphrase annotation type:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    annotationTypeTField = new JTextField("Keyphrase");
    constraints2.weightx = 0;
    outputPanel.add(annotationTypeTField, constraints2);

    constraints.gridy = 1;
    add(outputPanel, constraints);

    constraints.gridy = 2;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.CENTER;
    add(new JButton(new ImportCorpusAction()), constraints);

    constraints.gridy = 3;
    constraints.weighty = 1;
    add(Box.createVerticalGlue(), constraints);
}

From source file:LayeredPaneDemo.java

public LayeredPaneDemo() {
    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    // Create and load the duke icon.
    final ImageIcon icon = new ImageIcon("yourFile.gif");

    // Create and set up the layered pane.
    layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(new Dimension(300, 310));
    layeredPane.setBorder(BorderFactory.createTitledBorder("Move the Mouse to Move Duke"));
    layeredPane.addMouseMotionListener(this);

    // This is the origin of the first label added.
    Point origin = new Point(10, 20);

    // This is the offset for computing the origin for the next label.
    int offset = 35;

    // Add several overlapping, colored labels to the layered pane
    // using absolute positioning/sizing.
    for (int i = 0; i < layerStrings.length; i++) {
        JLabel label = createColoredLabel(layerStrings[i], layerColors[i], origin);
        layeredPane.add(label, new Integer(i));
        origin.x += offset;/* w  ww.  j a va  2 s .  c  o  m*/
        origin.y += offset;
    }

    // Create and add the Duke label to the layered pane.
    dukeLabel = new JLabel(icon);
    if (icon != null) {
        dukeLabel.setBounds(15, 225, icon.getIconWidth(), icon.getIconHeight());
    } else {
        System.err.println("Duke icon not found; using black square instead.");
        dukeLabel.setBounds(15, 225, 30, 30);
        dukeLabel.setOpaque(true);
        dukeLabel.setBackground(Color.BLACK);
    }
    layeredPane.add(dukeLabel, new Integer(2), 0);

    // Add control pane and layered pane to this JPanel.
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(createControlPanel());
    add(Box.createRigidArea(new Dimension(0, 10)));
    add(layeredPane);
}

From source file:dk.dma.epd.shore.gui.notification.StrategicRouteNotificationDetailPanel.java

/**
 * {@inheritDoc}/*from   w w  w.  ja  v  a  2s . c o  m*/
 */
@Override
protected JPanel createInfoPanel() {
    // Initialize member variables here, since this method 
    // is called by super's constructor
    mmsiTxt = new JLabel(" ");
    nameTxt = new JLabel(" ");
    callSignTxt = new JLabel(" ");
    destinationTxt = new JLabel(" ");
    sogTxt = new JLabel(" ");

    typeTxt = new JLabel(" ");
    lengthTxt = new JLabel(" ");
    widthTxt = new JLabel(" ");
    draughtTxt = new JLabel(" ");
    cogTxt = new JLabel(" ");

    String[] infoTitles = { "MMSI:", "Name:", "Call Sign:", "Destination:", "SOG:", "Type:", "Lenght:",
            "Width:", "Draught:", "COG:" };

    infoLabels = new JLabel[] { mmsiTxt, nameTxt, callSignTxt, destinationTxt, sogTxt, typeTxt, lengthTxt,
            widthTxt, draughtTxt, cogTxt };

    int[] infoCols = { 5, 5 };

    JPanel infoPanel = new JPanel(new GridBagLayout());
    Insets insets2 = new Insets(2, 5, 2, 5);
    infoPanel.setBorder(BorderFactory.createTitledBorder("Ship Info"));
    for (int col = 0, index = 0; col < infoCols.length; col++) {
        for (int row = 0; row < infoCols[col]; row++, index++) {
            infoPanel.add(bold(new JLabel(infoTitles[index])),
                    new GridBagConstraints(col * 2, row, 1, 1, 0.0, 0.0, WEST, NONE, insets2, 0, 0));
            infoPanel.add(minSize(infoLabels[index], 40),
                    new GridBagConstraints(col * 2 + 1, row, 1, 1, 1.0, 0.0, WEST, HORIZONTAL, insets2, 0, 0));
        }
    }

    return infoPanel;
}

From source file:io.github.jeremgamer.editor.ManagerFrame.java

public ManagerFrame(String projectName, final JFrame parent) {
    dialog = this;

    ArrayList<BufferedImage> icons = new ArrayList<BufferedImage>();
    try {/*from  ww w  . j a v a  2 s.co m*/
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon16.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon32.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon64.png")));
        icons.add(ImageIO.read(ImageGetter.class.getResource("icon128.png")));
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    this.setIconImages((List<? extends Image>) icons);

    this.setTitle("Grer les projets");
    this.setSize(300, 200);
    this.setModal(true);
    this.setLocationRelativeTo(parent);
    this.setResizable(false);

    final JScrollPane scroll = new JScrollPane(content);
    scroll.getVerticalScrollBar().setUnitIncrement(Editor.SCROLL_SPEED);
    content.setBorder(BorderFactory.createTitledBorder(""));
    content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));
    for (File project : new File("projects").listFiles()) {
        if (project.getName().equals(Editor.getProjectName())) {
            content.add(new ProjectPanel(project.getName(), true, parent, this));
        } else {
            content.add(new ProjectPanel(project.getName(), false, parent, this));
        }
    }
    try {
        final JButton add = new JButton("Crer un nouveau projet",
                new ImageIcon(ImageIO.read(ImageGetter.class.getResource("add.png"))));
        newProjectPanel.add(newProjectName);
        newProjectPanel.add(validate);

        this.setLayout(new BorderLayout());
        scroll.setBorder(null);
        this.add(scroll, BorderLayout.CENTER);
        this.add(add, BorderLayout.SOUTH);

        add.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                validate.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        dispose();
                        parent.dispose();
                        new Thread(new Runnable() {
                            public void run() {
                                window.getContentPane()
                                        .add(new JLabel("",
                                                new ImageIcon(ImageGetter.class.getResource("splash.gif")),
                                                SwingConstants.CENTER));
                                window.setBackground(new Color(0, 0, 0, 0));
                                window.setSize(300, 300);
                                window.setLocationRelativeTo(null);
                                window.setVisible(true);
                            }
                        }).start();

                        new Thread(new Runnable() {
                            public void run() {
                                new Editor(newProjectName.getText());
                                window.setVisible(false);
                            }
                        }).start();
                    }
                });
                CaretListener caretUpdate = new CaretListener() {
                    public void caretUpdate(javax.swing.event.CaretEvent e) {
                        JTextField text = (JTextField) e.getSource();
                        for (File dir : new File("projects").listFiles()) {
                            if (dir.isDirectory() && text.getText().equals(dir.getName())) {
                                validate.setEnabled(false);
                                validate.setText("Existe dj");
                                break;
                            } else {
                                validate.setEnabled(true);
                                validate.setText("Crer!");
                            }
                        }
                    }
                };
                JButton cancel = null;
                try {
                    cancel = new JButton(
                            new ImageIcon(ImageIO.read(ImageGetter.class.getResource("cancel.png"))));
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
                newProjectName.addCaretListener(caretUpdate);
                remove(add);
                addPanel.setLayout(new BorderLayout());
                addPanel.add(newProjectPanel, BorderLayout.CENTER);
                addPanel.add(cancel, BorderLayout.EAST);
                add(addPanel, BorderLayout.SOUTH);
                revalidate();
                repaint();
                cancel.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent event) {
                        newProjectName.setText("");
                        remove(addPanel);
                        add(add, BorderLayout.SOUTH);
                        revalidate();
                        repaint();
                    }

                });
                newProjectName.requestFocusInWindow();
                newProjectName.requestFocus();
            }

        });
        this.setVisible(true);
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:org.jdal.swing.ApplicationContextGuiFactory.java

/**
 * //from ww  w .ja v a 2  s  .  c om
 * @param name title string
 * @return a new titled border
 * @deprecated use FormUtils.createTitledBorder instead.
 */
@Deprecated
public static Border createTitledBorder(String name) {
    Border margin = BorderFactory.createEmptyBorder(10, 10, 10, 10);
    Border title = BorderFactory.createTitledBorder(name);

    return BorderFactory.createCompoundBorder(title, margin);
}

From source file:uk.co.markfrimston.tasktree.Main.java

public Main(TaskTree taskTree) {
    super();/*from   w w w  . ja  v a2  s .co  m*/

    this.taskTree = taskTree;

    this.setTitle("Task Tree");
    this.setSize(new Dimension(300, 500));
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JPanel quickInPanel = new JPanel(new BorderLayout());
    this.quickIn = new JTextArea();
    this.quickIn.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent arg0) {
            if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
                String newText = quickIn.getText().trim();
                if (newText != null && newText.length() > 0) {
                    addTask(Main.this.taskTree.getRoot(), 0, newText, true);
                    try {
                        Main.this.taskTree.changesMade();
                    } catch (Exception e) {
                        error(e.getMessage());
                    }
                }
                quickIn.setText("");
            }
        }
    });
    this.quickIn.setPreferredSize(new Dimension(300, 75));
    this.quickIn.setBorder(BorderFactory.createTitledBorder("Quick Input"));
    quickInPanel.add(this.quickIn, BorderLayout.CENTER);
    this.syncButton = new JButton("Sync");
    this.syncButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            new SyncThread(Main.this).start();
        }
    });
    quickInPanel.add(this.syncButton, BorderLayout.EAST);
    this.getContentPane().add(quickInPanel, BorderLayout.NORTH);

    this.tree = new JTree(taskTree.getTreeModel());
    DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {
        public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
            Object newVal = htmlFilter(String.valueOf(node.getUserObject()));
            if (node.getChildCount() > 0 && !tree.isExpanded(new TreePath(node.getPath()))) {
                DefaultMutableTreeNode firstLeaf = (DefaultMutableTreeNode) node.getFirstLeaf();
                newVal = htmlFilter(String.valueOf(node.getUserObject()))
                        + " <span style='color:silver;font-style:italic'>" + "("
                        + String.valueOf(firstLeaf.getUserObject()) + ")</span>";
            }
            newVal = "<html>" + newVal + "</html>";

            return super.getTreeCellRendererComponent(tree, newVal, selected, expanded, leaf, row, hasFocus);
        }
    };
    ImageIcon bulletIcon = new ImageIcon(Main.class.getResource("bullet.gif"));
    renderer.setLeafIcon(bulletIcon);
    renderer.setOpenIcon(bulletIcon);
    renderer.setClosedIcon(bulletIcon);
    renderer.setBorder(BorderFactory.createEmptyBorder(4, 0, 4, 0));
    this.tree.setCellRenderer(renderer);
    this.tree.setRootVisible(false);
    this.tree.setShowsRootHandles(true);
    this.tree.addMouseListener(new MouseAdapter() {
        protected void doSelectRow(MouseEvent arg0) {
            int row = tree.getRowForLocation(arg0.getX(), arg0.getY());
            if (row != -1) {
                tree.setSelectionRow(row);
                if (arg0.isPopupTrigger()) {
                    popup.show(tree, arg0.getX(), arg0.getY());
                }
            }
        }

        public void mousePressed(MouseEvent arg0) {
            doSelectRow(arg0);
        }

        public void mouseReleased(MouseEvent arg0) {
            doSelectRow(arg0);
        }
    });
    JScrollPane treeScroll = new JScrollPane(tree);
    treeScroll.setBorder(BorderFactory.createTitledBorder("Task List"));
    this.getContentPane().add(treeScroll, BorderLayout.CENTER);

    this.popup = new JPopupMenu();
    JMenuItem addBefore = new JMenuItem("Add Before");
    addBefore.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            int pos = parent.getIndex(selected);
            promptAndInsert(parent, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(addBefore);
    JMenuItem addAfter = new JMenuItem("Add After");
    addAfter.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            int pos = parent.getIndex(selected) + 1;
            promptAndInsert(parent, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(addAfter);
    JMenuItem addNested = new JMenuItem("Add Nested");
    addNested.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            int pos = selected.getChildCount();
            promptAndInsert(selected, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                ex.getMessage();
            }
        }
    });
    this.popup.add(addNested);
    this.popup.add(new JSeparator());
    JMenuItem moveTop = new JMenuItem("Move to Top");
    moveTop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            moveTask(selected, parent, 0);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(moveTop);
    JMenuItem moveUp = new JMenuItem("Move Up");
    moveUp.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            int pos = Math.max(parent.getIndex(selected) - 1, 0);
            moveTask(selected, parent, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(moveUp);
    JMenuItem moveDown = new JMenuItem("Move Down");
    moveDown.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            int pos = Math.min(parent.getIndex(selected) + 1, parent.getChildCount() - 1);
            moveTask(selected, parent, pos);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(moveDown);
    JMenuItem moveBottom = new JMenuItem("Move to Bottom");
    moveBottom.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            DefaultMutableTreeNode parent = (DefaultMutableTreeNode) selected.getParent();
            moveTask(selected, parent, parent.getChildCount() - 1);
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(moveBottom);
    this.popup.add(new JSeparator());
    JMenuItem rename = new JMenuItem("Edit");
    rename.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selected = getSelectedNode();
            String newText = prompt((String) selected.getUserObject());
            if (newText != null && newText.length() > 0) {
                selected.setUserObject(newText);
                Main.this.taskTree.getTreeModel().reload(selected);
                try {
                    Main.this.taskTree.changesMade();
                } catch (Exception ex) {
                    error(ex.getMessage());
                }
            }
        }
    });
    this.popup.add(rename);
    JMenuItem delete = new JMenuItem("Delete");
    delete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            promptAndRemove(getSelectedNode());
            try {
                Main.this.taskTree.changesMade();
            } catch (Exception ex) {
                error(ex.getMessage());
            }
        }
    });
    this.popup.add(delete);

    this.setVisible(true);

    loadConfig();
    load();

    syncButton.setVisible(this.taskTree.hasSyncCapability());
}

From source file:com.actian.services.knime.core.operators.DeriveGroupNodeDialogPane.java

private void initComponents() {
    this.expression = new JTextArea(10, 20);
    expression.setWrapStyleWord(true);//  w  ww. ja  v  a 2s.c o  m
    expression.setFont(new Font("Monospaced", Font.PLAIN, 11));

    this.expressionPanel = new JScrollPane(expression);
    this.expressionPanel.setBorder(BorderFactory.createTitledBorder("Group Expressions"));

    functionPanel = new JPanel();
    functionPanel.setLayout(new GridLayout(0, 1, 0, 0));
    functionPanel.setBorder(BorderFactory.createTitledBorder("Available Aggregate Functions"));

    fcomboBox = new JComboBox();
    fcomboBox.setMaximumRowCount(10);
    fcomboBox.setModel(new DefaultComboBoxModel(new String[] { "Function - Description" }));
    fcomboBox.setFont(new Font("Monospaced", Font.PLAIN, 10));
    functionPanel.add(fcomboBox);

    GroupLayout groupLayout = new GroupLayout(this);
    groupLayout.setHorizontalGroup(groupLayout.createParallelGroup(Alignment.TRAILING).addGroup(groupLayout
            .createSequentialGroup()
            .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
                    .addGroup(Alignment.LEADING,
                            groupLayout.createSequentialGroup().addContainerGap().addComponent(columnSelect,
                                    GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE))
                    .addGroup(Alignment.LEADING,
                            groupLayout.createSequentialGroup().addGap(7).addComponent(expressionPanel,
                                    GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE))
                    .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup().addContainerGap()
                            .addComponent(functionPanel, GroupLayout.DEFAULT_SIZE, 433, Short.MAX_VALUE)))
            .addGap(7)));
    groupLayout.setVerticalGroup(groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup().addGap(5)
                    .addComponent(expressionPanel, GroupLayout.DEFAULT_SIZE, 203, Short.MAX_VALUE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(functionPanel, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE,
                            GroupLayout.PREFERRED_SIZE)
                    .addPreferredGap(ComponentPlacement.RELATED)
                    .addComponent(columnSelect, GroupLayout.PREFERRED_SIZE, 248, GroupLayout.PREFERRED_SIZE)
                    .addContainerGap()));
    setLayout(groupLayout);
}

From source file:com.floreantpos.ui.forms.QuickCustomerForm.java

private void createCustomerForm() {
    setLayout(new BorderLayout(10, 10));
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    setOpaque(true);/*from   w w w .jav a 2 s .co  m*/
    JPanel inputPanel = new JPanel();
    inputPanel.setLayout(new MigLayout("insets 10 10 10 10", "[][][][]", "[][][][][]")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    inputPanel.setBorder(BorderFactory.createTitledBorder("Enter Customer Information"));

    JLabel lblAddress = new JLabel(Messages.getString("CustomerForm.18")); //$NON-NLS-1$
    tfAddress = new JTextArea(new FixedLengthDocument(220));
    JScrollPane scrlDescription = new JScrollPane(tfAddress);
    scrlDescription.setPreferredSize(PosUIManager.getSize(338, 52));

    JLabel lblZip = new JLabel(Messages.getString("CustomerForm.21")); //$NON-NLS-1$
    tfZip = new FixedLengthTextField(30);

    JLabel lblCitytown = new JLabel(Messages.getString("CustomerForm.24")); //$NON-NLS-1$
    tfCity = new FixedLengthTextField();

    JLabel lblState = new JLabel(Messages.getString("QuickCustomerForm.0")); //$NON-NLS-1$
    tfState = new JTextField(30);

    JLabel lblCellPhone = new JLabel(Messages.getString("CustomerForm.32")); //$NON-NLS-1$

    inputPanel.add(lblCellPhone, "cell 0 1,alignx right"); //$NON-NLS-1$
    tfCellPhone = new JTextField(30);
    inputPanel.add(tfCellPhone, "cell 1 1"); //$NON-NLS-1$
    //setPreferredSize(PosUIManager.getSize(800, 350));

    JLabel lblFirstName = new JLabel(Messages.getString("CustomerForm.3")); //$NON-NLS-1$

    //inputPanel.add(lblFirstName, "cell 0 2,alignx right"); //$NON-NLS-1$
    tfFirstName = new FixedLengthTextField();
    //inputPanel.add(tfFirstName, "cell 1 2"); //$NON-NLS-1$

    JLabel lblLastName = new JLabel(Messages.getString("CustomerForm.11")); //$NON-NLS-1$

    //inputPanel.add(lblLastName, "cell 0 3,alignx right"); //$NON-NLS-1$
    tfLastName = new FixedLengthTextField();
    //inputPanel.add(tfLastName, "cell 1 3"); //$NON-NLS-1$

    JLabel lblName = new JLabel("Name"); //$NON-NLS-1$

    inputPanel.add(lblName, "cell 0 3,alignx right"); //$NON-NLS-1$
    tfName = new FixedLengthTextField();
    tfName.setLength(120);
    inputPanel.add(tfName, "cell 1 3"); //$NON-NLS-1$

    inputPanel.add(lblZip, "cell 0 4,right"); //$NON-NLS-1$
    inputPanel.add(tfZip, "cell 1 4"); //$NON-NLS-1$

    inputPanel.add(lblCitytown, "cell 0 5,right"); //$NON-NLS-1$
    inputPanel.add(tfCity, "cell 1 5"); //$NON-NLS-1$

    inputPanel.add(lblState, "cell 0 6,right"); //$NON-NLS-1$
    inputPanel.add(tfState, "cell 1 6"); //$NON-NLS-1$

    inputPanel.add(lblAddress, "cell 2 1 1 6,right"); //$NON-NLS-1$
    inputPanel.add(scrlDescription, "grow, cell 3 1 1 6"); //$NON-NLS-1$

    qwertyKeyPad = new QwertyKeyPad();

    add(inputPanel, BorderLayout.CENTER);

    if (isKeypad) {
        add(qwertyKeyPad, BorderLayout.SOUTH); //$NON-NLS-1$
    }

    tfZip.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            getStateAndCityByZipCode();
        }
    });

    tfZip.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            getStateAndCityByZipCode();
        }

        @Override
        public void focusGained(FocusEvent e) {

        }
    });

    enableCustomerFields(false);
    callOrderController();
}

From source file:com.adito.upgrade.GUIUpgrader.java

public GUIUpgrader() {
    super(new BorderLayout());
    JPanel info = new JPanel(new BorderLayout(2, 2));

    //        info.setBackground(Color.white);
    //        info.setForeground(Color.black);
    //        info.setOpaque(true);
    info.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    JLabel l = new JLabel("<html><p>This utility upgrades configuration from "
            + "one version 0.1.16 installation to another "
            + "0.2.5+ installation. You may choose which resources you "
            + "wish to be copied. If resources with the same name already " + "exist they will be left as is.");
    l.setIcon(new ImageIcon(GUIUpgrader.class.getResource("upgrader-48x48.png")));
    info.add(l, BorderLayout.CENTER);
    info.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH);
    mainPanel = new JPanel(new BorderLayout());
    add(info, BorderLayout.NORTH);
    add(mainPanel, BorderLayout.CENTER);

    // Installations panel
    JPanel installations = new JPanel(new GridBagLayout());
    installations.setBorder(BorderFactory.createTitledBorder("Installations"));
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 2.0;/*  ww  w  . j  a  va2s. c o m*/
    UIUtil.jGridBagAdd(installations, new JLabel("Source"), gbc, GridBagConstraints.REMAINDER);
    gbc.weightx = 1.0;
    source = new JTextField();
    source.getDocument().addDocumentListener(this);
    UIUtil.jGridBagAdd(installations, source, gbc, GridBagConstraints.RELATIVE);
    browseSource = new JButton("Browse");
    browseSource.setMnemonic('b');
    browseSource.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser(source.getText());
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setDialogTitle("Select source installation directory (0.16.1)");
            if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) {
                source.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    gbc.weightx = 0.0;
    UIUtil.jGridBagAdd(installations, browseSource, gbc, GridBagConstraints.REMAINDER);
    gbc.weightx = 2.0;
    UIUtil.jGridBagAdd(installations, new JLabel("Target"), gbc, GridBagConstraints.REMAINDER);
    gbc.weightx = 1.0;
    target = new JTextField(System.getProperty("user.dir"));
    target.getDocument().addDocumentListener(this);
    UIUtil.jGridBagAdd(installations, target, gbc, GridBagConstraints.RELATIVE);
    browseTarget = new JButton("Browse");
    browseTarget.setMnemonic('r');
    browseTarget.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JFileChooser chooser = new JFileChooser(target.getText());
            chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
            chooser.setDialogTitle("Select target installation directory (0.2.5+)");
            if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) {
                target.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });
    gbc.weightx = 0.0;
    UIUtil.jGridBagAdd(installations, browseTarget, gbc, GridBagConstraints.REMAINDER);
    mainPanel.add(installations, BorderLayout.NORTH);

    // Upgrade selection
    upgradeSelectionPanel = new JPanel();
    upgradeSelectionPanel.setBorder(BorderFactory.createTitledBorder("Upgrades"));
    upgradeSelectionPanel.setLayout(new BoxLayout(upgradeSelectionPanel, BoxLayout.Y_AXIS));
    mainPanel.add(upgradeSelectionPanel, BorderLayout.CENTER);

}

From source file:de.codesourcery.jasm16.ide.ui.views.EmulationOptionsView.java

public EmulationOptionsView() {
    emulatorPanel.setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE);
    emulatorPanel.add(new JLabel("Emulation speed"), cnstrs);

    cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE);
    cnstrs.anchor = GridBagConstraints.WEST;
    emulatorPanel.setBorder(BorderFactory.createTitledBorder("General options"));

    speedBox.setRenderer(new DefaultListCellRenderer() {

        public Component getListCellRendererComponent(javax.swing.JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            final java.awt.Component result = super.getListCellRendererComponent(list, value, index, isSelected,
                    cellHasFocus);/*from   w ww.  j av a2s .co m*/

            if (value != null) {
                switch ((EmulationSpeed) value) {
                case MAX_SPEED:
                    setText("Max.");
                    break;
                case REAL_SPEED:
                    setText("100 kHz");
                    break;
                default:
                    setText(value.toString());
                    break;
                }
            }
            return result;
        };
    });

    emulatorPanel.add(speedBox, cnstrs);

    // disk drive panel
    selectedFileField.setColumns(25);

    diskDrivePanel.setLayout(new GridBagLayout());
    cnstrs = constraints(0, 0, false, true, GridBagConstraints.NONE);
    cnstrs.anchor = GridBagConstraints.CENTER;

    diskDrivePanel.setBorder(BorderFactory.createTitledBorder("Disk drive"));
    diskDrivePanel.add(selectedFileField, cnstrs);

    cnstrs = constraints(1, 0, false, true, GridBagConstraints.NONE);
    cnstrs.anchor = GridBagConstraints.CENTER;
    diskDrivePanel.add(fileChooserButton, cnstrs);

    fileChooserButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final JFileChooser chooser;
            if (getSelectedFile() != null) {
                chooser = new JFileChooser(getSelectedFile().getParentFile());
            } else {
                chooser = new JFileChooser();
            }
            final int result = chooser.showOpenDialog(null);
            if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) {
                selectedFileField.setText(chooser.getSelectedFile().getAbsolutePath());
            }
        }
    });

    cnstrs = constraints(2, 0, false, true, GridBagConstraints.NONE);
    cnstrs.anchor = GridBagConstraints.CENTER;
    diskDrivePanel.add(writeProtected, cnstrs);
}