Example usage for javax.swing JPanel setBorder

List of usage examples for javax.swing JPanel setBorder

Introduction

In this page you can find the example usage for javax.swing JPanel setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:de.atomfrede.tools.evalutation.ui.ExceptionDialog.java

public JComponent createDetailsPanel() {
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    exception.printStackTrace(pw);/*from  ww  w. j  ava 2s  .c  om*/
    JTextArea textArea = new JTextArea(sw.toString());
    // textArea.setRows(10);

    JLabel label = new JLabel("Details:");

    JPanel panel = new JPanel(new BorderLayout(6, 6));
    panel.add(new JScrollPane(textArea));
    panel.add(label, BorderLayout.BEFORE_FIRST_LINE);
    label.setLabelFor(textArea);
    panel.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10));

    setSize((int) panel.getPreferredSize().getWidth() + 20, getHeight() + 95);
    setMinimumSize(getSize());
    setMaximumSize(new Dimension(getSize().width, getSize().height + 150));
    panel.setMaximumSize(new Dimension((int) getMaximumSize().getWidth(), 150));
    return panel;
}

From source file:net.daboross.outputtablesclient.gui.OutputInterface.java

@Override
public void onUpdate(final RobotTable table, final String key, final String value, final UpdateAction action) {
    if (!application.getOutput().getNameTable().contains(table.getName())) {
        return;/*from ww  w  .j a va  2 s  .c  om*/
    }
    if (action == UpdateAction.NEW) {
        //            if (key.equalsIgnoreCase(":RangeGUI")) {
        //                Output.oLog("Range: %s", value);
        //                try {
        //                    application.getCustomInterface().setTo(Double.parseDouble(value));
        //                } catch (NumberFormatException ex) {
        //                    Output.oLog("Invalid range '%s'", value);
        //                }
        //            }
        ensureTableExists(table.getName());
        JPanel panel = new JPanel(new GridBagLayout());
        panel.setBorder(new LineBorder(Color.BLACK));
        tableKeyAndKeyToValuePanel.get(table.getName()).put(key, panel);

        JLabel keyLabel = new JLabel(key);
        keyLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
        panel.add(keyLabel, new GBC().fill(GridBagConstraints.VERTICAL).gridy(0));

        JSeparator separator = new JSeparator(JSeparator.VERTICAL);
        separator.setPreferredSize(new Dimension(2, 20));
        panel.add(separator, new GBC().fill(GridBagConstraints.VERTICAL).gridy(0));

        JLabel valueLabel = new JLabel(value);
        valueLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
        panel.add(valueLabel, new GBC().fill(GridBagConstraints.VERTICAL).gridy(0));
        tableKeyAndKeyToValueLabel.get(table.getName()).put(key, valueLabel);

        JPanel parentPanel = tableKeyToTablePanel.get(table.getName());
        parentPanel.add(panel);
        parentPanel.revalidate();
    } else if (action == UpdateAction.UPDATE) {
        //            if (key.equalsIgnoreCase(":RangeGUI")) {
        //                Output.oLog("Range: %s", value);
        //                try {
        //                    application.getCustomInterface().setTo(Double.parseDouble(value));
        //                } catch (NumberFormatException ex) {
        //                    Output.oLog("Invalid range '%s'", value);
        //                }
        //            }
        ensureTableExists(table.getName());
        JLabel valueLabel = tableKeyAndKeyToValueLabel.get(table.getName()).get(key);
        valueLabel.setText(value);
    } else if (action == UpdateAction.DELETE) {
        if (tableKeyToTablePanel.get(table.getName()) == null) {
            return;
        }
        JPanel parentPanel = tableKeyToTablePanel.get(table.getName());
        JPanel valuePanel = tableKeyAndKeyToValuePanel.get(table.getName()).remove(key);
        parentPanel.remove(valuePanel);
        parentPanel.revalidate();
    }
}

From source file:net.sf.housekeeper.swing.FoodEditorView.java

/**
 * Builds a bar with OK and Cancel buttons.
 * //from   w w w.  jav a 2  s  . c  om
 * @return The button bar.
 */
