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

public Test() {
    this.setBounds(100, 100, 200, 100);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.LOWERED, Color.lightGray, Color.yellow));
    //panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.RAISED, 
    //  Color.lightGray, Color.yellow));
    //panel.setBorder(BorderFactory.createSoftBevelBorder(BevelBorder.LOWERED, 
    //  Color.lightGray, Color.lightGray, Color.white, Color.orange));

    this.setLayout(new FlowLayout());

    JButton exitButton = new JButton("Exit");
    panel.add(exitButton);/*  ww w. j a v a  2  s. c  o  m*/
    this.add(panel);

    exitButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent event) {
            System.exit(0);
        }
    });
}

From source file:Buttons.java

public void init() {
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(jb);/*  ww w  .  j  av  a 2 s .c  o  m*/
    cp.add(new JToggleButton("JToggleButton"));
    cp.add(new JCheckBox("JCheckBox"));
    cp.add(new JRadioButton("JRadioButton"));
    JPanel jp = new JPanel();
    jp.setBorder(new TitledBorder("Directions"));
    jp.add(up);
    jp.add(down);
    jp.add(left);
    jp.add(right);
    cp.add(jp);
}

From source file:levelBuilder.DialogMaker.java

/**
 * First window to interact with. Offers options of load graph or new graph.
 *//*  ww  w  .ja v a  2  s .  com*/
private static void splashWindow() {
    final JFrame frame = new JFrame("Dialog Maker");

    //Handles button pushes.
    class SplashActionHandler implements ActionListener {
        @Override
        public void actionPerformed(ActionEvent e) {
            frame.dispose();
            if (e.getActionCommand().equals("loadGraph"))
                loadFilePopup();
            else
                loadGraph(true);
        }
    }

    //Loads and sets background image.
    BufferedImage img = null;
    try {
        img = ImageIO.read(new File(imgDir + "splash.png"));
    } catch (IOException e) {
        e.printStackTrace();
    }
    final BufferedImage img2 = img;
    JPanel panel = new JPanel() {
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
            g.drawImage(img2, 0, 0, null);
        }
    };

    panel.setOpaque(true);
    panel.setLayout(new BorderLayout());
    panel.setPreferredSize(new Dimension(800, 600));
    panel.setBorder(BorderFactory.createEmptyBorder(0, 0, 300, 0));

    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.setOpaque(false);

    //Buttons
    JButton loadMap = new JButton("Load Graph");
    loadMap.setActionCommand("loadGraph");
    loadMap.addActionListener(new SplashActionHandler());
    buttonPanel.add(loadMap);

    JButton newMap = new JButton("New Graph");
    newMap.setActionCommand("newGraph");
    newMap.addActionListener(new SplashActionHandler());
    buttonPanel.add(newMap);

    panel.add(buttonPanel, BorderLayout.SOUTH);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(panel);
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));
    simplePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JLabel simpleLabel = new JLabel("SIMPLE BORDERS", JLabel.CENTER);
    simplePanel.add(simpleLabel);//from ww  w .j a  v a2 s . c o m

    add(simplePanel);
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createMatteBorder(2, 5, 2, 5, Color.BLUE));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);//from   w ww.j  a  v  a 2 s .  co m
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createTitledBorder("Title Border"));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);/*from  ww  w.ja  v  a  2s  .c  o m*/
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    JLabel titleLabel = new JLabel("TITLE BORDERS", JLabel.CENTER);
    titleLabel.setForeground(Color.red.darker());

    add(simplePanel);//ww  w  .j a  va 2  s  .  c  o  m
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Title Lowered Etched Border"));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);//from   w  w w . java2s .co m
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(Color.BLUE),
            "Title Line Border with color"));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);/*from w  w  w.j ava 2 s  .co  m*/
}

From source file:Main.java

public Main() {
    JPanel simplePanel = new JPanel(new GridLayout(7, 1, 5, 5));

    simplePanel.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createRaisedBevelBorder(),
            BorderFactory.createLoweredBevelBorder()));
    simplePanel.add(new JLabel("Examples"), JLabel.CENTER);

    add(simplePanel);//from   w w  w  .  j av a 2  s  .  co m
}