Example usage for javax.swing BorderFactory createEmptyBorder

List of usage examples for javax.swing BorderFactory createEmptyBorder

Introduction

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

Prototype

public static Border createEmptyBorder(int top, int left, int bottom, int right) 

Source Link

Document

Creates an empty border that takes up space but which does no drawing, specifying the width of the top, left, bottom, and right sides.

Usage

From source file:GUI.Main.java

static void openListOfOffresFrame(final LoginE client) throws IOException {
    System.out.println("////////////////////////////////////////////////////////////////////////////////////");
    System.out.println("////////////////////////////////////////////////////////////////////////////////////");
    System.out.println("My ID :" + client.getId());
    System.out.println("////////////////////////////////////////////////////////////////////////////////////");
    System.out.println("////////////////////////////////////////////////////////////////////////////////////");
    new SwingWorker<Void, Void>() {
        @Override/*from   w w  w. ja v a2s .c  om*/
        protected Void doInBackground() throws Exception {

            // do some processing here while the progress bar is running
            fm.setSize(500, 500);
            fm.setLocation(300, 200);
            fm.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
            fm.setLayout(new GridLayout(1, 1, 5, 5));
            try {
                fm1.add(createAdminPanel(client.getURLp(), client.getNom(), client.getPrenom(),
                        client.getId()));

            } catch (IOException ex) {
            }

            return null;
        }

        // this is called when doInBackground finished
        @Override
        protected void done() {
            //Background processing done
            //Crate new Frale and confagurated
            fm.add(fm1);
            ListOfOffresFrame = new JFrame();
            ListOfOffresFrame.setMaximizedBounds(null);
            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
            ListOfOffresFrame.setMinimumSize(dim);
            ListOfOffresFrame.setTitle("T_IMMOB");
            ListOfOffresFrame.setLayout(new GridLayout(1, 0));

            ListOfOffresFrame.setLocation(0, 0);
            ListOfOffresFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            try {
                gfl = new ListOfOffres1().createListOfOffresPanel(0, "", client.getId());
            } catch (IOException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            } catch (InterruptedException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            } catch (JSONException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
            gf2.add(new GroupPanel(GroupingType.fillLast, 0, true, fm, new WhiteSpace(), gfl));
            ListOfOffresFrame.setContentPane(gf2);
            ListOfOffresFrame.setPreferredSize(dim);
            ListOfOffresFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
            ListOfOffresFrame.setVisible(true);
            prog.setVisible(false);
            prog.dispose();
            final WebPopOver popOver = new WebPopOver(textSearchField);
            popOver.setCloseOnFocusLoss(true);
            popOver.setMargin(10);

            popOver.setLayout(new VerticalFlowLayout());
            popOver.add(new WebLabel(
                    "<html><center><font size=4>Vous pouvez faire des recherche sure</font></center></html>"));
            popOver.add(
                    new WebLabel("<html><center><font size=3>- Etat de l'offre ( Nouveau , Bon , Mauvais)"));
            popOver.add(new WebLabel(
                    "<html><center><font size=3>- Nature de l'offre ( Location , Vente )</font></center></html>"));
            popOver.add(new WebLabel(
                    "<html><center><font size=3>- Type de l'offre ( Vila , Studio , Apartemen ,</font></center></html>"));
            popOver.add(new WebLabel("<html><center><font size=3>Maison , Entrepot)</font></center></html>"));
            popOver.show(textSearchField);

        }
    }

            .execute();
}

From source file:BasicDnD.java

public BasicDnD() {
    super(new BorderLayout());
    JPanel leftPanel = createVerticalBoxPanel();
    JPanel rightPanel = createVerticalBoxPanel();

    //Create a table model.
    DefaultTableModel tm = new DefaultTableModel();
    tm.addColumn("Column 0");
    tm.addColumn("Column 1");
    tm.addColumn("Column 2");
    tm.addColumn("Column 3");
    tm.addRow(new String[] { "Table 00", "Table 01", "Table 02", "Table 03" });
    tm.addRow(new String[] { "Table 10", "Table 11", "Table 12", "Table 13" });
    tm.addRow(new String[] { "Table 20", "Table 21", "Table 22", "Table 23" });
    tm.addRow(new String[] { "Table 30", "Table 31", "Table 32", "Table 33" });

    //LEFT COLUMN
    //Use the table model to create a table.
    table = new JTable(tm);
    leftPanel.add(createPanelForComponent(table, "JTable"));

    //Create a color chooser.
    colorChooser = new JColorChooser();
    leftPanel.add(createPanelForComponent(colorChooser, "JColorChooser"));

    //RIGHT COLUMN
    //Create a textfield.
    textField = new JTextField(30);
    textField.setText("Favorite foods:\nPizza, Moussaka, Pot roast");
    rightPanel.add(createPanelForComponent(textField, "JTextField"));

    //Create a scrolled text area.
    textArea = new JTextArea(5, 30);
    textArea.setText("Favorite shows:\nBuffy, Alias, Angel");
    JScrollPane scrollPane = new JScrollPane(textArea);
    rightPanel.add(createPanelForComponent(scrollPane, "JTextArea"));

    //Create a list model and a list.
    DefaultListModel listModel = new DefaultListModel();
    listModel.addElement("Martha Washington");
    listModel.addElement("Abigail Adams");
    listModel.addElement("Martha Randolph");
    listModel.addElement("Dolley Madison");
    listModel.addElement("Elizabeth Monroe");
    listModel.addElement("Louisa Adams");
    listModel.addElement("Emily Donelson");
    list = new JList(listModel);
    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    JScrollPane listView = new JScrollPane(list);
    listView.setPreferredSize(new Dimension(300, 100));
    rightPanel.add(createPanelForComponent(listView, "JList"));

    //Create a tree.
    DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Mia Familia");
    DefaultMutableTreeNode sharon = new DefaultMutableTreeNode("Sharon");
    rootNode.add(sharon);/*  w  ww.ja  va 2 s .  c  om*/
    DefaultMutableTreeNode maya = new DefaultMutableTreeNode("Maya");
    sharon.add(maya);
    DefaultMutableTreeNode anya = new DefaultMutableTreeNode("Anya");
    sharon.add(anya);
    sharon.add(new DefaultMutableTreeNode("Bongo"));
    maya.add(new DefaultMutableTreeNode("Muffin"));
    anya.add(new DefaultMutableTreeNode("Winky"));
    DefaultTreeModel model = new DefaultTreeModel(rootNode);
    tree = new JTree(model);
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    JScrollPane treeView = new JScrollPane(tree);
    treeView.setPreferredSize(new Dimension(300, 100));
    rightPanel.add(createPanelForComponent(treeView, "JTree"));

    //Create the toggle button.
    toggleDnD = new JCheckBox("Turn on Drag and Drop");
    toggleDnD.setActionCommand("toggleDnD");
    toggleDnD.addActionListener(this);

    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel);
    splitPane.setOneTouchExpandable(true);

    add(splitPane, BorderLayout.CENTER);
    add(toggleDnD, BorderLayout.PAGE_END);
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
}