private JPanel buildButtonBar() {
    JPanel bar = ButtonBarFactory.buildOKCancelBar(okButton, cancelButton);
    bar.setBorder(Borders.BUTTON_BAR_GAP_BORDER);
    return bar;
}

From source file:L2RTreeLayoutDemo.java

public L2RTreeLayoutDemo() {

    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();//from   w w  w. j  ava  2 s . c  om

    treeLayout = new TreeLayout<String, Integer>(graph);
    radialLayout = new RadialTreeLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    vv = new VisualizationViewer<String, Integer>(treeLayout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings();

    setLtoR(vv);

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Radial");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, treeLayout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout,
                        treeLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                setLtoR(vv);
                vv.removePreRenderPaintable(rings);
            }

            vv.repaint();
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);

    content.add(controls, BorderLayout.SOUTH);
}

From source file:com.floreantpos.ui.OrderFilterPanel.java

private void createOrderTypeFilterPanel() {
    OrderTypeFilterButton btnFilterByOrderTypeALL = new OrderTypeFilterButton(POSConstants.ALL);

    JPanel filterByOrderPanel = new JPanel(new MigLayout("", "fill, grow", "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    filterByOrderPanel.setBorder(new TitledBorder(Messages.getString("SwitchboardView.4"))); //$NON-NLS-1$

    ButtonGroup orderTypeGroup = new ButtonGroup();
    orderTypeGroup.add(btnFilterByOrderTypeALL);

    filterByOrderPanel.add(btnFilterByOrderTypeALL);

    List<OrderType> orderTypes = Application.getInstance().getOrderTypes();
    for (OrderType orderType : orderTypes) {
        OrderTypeFilterButton orderTypeFilterButton = new OrderTypeFilterButton(orderType.getName());
        orderTypeGroup.add(orderTypeFilterButton);
        filterByOrderPanel.add(orderTypeFilterButton);
    }//from   w w w.ja v  a  2  s.  c  o  m

    getContentPane().add(filterByOrderPanel);
}

From source file:gisintegration.SimpleSwingBrowser.java

private void initComponents() {
    createScene();// w  w  w  . java2s.  co m

    //        ActionListener al = new ActionListener() {
    //            @Override
    //            public void actionPerformed(ActionEvent e) {
    //                loadURL(txtURL.getText());
    //            }
    //        };
    //
    //        btnGo.addActionListener(al);
    //        txtURL.addActionListener(al);

    progressBar.setPreferredSize(new Dimension(150, 18));
    progressBar.setStringPainted(true);

    //        JPanel topBar = new JPanel(new BorderLayout(5, 0));
    //        topBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    //        topBar.add(txtURL, BorderLayout.CENTER);
    //        topBar.add(btnGo, BorderLayout.EAST);

    JPanel statusBar = new JPanel(new BorderLayout(5, 0));
    statusBar.setBorder(BorderFactory.createEmptyBorder(3, 5, 3, 5));
    statusBar.add(lblStatus, BorderLayout.CENTER);
    statusBar.add(progressBar, BorderLayout.EAST);

    //panel.add(topBar, BorderLayout.NORTH);
    panel.add(jfxPanel, BorderLayout.CENTER);
    panel.add(statusBar, BorderLayout.SOUTH);

    setLayout(new BorderLayout());
    add(panel, BorderLayout.CENTER);

    //        setPreferredSize(new Dimension(1024, 600));
    //        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    //        pack();

}

From source file:com.apatar.ui.JSubmitHelpDialog.java

private void createDialog() {
    setLayout(new BorderLayout(5, 5));

    setSize(400, 400);//ww w  .  java2  s.com

    JPanel textPanel = new JPanel(new BorderLayout(5, 5));
    textPanel.setBorder(new EmptyBorder(10, 5, 5, 5));
    text.setLineWrap(true);
    text.setWrapStyleWord(true);
    text.setFont(UiUtils.NORMAL_SIZE_12_FONT);

    textPanel.add(new JLabel("If you found a bug, please submit it here:"), BorderLayout.NORTH);
    textPanel.add(new JScrollPane(text), BorderLayout.CENTER);

    JPanel contactPanel = new JPanel();
    contactPanel.setLayout(new BoxLayout(contactPanel, BoxLayout.Y_AXIS));

    JPanel firstNamePanel = new JPanel();
    firstNamePanel.setLayout(new BoxLayout(firstNamePanel, BoxLayout.X_AXIS));
    firstNamePanel.add(new JLabel("Your First Name:"));
    firstNamePanel.add(Box.createHorizontalStrut(5));
    firstNamePanel.add(firstNameField);

    JPanel lastNamePanel = new JPanel();
    lastNamePanel.setLayout(new BoxLayout(lastNamePanel, BoxLayout.X_AXIS));
    lastNamePanel.add(new JLabel("Your Last Name:"));
    lastNamePanel.add(Box.createHorizontalStrut(5));
    lastNamePanel.add(lastNameField);

    JPanel emailPanel = new JPanel();
    emailPanel.setLayout(new BoxLayout(emailPanel, BoxLayout.X_AXIS));
    emailPanel.add(new JLabel("Your E-mail:"));
    emailPanel.add(Box.createHorizontalStrut(28));
    emailPanel.add(emailField);

    contactPanel.add(firstNamePanel);
    contactPanel.add(Box.createVerticalStrut(5));
    contactPanel.add(lastNamePanel);
    contactPanel.add(Box.createVerticalStrut(5));
    contactPanel.add(emailPanel);

    textPanel.add(contactPanel, BorderLayout.SOUTH);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS));
    buttonPanel.add(Box.createHorizontalGlue());
    buttonPanel.add(sendButton);
    buttonPanel.add(Box.createHorizontalStrut(5));
    buttonPanel.add(cancel);
    buttonPanel.add(Box.createHorizontalStrut(5));
    buttonPanel.setBorder(new EmptyBorder(0, 0, 5, 0));

    getContentPane().add(textPanel, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
}

From source file:edu.uci.ics.jung.samples.L2RTreeLayoutDemo.java

@SuppressWarnings({ "unchecked", "rawtypes" })
public L2RTreeLayoutDemo() {

    // create a simple graph for the demo
    graph = new DelegateForest<String, Integer>();

    createTree();// ww w  .jav  a2s. c  om

    treeLayout = new TreeLayout<String, Integer>(graph);
    radialLayout = new RadialTreeLayout<String, Integer>(graph);
    radialLayout.setSize(new Dimension(600, 600));
    vv = new VisualizationViewer<String, Integer>(treeLayout, new Dimension(600, 600));
    vv.setBackground(Color.white);
    vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
    vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
    vv.getRenderContext().setArrowFillPaintTransformer(new ConstantTransformer(Color.lightGray));
    rings = new Rings();

    setLtoR(vv);

    Container content = getContentPane();
    final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
    content.add(panel);

    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);

    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1.1f, vv.getCenter());
        }
    });
    JButton minus = new JButton("-");
    minus.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            scaler.scale(vv, 1 / 1.1f, vv.getCenter());
        }
    });

    JToggleButton radial = new JToggleButton("Radial");
    radial.addItemListener(new ItemListener() {

        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {

                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, treeLayout,
                        radialLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                vv.addPreRenderPaintable(rings);
            } else {
                LayoutTransition<String, Integer> lt = new LayoutTransition<String, Integer>(vv, radialLayout,
                        treeLayout);
                Animator animator = new Animator(lt);
                animator.start();
                vv.getRenderContext().getMultiLayerTransformer().setToIdentity();
                setLtoR(vv);
                vv.removePreRenderPaintable(rings);
            }

            vv.repaint();
        }
    });

    JPanel scaleGrid = new JPanel(new GridLayout(1, 0));
    scaleGrid.setBorder(BorderFactory.createTitledBorder("Zoom"));

    JPanel controls = new JPanel();
    scaleGrid.add(plus);
    scaleGrid.add(minus);
    controls.add(radial);
    controls.add(scaleGrid);
    controls.add(modeBox);

    content.add(controls, BorderLayout.SOUTH);
}

