Example usage for javax.swing.border LineBorder LineBorder

List of usage examples for javax.swing.border LineBorder LineBorder

Introduction

In this page you can find the example usage for javax.swing.border LineBorder LineBorder.

Prototype

public LineBorder(Color color) 

Source Link

Document

Creates a line border with the specified color and a thickness = 1.

Usage

From source file:Main.java

public static void main(String[] argv) {
    LineBorder border = new LineBorder(Color.red);
    TitledBorder titledBorder = BorderFactory.createTitledBorder(border, "Title");
}

From source file:Main.java

public static void main(String[] argv) {
    LineBorder border = new LineBorder(Color.red);
    TitledBorder titledBorder = BorderFactory.createTitledBorder(border, "Title");

    // Or: DEFAULT_JUSTIFICATION, LEFT, RIGHT
    titledBorder.setTitleJustification(TitledBorder.CENTER);
}

From source file:Main.java

public static void main(String[] argv) {
    LineBorder border = new LineBorder(Color.red);
    TitledBorder titledBorder = BorderFactory.createTitledBorder(border, "Title");

    // Or: DEFAULT_POSITION, ABOVE_TOP, TOP, ABOVE_BOTTOM, BOTTOM, BELOW_BOTTOM
    titledBorder.setTitlePosition(TitledBorder.BELOW_TOP);
}

From source file:Main.java

License:asdf

public static void main(String[] argv) {
    LineBorder border1 = new LineBorder(Color.red);
    TitledBorder border2 = new TitledBorder("asdf");

    Border newBorder = BorderFactory.createCompoundBorder(border1, border2);
    JButton component = new JButton("button");
    component.setBorder(newBorder);// w  w w .j av a 2s  .  c  om
}

From source file:Main.java

public static void main(String[] args) {
    JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT));
    statusBar.setBorder(new CompoundBorder(new LineBorder(Color.DARK_GRAY), new EmptyBorder(4, 4, 4, 4)));
    final JLabel status = new JLabel();
    statusBar.add(status);//w  ww. j  a  v  a2 s.  com

    JLabel content = new JLabel("Content in the middle");
    content.setHorizontalAlignment(JLabel.CENTER);

    final JFrame frame = new JFrame("Test");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(content);
    frame.add(statusBar, BorderLayout.SOUTH);

    frame.addComponentListener(new ComponentAdapter() {
        @Override
        public void componentResized(ComponentEvent e) {
            status.setText(frame.getWidth() + "x" + frame.getHeight());
        }
    });

    frame.setBounds(20, 20, 200, 200);
    frame.setVisible(true);
}

From source file:ATitledBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Border thisBorder = BorderFactory.createTitledBorder("Easy");

    Border thatBorder1 = new LineBorder(Color.RED);
    Border thatBorder2 = new TitledBorder(thatBorder1, "Harder");

    Font font = new Font("Serif", Font.ITALIC, 12);
    Border thatBorder = new TitledBorder(thatBorder2, "Harder", TitledBorder.LEFT, TitledBorder.ABOVE_BOTTOM,
            font, Color.RED);//w w w . j av  a2  s  .  c o m

    JButton thisButton = new JButton("Easy");
    thisButton.setBorder(thisBorder);

    JButton thatButton = new JButton("Harder");
    thatButton.setBorder(thatBorder);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(1, 2));
    contentPane.add(thisButton);
    contentPane.add(thatButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:MainClass.java

public static void main(String args[]) throws Exception {
    JFrame frame = new JFrame("Cornering Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JButton button = new JButton("+");

    JLabel bigLabel = new JLabel("A");
    bigLabel.setPreferredSize(new Dimension(400, 400));
    bigLabel.setBorder(new LineBorder(Color.red));

    JScrollPane scrollPane = new JScrollPane(bigLabel);
    scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, button);
    scrollPane.setColumnHeaderView(new JLabel("B"));
    scrollPane.setRowHeaderView(new JLabel("C"));

    ActionListener actionListener = new JScrollPaneToTopAction(scrollPane);
    button.addActionListener(actionListener);

    frame.add(scrollPane, BorderLayout.CENTER);
    frame.setSize(300, 200);// w w w  .  j  av a  2  s  . co m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 11, 212, 500);
    frame.getContentPane().add(scrollPane);

    JTree tree = new JTree(addNodes(new File(".")));
    tree.setRootVisible(false);/*from w  ww.j a  va 2 s  . c om*/
    tree.setShowsRootHandles(true);

    tree.setBorder(new LineBorder(new Color(0, 0, 0)));
    tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    scrollPane.setViewportView(tree);

    tree.setCellRenderer(new FileTreeCellRenderer());

    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {

    JFrame f = new JFrame();
    f.setTitle("Example2");
    f.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);

    JPanel p1 = new JPanel(new FlowLayout(FlowLayout.CENTER));
    p1.setBorder(new TitledBorder(new LineBorder(Color.BLACK), "JPanel 1"));
    for (int i = 0; i < NB1; i++)
        p1.add(new JButton("Button " + i));

    JPanel p2 = new JPanel(new FlowLayout(FlowLayout.CENTER));

    p2.setBorder(new TitledBorder(new LineBorder(Color.BLACK), "JPanel 2"));
    for (int i = NB1; i < NB2; i++)
        p2.add(new JButton("Button " + i));

    JPanel p3 = new JPanel(new FlowLayout(FlowLayout.CENTER));
    p3.setBorder(new TitledBorder(new LineBorder(Color.BLACK), "JPanel 3"));
    for (int i = NB2; i < NB3; i++)
        p3.add(new JButton("Button " + i));

    JPanel global = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL; // added
    gbc.weightx = 1.0f; // added
    gbc.gridy = 0;//from   w  w w . j  a v a 2  s . c  o  m
    global.add(p1, gbc);
    gbc.gridy++;
    global.add(p2, gbc);
    gbc.gridy++;
    global.add(p3, gbc);

    f.add(global);
    f.pack();
    f.setVisible(true);

}

From source file:Main.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Tabbed Pane Sample");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JLabel label = new JLabel("Label");
    label.setPreferredSize(new Dimension(1000, 1000));
    JScrollPane jScrollPane = new JScrollPane(label);

    JButton jButton1 = new JButton();

    jScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    jScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    jScrollPane.setViewportBorder(new LineBorder(Color.RED));
    jScrollPane.getViewport().add(jButton1, null);

    frame.add(jScrollPane, BorderLayout.CENTER);
    frame.setSize(400, 150);/*from  w  w w  .  ja  va  2 s  . c om*/
    frame.setVisible(true);
}