From source file:net.mariottini.swing.JFontChooser.java

/**
 * Construct a font chooser with the specified fonts, optionally showing a sample to the user. The
 * sample text is a default text, you can change it by calling <code>setSampleText</code>.
 * //from  www.  j a  v  a  2 s .  co  m
 * @param fontNames
 *          the font family names to show to the user.
 * @param showSample
 *          true to show a sample of the selected font to the user.
 * @see #setSampleText
 */
public JFontChooser(String[] fontNames, boolean showSample) {
    setLayout(new BorderLayout());

    JPanel centerPanel = new JPanel(new BorderLayout());

    // Uncomment one of the two lines below to use a standard layout manager
    // instead of my MeshLayout manager. The result is ugly.
    // JPanel listsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));/*
    // JPanel listsPanel = new JPanel(new GridLayout(0, 3));/*
    net.mariottini.layout.MeshLayout mesh = new net.mariottini.layout.MeshLayout(0, 3, 0);
    mesh.setExpandColumn(0);
    JPanel listsPanel = new JPanel(mesh);// */

    JPanel panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(8, 8, 8, 8));
    panel.add(new JLabel("Family name:"), BorderLayout.NORTH);
    fontList = new JList<>(fontNames);
    fontList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    fontList.setVisibleRowCount(7);
    fontList.setSelectedIndex(0);
    panel.add(new JScrollPane(fontList), BorderLayout.CENTER);
    listsPanel.add(panel);

    panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 8));
    panel.add(new JLabel("Style:"), BorderLayout.NORTH);
    styleList = new JList<>(STYLE_NAMES);
    styleList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    styleList.setVisibleRowCount(7);
    styleList.setSelectedIndex(0);
    panel.add(new JScrollPane(styleList), BorderLayout.CENTER);
    listsPanel.add(panel);

    panel = new JPanel(new BorderLayout());
    panel.setBorder(BorderFactory.createEmptyBorder(8, 0, 8, 8));
    panel.add(new JLabel("Size:"), BorderLayout.NORTH);
    JPanel sizePanel = new JPanel(new BorderLayout());
    sizeText = new JTextField(String.valueOf(SIZES[0]), 4);
    sizePanel.add(sizeText, BorderLayout.NORTH);
    sizeList = new JList<>(ArrayUtils.toObject(SIZES));
    sizeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    sizeList.setVisibleRowCount(6);
    sizePanel.add(new JScrollPane(sizeList), BorderLayout.CENTER);
    panel.add(sizePanel, BorderLayout.CENTER);
    listsPanel.add(panel);

    centerPanel.add(listsPanel, BorderLayout.NORTH);

    samplePanel = new JPanel(new BorderLayout());
    samplePanel.setBorder(BorderFactory.createEmptyBorder(0, 8, 4, 8));
    samplePanel.add(new JLabel("Sample:"), BorderLayout.NORTH);
    sampleLabel = new JLabel(DEFAULT_SAMPLE_TEXT, JLabel.CENTER);
    sampleLabel.setMinimumSize(new Dimension(64, 48));
    sampleLabel.setOpaque(true);
    sampleLabel.setBackground(sizeList.getBackground());
    sampleLabel.setBorder(sizeText.getBorder());
    samplePanel.add(sampleLabel, BorderLayout.CENTER);
    samplePanel.setVisible(showSample);
    centerPanel.add(samplePanel, BorderLayout.CENTER);

    add(centerPanel, BorderLayout.CENTER);

    accessoryPanel = new JPanel(new BorderLayout());
    accessoryPanel.setBorder(BorderFactory.createEmptyBorder(8, 0, 4, 8));
    accessoryComponent = new JLabel("Accessory");
    accessoryComponent.setOpaque(true);
    accessoryComponent.setBackground(sizeList.getBackground());
    accessoryPanel.add(accessoryComponent, BorderLayout.CENTER);
    accessoryPanel.setVisible(false);
    add(accessoryPanel, BorderLayout.EAST);

    JPanel southPanel = new JPanel(new BorderLayout());
    southPanel.add(new JLabel(), BorderLayout.CENTER);
    JPanel buttonsPanel = new JPanel();
    ActionListener actionListener = new ButtonActionListener();
    JButton button = new JButton("OK");
    button.addActionListener(actionListener);
    button.setActionCommand(APPROVE_SELECTION);
    buttonsPanel.add(button);
    button = new JButton("Cancel");
    button.addActionListener(actionListener);
    button.setActionCommand(CANCEL_SELECTION);
    buttonsPanel.add(button);
    southPanel.add(buttonsPanel, BorderLayout.EAST);
    add(southPanel, BorderLayout.SOUTH);

    // * Fix list size (optional)
    Dimension d = fontList.getPreferredSize();
    d.width += 6;
    fontList.setPreferredSize(d);
    d = styleList.getPreferredSize();
    d.width += 6;
    styleList.setPreferredSize(d);
    d = sizeList.getPreferredSize();
    d.width += 6;
    sizeList.setPreferredSize(d);
    // */

    // Fix sample size
    Dimension pref = sampleLabel.getPreferredSize();
    Dimension min = sampleLabel.getMinimumSize();
    pref.width += 16;
    pref.height += 12;
    if (pref.width < min.width) {
        pref.width = min.width;
    }
    if (pref.height < min.height) {
        pref.height = min.height;
    }
    sampleLabel.setPreferredSize(pref);

    // set listener
    SampleListener pl = new SampleListener();
    fontList.addListSelectionListener(pl);
    styleList.addListSelectionListener(pl);
    sizeList.addListSelectionListener(pl);
    sizeList.addListSelectionListener(new SizeListListener());
    sizeText.getDocument().addDocumentListener(new SizeTextListener());
    sizeText.addFocusListener(new SizeTextFocusListener());
    sizeList.setSelectedIndex(5);
}