From source file:cool.pandora.modeller.ui.jpanel.iiif.CreateSequencesFrame.java

private JPanel createComponents() {
    final Border border = new EmptyBorder(5, 5, 5, 5);

    final TitlePane titlePane = new TitlePane();
    initStandardCommands();//from w  ww .j a  v  a2s .  c om
    final JPanel pageControl = new JPanel(new BorderLayout());
    final JPanel titlePaneContainer = new JPanel(new BorderLayout());
    titlePane.setTitle(bagView.getPropertyMessage("CreateSequencesFrame.title"));
    titlePane.setMessage(new DefaultMessage(bagView.getPropertyMessage("Create Sequence in:")));
    titlePaneContainer.add(titlePane.getControl());
    titlePaneContainer.add(new JSeparator(), BorderLayout.SOUTH);
    pageControl.add(titlePaneContainer, BorderLayout.NORTH);
    final JPanel contentPane = new JPanel();

    final DefaultBag bag = bagView.getBag();
    if (bag != null) {
        map = bag.getInfo().getFieldMap();
    }

    final JLabel urlLabel = new JLabel(bagView.getPropertyMessage("baseURL.label"));
    urlLabel.setToolTipText(bagView.getPropertyMessage("baseURL.description"));
    final JTextField urlField = new JTextField("");
    final URI uri = IIIFObjectURI.getSequenceContainerURI(map);
    try {
        urlField.setText(uri != null ? uri.toString() : null);
    } catch (final Exception e) {
        log.error("Failed to set url label", e);
    }

    final JLabel sequenceIDLabel = new JLabel(bagView.getPropertyMessage("sequenceID.label"));
    sequenceIDLabel.setToolTipText(bagView.getPropertyMessage("sequenceID.description"));
    sequenceIDField = new JTextField("normal");
    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints glbc = new GridBagConstraints();
    final JPanel panel = new JPanel(layout);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    int row = 0;

    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(urlLabel, glbc);
    panel.add(urlLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(urlField, glbc);
    panel.add(urlField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    layout.setConstraints(sequenceIDLabel, glbc);
    panel.add(sequenceIDLabel);
    buildConstraints(glbc, 1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);
    layout.setConstraints(sequenceIDField, glbc);
    panel.add(sequenceIDField);
    row++;
    buildConstraints(glbc, 0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST);
    buildConstraints(glbc, 1, row, 2, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER);

    GuiStandardUtils.attachDialogBorder(contentPane);
    pageControl.add(panel);
    final JComponent buttonBar = createButtonBar();
    pageControl.add(buttonBar, BorderLayout.SOUTH);

    this.pack();
    return pageControl;

}

From source file:be.ac.ua.comp.scarletnebula.gui.addserverwizard.ChooseImagePage.java

private JPanel getSearchPanel(final TableRowSorter<MachineImageTableModel> sorter) {
    final JPanel searchPanel = new JPanel(new GridBagLayout());
    searchPanel.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));

    add(searchPanel, BorderLayout.NORTH);
    final PlatformComboBox platformComboBox = new PlatformComboBox();

    final GridBagConstraints c = new GridBagConstraints();
    c.weightx = 0.0;// ww  w . j a  v  a 2  s.  c  o m
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 5);

    searchPanel.add(platformComboBox, c);
    final ArchitectureComboBox architectureComboBox = new ArchitectureComboBox();

    c.gridx = 1;
    searchPanel.add(architectureComboBox, c);

    final BetterTextField searchField = new BetterTextField();
    searchField.setPlaceHolder("Search terms");

    searchField.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));

    c.gridx = 2;
    c.weightx = 1.0;
    c.insets = new Insets(0, 0, 0, 0);
    searchPanel.add(searchField, c);

    searchField.addActionListener(
            new SearchFieldListener(architectureComboBox, sorter, platformComboBox, searchField));

    return searchPanel;
}