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

public TRescaleOp() {
    super();/*from   ww w  . j a va 2 s  .c o  m*/
    Container container = getContentPane();

    displayPanel = new DisplayPanel();
    container.add(displayPanel);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 2));
    panel.setBorder(new TitledBorder("Click a Button to Perform the Associated Operation..."));

    brightenButton = new JButton("Brightness >>");
    brightenButton.addActionListener(new ButtonListener());
    darkenButton = new JButton("Brightness <<");
    darkenButton.addActionListener(new ButtonListener());

    contIncButton = new JButton("Contrast >>");
    contIncButton.addActionListener(new ButtonListener());
    contDecButton = new JButton("Contrast <<");
    contDecButton.addActionListener(new ButtonListener());

    panel.add(brightenButton);
    panel.add(darkenButton);
    panel.add(contIncButton);
    panel.add(contDecButton);

    container.add(BorderLayout.SOUTH, panel);

    addWindowListener(new WindowEventHandler());
    setSize(displayPanel.getWidth(), displayPanel.getHeight() + 10);
    show(); // Display the frame
}

From source file:brainflow.core.ImageBrowser.java

private void initSourceView() {
    sourceView = new JList();
    final DefaultListModel model = new DefaultListModel();
    for (IImageSource source : sourceList.sourceList) {
        model.addElement(source);/*from   www .  ja  v a2  s .  c  o m*/
    }

    sourceView.setModel(model);
    sourceView.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    ButtonPanel panel = new ButtonPanel(SwingConstants.CENTER);

    JButton nextButton = new JButton("Next");
    ImageIcon icon = new ImageIcon(getClass().getClassLoader().getResource("icons/control_play_blue.png"));
    nextButton.setIcon(icon);

    JButton prevButton = new JButton("Previous");
    icon = new ImageIcon(getClass().getClassLoader().getResource("icons/control_rev_blue.png"));
    prevButton.setIcon(icon);
    panel.addButton(prevButton);
    panel.addButton(nextButton);
    panel.setSizeConstraint(ButtonPanel.SAME_SIZE);

    JPanel container = new JPanel(new BorderLayout());
    container.setBorder(new TitledBorder("Image List"));
    container.add(new JScrollPane(sourceView), BorderLayout.CENTER);
    container.add(panel, BorderLayout.SOUTH);
    add(container, BorderLayout.WEST);

    nextButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            int index = sourceView.getSelectedIndex();
            if (index == (sourceList.size() - 1)) {
                index = 0;
            } else {
                index++;
            }

            updateView(index);

        }
    });

    sourceView.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        @Override
        public void valueChanged(ListSelectionEvent e) {
            int index = sourceView.getSelectedIndex();
            if (currentModel.getSelectedLayer().getDataSource() != sourceView.getSelectedValue()) {
                System.out.println("updating view");
                updateView(index);
            } else {
                System.out.println("not updating view ");
            }

        }
    });
}

From source file:com.jcraft.weirdx.XRexec.java

public XRexec(String myName, int num) {
    try {//from  w ww  . j a  va  2  s  .c  o  m
        InetAddress local = null;
        if (myName != null && myName.length() > 0) {
            local = InetAddress.getByName(myName);
        } else {
            local = InetAddress.getLocalHost();
        }
        display = local.getHostName() + ":" + num + ".0";
    } catch (Exception e) {
        display = "localhost:" + num + ".0";
        LOG.error(e);
    }

    JFrame jframe = new JFrame();
    Container cpane = jframe.getContentPane();
    cpane.setLayout(new GridLayout(0, 1));

    JPanel jpanel = null;

    jpanel = new JPanel();
    jpanel.setBorder(BorderFactory.createTitledBorder("Host"));
    jpanel.setLayout(new BorderLayout());
    host.setText("");
    host.setMinimumSize(new Dimension(50, 25));
    host.setEditable(true);
    jpanel.add(host, "Center");
    cpane.add(jpanel);

    jpanel = new JPanel();
    jpanel.setBorder(BorderFactory.createTitledBorder("User"));
    jpanel.setLayout(new BorderLayout());
    name.setText("");
    name.setMinimumSize(new Dimension(50, 25));
    name.setEditable(true);
    jpanel.add(name, "Center");
    cpane.add(jpanel);

    jpanel = new JPanel();
    jpanel.setBorder(BorderFactory.createTitledBorder("Password"));
    jpanel.setLayout(new BorderLayout());
    passwd.setMinimumSize(new Dimension(50, 25));
    passwd.setEditable(true);
    jpanel.add(passwd, "Center");
    cpane.add(jpanel);

    jpanel = new JPanel();
    jpanel.setBorder(BorderFactory.createTitledBorder("Command with Absolute Path"));
    jpanel.setLayout(new BorderLayout());
    command.setText("");
    command.setMinimumSize(new Dimension(50, 25));
    command.setEditable(true);
    jpanel.add(command, "Center");
    command.addActionListener(this);
    cpane.add(jpanel);

    jpanel = new JPanel();
    jpanel.add(rexec, "Center");
    rexec.addActionListener(this);
    cpane.add(jpanel);

    jframe.pack();
    jframe.setVisible(true);
}