From source file:com.web.vehiclerouting.optaplanner.common.swingui.SolverAndPersistenceFrame.java

private JComponent createQuickOpenPanel(List<Action> quickOpenActionList, List<File> fileList, String title) {
    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    if (fileList.isEmpty()) {
        JLabel noneLabel = new JLabel("None");
        noneLabel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
        panel.add(noneLabel);/*  w w w.  java  2  s.c  o m*/
    } else {
        for (File file : fileList) {
            Action quickOpenAction = new QuickOpenAction(file);
            quickOpenActionList.add(quickOpenAction);
            JButton quickOpenButton = new JButton(quickOpenAction);
            quickOpenButton.setHorizontalAlignment(SwingConstants.LEFT);
            quickOpenButton.setMargin(new Insets(0, 0, 0, 0));
            panel.add(quickOpenButton);
        }
    }
    JScrollPane scrollPane = new JScrollPane(panel);
    scrollPane.getVerticalScrollBar().setUnitIncrement(25);
    scrollPane.setMinimumSize(new Dimension(100, 80));
    // Size fits into screen resolution 1024*768
    scrollPane.setPreferredSize(new Dimension(180, 200));
    JPanel titlePanel = new JPanel(new BorderLayout());
    titlePanel.add(scrollPane, BorderLayout.CENTER);
    titlePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2),
            BorderFactory.createTitledBorder(title)));
    return titlePanel;
}

From source file:org.obiba.onyx.jade.instrument.summitdoppler.VantageABIInstrumentRunner.java

protected JPanel buildMeasureCountSubPanel() {
    // Add the results sub panel.
    JPanel panel = new JPanel();

    panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));

    panel.add(measureCountLabel = new MeasureCountLabel());

    panel.setAlignmentX(Component.LEFT_ALIGNMENT);

    return (panel);
}

From source file:org.esa.beam.visat.toolviews.diag.TileCacheMonitor.java

/**
 * Creates a new monitor panel.//from  ww w  .  j ava2s . c  o m
 *
 * @return the monitor panel
 */
public JPanel createPanel() {

    JPanel mainPanel = new JPanel(new BorderLayout());
    CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new DateAxis("Time"));
    this.datasets = new TimeSeriesCollection[4];
    this.datasets[0] = addSubPlot(plot, "#Tiles");
    this.datasets[1] = addSubPlot(plot, "#Hits");
    this.datasets[2] = addSubPlot(plot, "#Misses");
    this.datasets[3] = addSubPlot(plot, "Mem (kB)");

    JFreeChart chart = new JFreeChart(plot);
    LegendTitle legend = (LegendTitle) chart.getSubtitle(0);
    legend.setPosition(RectangleEdge.RIGHT);
    legend.setMargin(new RectangleInsets(UnitType.ABSOLUTE, 0, 4, 0, 4));
    chart.setBorderPaint(Color.black);
    chart.setBorderVisible(true);
    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.setAxisOffset(new RectangleInsets(4, 4, 4, 4));
    ValueAxis axis = plot.getDomainAxis();
    axis.setAutoRange(true);
    axis.setFixedAutoRange(60000.0); // 60 seconds

    textarea = new JTextArea();
    tableModel = new TileCacheTableModel();
    ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new java.awt.Dimension(500, 470));
    chartPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    tabbedPane = new JTabbedPane();
    tabbedPane.add(CACHE_INFO_TAB, new JScrollPane(textarea));
    tabbedPane.add(CACHE_CHART_TAB, chartPanel);
    tabbedPane.add(IMAGES_TAB, new JScrollPane(new JTable(tableModel)));
    tabbedPane.setSelectedIndex(0);

    mainPanel.add(tabbedPane);

    return mainPanel;
}