From source file:components.ColorChooserDemo2.java

public ColorChooserDemo2() {
    super(new BorderLayout());

    //Set up banner to use as custom preview panel
    banner = new JLabel("Welcome to the Tutorial Zone!", JLabel.CENTER);
    banner.setForeground(Color.yellow);
    banner.setBackground(Color.blue);
    banner.setOpaque(true);/*from   w ww . j  av  a  2 s.  c  o  m*/
    banner.setFont(new Font("SansSerif", Font.BOLD, 24));
    banner.setPreferredSize(new Dimension(100, 65));

    JPanel bannerPanel = new JPanel(new BorderLayout());
    bannerPanel.add(banner, BorderLayout.CENTER);
    bannerPanel.setBorder(BorderFactory.createTitledBorder("Banner"));

    //Set up color chooser for setting background color
    JPanel panel = new JPanel(); //use FlowLayout
    JButton bcc = new JButton("Show Color Chooser...");
    bcc.addActionListener(this);
    panel.add(bcc);
    panel.setBorder(BorderFactory.createTitledBorder("Choose Background Color"));

    //Set up color chooser for setting text color
    tcc = new JColorChooser();
    tcc.getSelectionModel().addChangeListener(this);
    tcc.setBorder(BorderFactory.createTitledBorder("Choose Text Color"));

    //Remove the preview panel
    tcc.setPreviewPanel(new JPanel());

    //Override the chooser panels with our own
    AbstractColorChooserPanel panels[] = { new CrayonPanel() };
    tcc.setChooserPanels(panels);
    tcc.setColor(banner.getForeground());

    add(bannerPanel, BorderLayout.PAGE_START);
    add(panel, BorderLayout.CENTER);
    add(tcc, BorderLayout.PAGE_END);
}

From source file:EditableTree.java

public EditableTree() {
    DefaultMutableTreeNode forums = new DefaultMutableTreeNode("A");
    forums.add(new DefaultMutableTreeNode("B"));
    DefaultMutableTreeNode articles = new DefaultMutableTreeNode("E");
    articles.add(new DefaultMutableTreeNode("F"));
    DefaultMutableTreeNode examples = new DefaultMutableTreeNode("G");
    examples.add(new DefaultMutableTreeNode("H"));

    m_rootNode.add(forums);//from   ww  w  .  j  a v a  2 s .com
    m_rootNode.add(articles);
    m_rootNode.add(examples);

    m_tree.setEditable(true);
    m_tree.setSelectionRow(0);

    JScrollPane scrollPane = new JScrollPane(m_tree);
    getContentPane().add(scrollPane, BorderLayout.CENTER);

    JPanel panel = new JPanel();

    m_addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) m_tree.getLastSelectedPathComponent();
            if (selNode == null) {
                return;
            }
            DefaultMutableTreeNode newNode = new DefaultMutableTreeNode("New Node");
            m_model.insertNodeInto(newNode, selNode, selNode.getChildCount());

            TreeNode[] nodes = m_model.getPathToRoot(newNode);
            TreePath path = new TreePath(nodes);
            m_tree.scrollPathToVisible(path);
            m_tree.setSelectionPath(path);
            m_tree.startEditingAtPath(path);
        }
    });
    panel.add(m_addButton);

    m_delButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode selNode = (DefaultMutableTreeNode) m_tree.getLastSelectedPathComponent();
            removeNode(selNode);
        }
    });
    panel.add(m_delButton);

    JPanel searchPanel = new JPanel();
    searchPanel.setBorder(BorderFactory.createEtchedBorder());

    m_searchText = new JTextField(10);
    searchPanel.add(m_searchText);

    m_searchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode node = searchNode(m_searchText.getText());
            if (node != null) {
                TreeNode[] nodes = m_model.getPathToRoot(node);
                TreePath path = new TreePath(nodes);
                m_tree.scrollPathToVisible(path);
                m_tree.setSelectionPath(path);
            } else {
                System.out.println("Node with string " + m_searchText.getText() + " not found");
            }
        }
    });
    searchPanel.add(m_searchButton);

    m_searchAndDeleteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            DefaultMutableTreeNode node = searchNode(m_searchText.getText());
            if (node != null) {
                removeNode(node);
            } else {
                System.out.println("Node with string " + m_searchText.getText() + " not found");
            }
        }
    });
    searchPanel.add(m_searchAndDeleteButton);
    panel.add(searchPanel);
    getContentPane().add(panel, BorderLayout.SOUTH);
    setSize(700, 400);
    setVisible(true);
}

From source file:com.idealista.solrmeter.view.statistic.PieChartPanel.java

private Component createCustomizePanel() {
    JButton jButtonCustomize = new JButton(I18n.get("statistic.pieChartPanel.customize"));
    jButtonCustomize.addActionListener(new ActionListener() {

        @Override/*from   w w w . j ava2s  . com*/
        public void actionPerformed(ActionEvent e) {
            JDialogCustomizePieChart dialog = new JDialogCustomizePieChart(SolrMeterMain.mainFrame,
                    timeRangeStatistic);
            dialog.setVisible(true);
        }

    });

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));
    panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 10));
    panel.add(Box.createHorizontalGlue());
    panel.add(jButtonCustomize);

    return panel;
}