From source file:components.ListDialog.java

private ListDialog(Frame frame, Component locationComp, String labelText, String title, Object[] data,
        String initialValue, String longValue) {
    super(frame, title, true);

    //Create and initialize the buttons.
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(this);
    //// ww  w  .j ava2 s  .  c  om
    final JButton setButton = new JButton("Set");
    setButton.setActionCommand("Set");
    setButton.addActionListener(this);
    getRootPane().setDefaultButton(setButton);

    //main part of the dialog
    list = new JList(data) {
        //Subclass JList to workaround bug 4832765, which can cause the
        //scroll pane to not let the user easily scroll up to the beginning
        //of the list.  An alternative would be to set the unitIncrement
        //of the JScrollBar to a fixed value. You wouldn't get the nice
        //aligned scrolling, but it should work.
        public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
            int row;
            if (orientation == SwingConstants.VERTICAL && direction < 0
                    && (row = getFirstVisibleIndex()) != -1) {
                Rectangle r = getCellBounds(row, row);
                if ((r.y == visibleRect.y) && (row != 0)) {
                    Point loc = r.getLocation();
                    loc.y--;
                    int prevIndex = locationToIndex(loc);
                    Rectangle prevR = getCellBounds(prevIndex, prevIndex);

                    if (prevR == null || prevR.y >= r.y) {
                        return 0;
                    }
                    return prevR.height;
                }
            }
            return super.getScrollableUnitIncrement(visibleRect, orientation, direction);
        }
    };

    list.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
    if (longValue != null) {
        list.setPrototypeCellValue(longValue); //get extra space
    }
    list.setLayoutOrientation(JList.HORIZONTAL_WRAP);
    list.setVisibleRowCount(-1);
    list.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                setButton.doClick(); //emulate button click
            }
        }
    });
    JScrollPane listScroller = new JScrollPane(list);
    listScroller.setPreferredSize(new Dimension(250, 80));
    listScroller.setAlignmentX(LEFT_ALIGNMENT);

    //Create a container so that we can add a title around
    //the scroll pane.  Can't add a title directly to the
    //scroll pane because its background would be white.
    //Lay out the label and scroll pane from top to bottom.
    JPanel listPane = new JPanel();
    listPane.setLayout(new BoxLayout(listPane, BoxLayout.PAGE_AXIS));
    JLabel label = new JLabel(labelText);
    label.setLabelFor(list);
    listPane.add(label);
    listPane.add(Box.createRigidArea(new Dimension(0, 5)));
    listPane.add(listScroller);
    listPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    //Lay out the buttons from left to right.
    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS));
    buttonPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));
    buttonPane.add(Box.createHorizontalGlue());
    buttonPane.add(cancelButton);
    buttonPane.add(Box.createRigidArea(new Dimension(10, 0)));
    buttonPane.add(setButton);

    //Put everything together, using the content pane's BorderLayout.
    Container contentPane = getContentPane();
    contentPane.add(listPane, BorderLayout.CENTER);
    contentPane.add(buttonPane, BorderLayout.PAGE_END);

    //Initialize values.
    setValue(initialValue);
    pack();
    setLocationRelativeTo(locationComp);
}

From source file:com.intel.stl.ui.monitor.view.PSNodesDetailsPanel.java

/**
 * Description:/*from   w w  w . j a  va  2  s.c  om*/
 * 
 * @param name
 */
protected void initComponent() {
    setLayout(new BorderLayout(0, 0));
    setOpaque(false);
    setBorder(BorderFactory.createTitledBorder((Border) null));

    JPanel titlePanel = new JPanel(new BorderLayout(5, 1));
    titlePanel.setOpaque(false);
    numberLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    numberLabel.setHorizontalAlignment(JLabel.RIGHT);
    titlePanel.add(numberLabel, BorderLayout.CENTER);
    nameLabel = ComponentFactory.getH3Label("", Font.PLAIN);
    nameLabel.setHorizontalAlignment(JLabel.LEFT);
    nameLabel.setVerticalAlignment(JLabel.BOTTOM);
    titlePanel.add(nameLabel, BorderLayout.EAST);
    add(titlePanel, BorderLayout.NORTH);

    JPanel mainPanel = new JPanel();
    mainPanel.setOpaque(false);
    mainPanel.setBorder(BorderFactory.createEmptyBorder(0, 2, 0, 2));
    GridBagLayout gridBag = new GridBagLayout();
    mainPanel.setLayout(gridBag);
    GridBagConstraints gc = new GridBagConstraints();

    gc.weighty = 0;
    gc.insets = new Insets(8, 2, 2, 2);
    gc.weightx = 1;
    gc.gridwidth = 1;
    gc.gridheight = 2;
    // gc.gridheight = 3; // Should change to 3 if we add Route
    typeChartPanel = new ChartPanel(null);
    typeChartPanel.setPreferredSize(new Dimension(80, 60));
    mainPanel.add(typeChartPanel, gc);

    gc.fill = GridBagConstraints.BOTH;
    gc.insets = new Insets(12, 2, 2, 2);
    gc.weightx = 0;
    gc.gridheight = 1;
    swNumberLabel = createNumberLabel();
    mainPanel.add(swNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    swNameLabel = createNameLabel(STLConstants.K0048_SWITCHES.getValue());
    mainPanel.add(swNameLabel, gc);

    gc.insets = new Insets(2, 2, 6, 2);
    gc.gridwidth = 1;
    fiNumberLabel = createNumberLabel();
    mainPanel.add(fiNumberLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    fiNameLabel = createNameLabel(STLConstants.K0052_HOSTS.getValue());
    mainPanel.add(fiNameLabel, gc);

    // gc.gridwidth = 1;
    // rtNumberLabel = ComponentFactory.getH4Label(
    // STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    // rtNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    // mainPanel.add(rtNumberLabel, gc);
    //
    // gc.gridwidth = GridBagConstraints.REMAINDER;
    // rtNameLabel = ComponentFactory.getH5Label(
    // STLConstants.K0050_ROUTERS.getValue(), Font.PLAIN);
    // rtNameLabel.setVerticalAlignment(JLabel.BOTTOM);
    // mainPanel.add(rtNameLabel, gc);

    add(mainPanel, BorderLayout.CENTER);

    JPanel bottomPanel = new JPanel(new GridBagLayout());
    bottomPanel.setOpaque(false);
    bottomPanel.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 0, UIConstants.INTEL_BORDER_GRAY));
    gc = new GridBagConstraints();
    gc.insets = new Insets(0, 5, 1, 5);
    gc.fill = GridBagConstraints.BOTH;
    gc.weightx = 1;
    gc.gridheight = 2;
    otherPortsLabel = ComponentFactory.getH1Label(STLConstants.K0039_NOT_AVAILABLE.getValue(), Font.PLAIN);
    otherPortsLabel.setForeground(UIConstants.INTEL_GRAY);
    otherPortsLabel.setHorizontalAlignment(JLabel.RIGHT);
    bottomPanel.add(otherPortsLabel, gc);

    gc.gridwidth = GridBagConstraints.REMAINDER;
    gc.gridheight = 1;
    gc.weightx = 0;
    gc.weighty = 1;
    JLabel label = ComponentFactory.getH4Label(STLConstants.K1026_PORT_RESOURCE.getValue(), Font.PLAIN);
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setVerticalAlignment(JLabel.BOTTOM);
    bottomPanel.add(label, gc);

    gc.weighty = 0;
    label = ComponentFactory.getH4Label(STLConstants.K2077_NOT_IN_FABRIC.getValue(), Font.PLAIN);
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setVerticalAlignment(JLabel.BOTTOM);
    bottomPanel.add(label, gc);
    add(bottomPanel, BorderLayout.SOUTH);
}