From source file:com.emental.mindraider.ui.dialogs.SearchConceptAnnotation.java

/**
 * Constructor./*from w w  w .jav a  2s.c o m*/
 */
public SearchConceptAnnotation(AbstractTextAnnotationRenderer renderer) {
    super("Search Annotation");

    this.renderer = renderer;

    JPanel dialogPanel = new JPanel();
    dialogPanel.setBorder(new EmptyBorder(5, 10, 0, 10));
    dialogPanel.setLayout(new BorderLayout());

    JPanel contentAndButtons = new JPanel(new GridLayout(2, 1));
    JPanel contentPanel = new JPanel(new BorderLayout());

    // 1a.
    // TODO add help like in eclipse
    contentPanel.add(new JLabel(Messages.getString("FtsJDialog.searchString")), BorderLayout.NORTH);
    // 1b.
    searchCombo = new JComboBox(history.toArray());
    searchCombo.setSelectedItem("");
    searchCombo.setPreferredSize(new Dimension(200, 18));
    searchCombo.setEditable(true);
    searchCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if ("comboBoxEdited".equals(e.getActionCommand())) {
                search();
            }
        }
    });
    contentPanel.add(searchCombo, BorderLayout.SOUTH);
    contentAndButtons.add(contentPanel);

    // 2.
    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5));
    JButton searchButton = new JButton(Messages.getString("FtsJDialog.searchButton"));
    searchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            search();
        }
    });
    p.add(searchButton);

    JButton cancelButton = new JButton(Messages.getString("FtsJDialog.cancel"));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    p.add(cancelButton);

    contentAndButtons.add(p);

    dialogPanel.add(contentAndButtons, BorderLayout.CENTER);

    getContentPane().add(dialogPanel, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);
}

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

@Override
public JComponent createContentPanel() {
    // TODO use here nicer layout, maybe with an icon

    JPanel panel = new JPanel(new BorderLayout(10, 10));
    panel.setBorder(BorderFactory.createEmptyBorder(20, 40, 40, 40));

    JLabel label = new JLabel("<html>An error occured!<br/>" + exception.toString() + "</html>");
    label.setHorizontalAlignment(SwingConstants.LEFT);
    panel.add(label, BorderLayout.CENTER);
    panel.add(new JLabel(Icons.IC_DIALOG_ERROR_LARGE), BorderLayout.WEST);
    setSize(panel.getPreferredSize());//w  ww.j av a2  s . c  o m
    return panel;
}

From source file:ConvolveApp.java

public ConvolveApp() {
    super();//from   www.  j a  v  a 2  s  .  com
    Container container = getContentPane();

    displayPanel = new CPanel();
    container.add(displayPanel);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 2));
    panel.setBorder(new TitledBorder("Click a Button to Perform the Associated Operation and Reset..."));

    sharpenButton = new JButton("Sharpen");
    sharpenButton.addActionListener(new ButtonListener());
    blurringButton = new JButton("Blur");
    blurringButton.addActionListener(new ButtonListener());
    edButton = new JButton("Edge Detect");
    edButton.addActionListener(new ButtonListener());
    resetButton = new JButton("Reset");
    resetButton.addActionListener(new ButtonListener());

    panel.add(sharpenButton);
    panel.add(blurringButton);
    panel.add(edButton);
    panel.add(resetButton);

    container.add(BorderLayout.SOUTH, panel);

    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
    setSize(displayPanel.getWidth(), displayPanel.getHeight() + 10);
    setVisible(true);
}

From source file:InternalFrameEventDemo.java

protected void createDisplayWindow() {
    JButton b1 = new JButton("Show internal frame");
    b1.setActionCommand(SHOW);/*  w w  w .j a  v  a 2 s  . c o  m*/
    b1.addActionListener(this);

    JButton b2 = new JButton("Clear event info");
    b2.setActionCommand(CLEAR);
    b2.addActionListener(this);

    display = new JTextArea(3, 30);
    display.setEditable(false);
    JScrollPane textScroller = new JScrollPane(display);
    // Have to supply a preferred size, or else the scroll
    // area will try to stay as large as the text area.
    textScroller.setPreferredSize(new Dimension(200, 75));
    textScroller.setMinimumSize(new Dimension(10, 10));

    displayWindow = new JInternalFrame("Event Watcher", true, // resizable
            false, // not closable
            false, // not maximizable
            true); // iconifiable
    JPanel contentPane = new JPanel();
    contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    b1.setAlignmentX(CENTER_ALIGNMENT);
    contentPane.add(b1);
    contentPane.add(Box.createRigidArea(new Dimension(0, 5)));
    contentPane.add(textScroller);
    contentPane.add(Box.createRigidArea(new Dimension(0, 5)));
    b2.setAlignmentX(CENTER_ALIGNMENT);
    contentPane.add(b2);

    displayWindow.setContentPane(contentPane);
    displayWindow.pack();
    displayWindow.setVisible(true);
}