From source file:FormatterFactoryDemo.java

public FormatterFactoryDemo() {
    super(new BorderLayout());
    setUpFormats();/* w w w .ja 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(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:com.sshtools.common.ui.SshToolsConnectionProxyTab.java

/**
 * Creates a new SshToolsConnectionProxyTab object.
 *///w  ww. ja v a 2s  . c  om
public SshToolsConnectionProxyTab() {
    super();
    group.add(noProxy);
    group.add(httpProxy);
    group.add(socks4Proxy);
    group.add(socks5Proxy);

    ChangeListener listener = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (noProxy.isSelected()) {
                username.setEnabled(false);
                password.setEnabled(false);
                proxy.setEnabled(false);

                //port.setEnabled(false);
                port.setForeground(Color.white);
            } else {
                username.setEnabled(true);
                password.setEnabled(true);
                proxy.setEnabled(true);

                //port.setEnabled(true);
                port.setForeground(Color.black);

                if (httpProxy.isSelected()) {
                    port.setText("80");
                } else {
                    port.setText("1080");
                }
            }
        }
    };

    noProxy.getModel().addChangeListener(listener);
    httpProxy.getModel().addChangeListener(listener);
    socks4Proxy.getModel().addChangeListener(listener);
    socks5Proxy.getModel().addChangeListener(listener);

    //  Create the main connection details panel
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(0, 2, 2, 2);
    gbc.weightx = 1.0;
    proxyframe.setBorder(BorderFactory.createTitledBorder("Connect using the following proxy"));

    //  No proxy label
    gbc.insets = new Insets(2, 10, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, noProxy, gbc, GridBagConstraints.RELATIVE);

    // Socks 4 label
    gbc.insets = new Insets(2, 15, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, socks4Proxy, gbc, GridBagConstraints.REMAINDER);

    //gbc.fill = GridBagConstraints.HORIZONTAL;
    // Http Proxy
    gbc.insets = new Insets(2, 10, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, httpProxy, gbc, GridBagConstraints.RELATIVE);

    // Socks 5 label
    gbc.insets = new Insets(2, 15, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, socks5Proxy, gbc, GridBagConstraints.REMAINDER);

    gbc.insets = new Insets(2, 10, 2, 10);

    JPanel connect = new JPanel(new GridBagLayout());
    connect.setBorder(BorderFactory.createTitledBorder("Proxy Details"));
    UIUtil.jGridBagAdd(connect, new JLabel("Host"), gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, proxy, gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, new JLabel("Port"), gbc, GridBagConstraints.REMAINDER);
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;

    UIUtil.jGridBagAdd(connect, port, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.HORIZONTAL;

    UIUtil.jGridBagAdd(connect, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, username, gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, new JLabel("Password"), gbc, GridBagConstraints.REMAINDER);
    gbc.insets = new Insets(2, 10, 10, 10);
    UIUtil.jGridBagAdd(connect, password, gbc, GridBagConstraints.REMAINDER);

    JPanel main = new JPanel(new GridBagLayout());
    gbc.insets = new Insets(2, 2, 2, 2);
    UIUtil.jGridBagAdd(main, proxyframe, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, connect, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(PROXY_ICON), main);
    noProxy.setSelected(true);

    //  This panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    add(iconProxyDetailsPanel, BorderLayout.NORTH);
}