Example usage for javax.swing.border EtchedBorder EtchedBorder

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

Introduction

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

Prototype

public EtchedBorder() 

Source Link

Document

Creates a lowered etched border whose colors will be derived from the background color of the component passed into the paintBorder method.

Usage

From source file:MainClass.java

public static void main(String[] args) {
    JFrame aWindow = new JFrame("This is a Box Layout");
    aWindow.setBounds(200, 200, 200, 200);
    aWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    Box left = Box.createVerticalBox();
    left.add(Box.createVerticalStrut(30));
    ButtonGroup radioGroup = new ButtonGroup();
    JRadioButton rbutton;/*from  w w w. ja va  2  s  .c  o m*/
    radioGroup.add(rbutton = new JRadioButton("Red"));
    left.add(rbutton);
    left.add(Box.createVerticalStrut(30));
    radioGroup.add(rbutton = new JRadioButton("Green"));
    left.add(rbutton);
    left.add(Box.createVerticalStrut(30));
    radioGroup.add(rbutton = new JRadioButton("Blue"));
    left.add(rbutton);
    left.add(Box.createVerticalStrut(30));
    radioGroup.add(rbutton = new JRadioButton("Yellow"));
    left.add(rbutton);

    left.add(Box.createGlue());

    JPanel leftPanel = new JPanel(new BorderLayout());
    leftPanel.setBorder(new TitledBorder(new EtchedBorder(), "Line Color"));
    leftPanel.add(left, BorderLayout.CENTER);

    Box right = Box.createVerticalBox();
    right.add(Box.createVerticalStrut(30));
    right.add(new JCheckBox("Dashed"));
    right.add(Box.createVerticalStrut(30));
    right.add(new JCheckBox("Thick"));
    right.add(Box.createVerticalStrut(30));
    right.add(new JCheckBox("Rounded"));

    right.add(Box.createGlue());

    JPanel rightPanel = new JPanel(new BorderLayout());
    rightPanel.setBorder(new TitledBorder(new EtchedBorder(), "Line Properties"));
    rightPanel.add(right, BorderLayout.CENTER);

    Box top = Box.createHorizontalBox();
    top.add(leftPanel);
    top.add(Box.createHorizontalStrut(5));
    top.add(rightPanel);

    Container content = aWindow.getContentPane();
    content.setLayout(new BorderLayout());
    content.add(top, BorderLayout.CENTER);

    BoxLayout box = new BoxLayout(content, BoxLayout.Y_AXIS);

    content.setLayout(box);
    content.add(top);

    aWindow.setVisible(true);
}

From source file:Main.java

public Main() {
    JCheckBox m_chkBold = new JCheckBox("Bold");
    m_chkBold.setMnemonic('b');
    m_chkBold.setToolTipText("Bold font");
    add(m_chkBold);/*from   ww w  .ja v  a  2s  . c  o m*/
    setBorder(new TitledBorder(new EtchedBorder(), "Effects"));
    JCheckBox m_chkItalic = new JCheckBox("Italic");
    m_chkItalic.setMnemonic('i');
    m_chkItalic.setToolTipText("Italic font");
    add(m_chkItalic);
    JCheckBox m_chkUnderline = new JCheckBox("Underline");
    m_chkUnderline.setMnemonic('u');
    m_chkUnderline.setToolTipText("Underline font");
    add(m_chkUnderline);
    JCheckBox m_chkStrikethrough = new JCheckBox("Strikethrough");
    m_chkStrikethrough.setMnemonic('r');
    m_chkStrikethrough.setToolTipText("Strikethrough font");
    add(m_chkStrikethrough);
    JCheckBox m_chkSubscript = new JCheckBox("Subscript");
    m_chkSubscript.setMnemonic('t');
    m_chkSubscript.setToolTipText("Subscript font");
    add(m_chkSubscript);
    JCheckBox m_chkSuperscript = new JCheckBox("Superscript");
    m_chkSuperscript.setMnemonic('p');
    m_chkSuperscript.setToolTipText("Superscript font");
    add(m_chkSuperscript);

}

From source file:CheckBoxMnemonic.java

public CheckBoxMnemonic() {
    JCheckBox m_chkBold = new JCheckBox("Bold");
    m_chkBold.setMnemonic('b');
    m_chkBold.setToolTipText("Bold font");
    add(m_chkBold);//from w w w .j  av a 2  s .  co  m
    setBorder(new TitledBorder(new EtchedBorder(), "Effects"));
    JCheckBox m_chkItalic = new JCheckBox("Italic");
    m_chkItalic.setMnemonic('i');
    m_chkItalic.setToolTipText("Italic font");
    add(m_chkItalic);
    JCheckBox m_chkUnderline = new JCheckBox("Underline");
    m_chkUnderline.setMnemonic('u');
    m_chkUnderline.setToolTipText("Underline font");
    add(m_chkUnderline);
    JCheckBox m_chkStrikethrough = new JCheckBox("Strikethrough");
    m_chkStrikethrough.setMnemonic('r');
    m_chkStrikethrough.setToolTipText("Strikethrough font");
    add(m_chkStrikethrough);
    JCheckBox m_chkSubscript = new JCheckBox("Subscript");
    m_chkSubscript.setMnemonic('t');
    m_chkSubscript.setToolTipText("Subscript font");
    add(m_chkSubscript);
    JCheckBox m_chkSuperscript = new JCheckBox("Superscript");
    m_chkSuperscript.setMnemonic('p');
    m_chkSuperscript.setToolTipText("Superscript font");
    add(m_chkSuperscript);

}

From source file:Main.java

public SplashScreen() {
    Container container = getContentPane();

    JPanel panel = new JPanel();
    panel.setBorder(new EtchedBorder());
    container.add(panel, BorderLayout.CENTER);

    JLabel label = new JLabel("Hello World!");
    label.setFont(new Font("Verdana", Font.BOLD, 14));
    panel.add(label);/*  w w w .ja va  2  s . co  m*/

    progressBar.setMaximum(PROGBAR_MAX);
    container.add(progressBar, BorderLayout.SOUTH);
    pack();
    setVisible(true);
    startProgressBar();
}

From source file:MenuActionExample.java

public MenuActionExample() {
    super(true);/*  www .ja va2s  .c  o  m*/

    // Create a menu bar and give it a bevel border.
    menuBar = new JMenuBar();
    menuBar.setBorder(new BevelBorder(BevelBorder.RAISED));

    // Create a menu and add it to the menu bar.
    JMenu menu = new JMenu("Menu");
    menuBar.add(menu);

    // Create a toolbar and give it an etched border.
    toolBar = new JToolBar();
    toolBar.setBorder(new EtchedBorder());

    // Instantiate a sample action with the NAME property of
    // "Download" and the appropriate SMALL_ICON property.
    SampleAction exampleAction = new SampleAction("Download", new ImageIcon("action.gif"));

    // Finally, add the sample action to the menu and the toolbar.
    // These methods are no longer preferred:
    // menu.add(exampleAction);
    // toolBar.add(exampleAction);
    // Instead, you should create actual menu items and buttons:
    JMenuItem exampleItem = new JMenuItem(exampleAction);
    JButton exampleButton = new JButton(exampleAction);
    menu.add(exampleItem);
    toolBar.add(exampleButton);
}

From source file:Main.java

public Main() {
    setSize(500, 340);//from w ww . ja va2s. com

    Date currentDate = new Date();
    calendar.setTime(currentDate);

    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(4, 1));

    JPanel p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Selected Date"));
    dateLabel = new JLabel(dateFormat.format(currentDate) + "     ");
    dateLabel.setFont(new Font("Arial", Font.BOLD, 24));
    p.add(dateLabel);
    p1.add(p);

    yearSlider.setPaintLabels(true);
    yearSlider.setMajorTickSpacing(5);
    yearSlider.setMinorTickSpacing(1);
    yearSlider.setPaintTicks(true);
    DateListener lst = new DateListener();
    yearSlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Year"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(yearSlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    String[] months = (new DateFormatSymbols()).getShortMonths();
    hashTable = new Hashtable(12);
    for (int i = 0; i < 12; i++)
        hashTable.put(new Integer(i + 1), new JLabel(months[i], JLabel.CENTER));
    monthSlider.setLabelTable(hashTable);
    monthSlider.setPaintLabels(true);
    monthSlider.setMajorTickSpacing(1);
    monthSlider.setPaintTicks(true);
    monthSlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Month"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(monthSlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

    int maxDays = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
    daySlider = new JSlider(JSlider.HORIZONTAL, 1, maxDays, calendar.get(Calendar.DAY_OF_MONTH));
    daySlider.setPaintLabels(true);
    daySlider.setMajorTickSpacing(5);
    daySlider.setMinorTickSpacing(1);
    daySlider.setPaintTicks(true);
    daySlider.addChangeListener(lst);

    p = new JPanel();
    p.setBorder(new TitledBorder(new EtchedBorder(), "Day"));
    p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS));
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p.add(daySlider);
    p.add(Box.createRigidArea(RIGID_DIMENSION));
    p1.add(p);

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

    WindowListener wndCloser = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(wndCloser);

    enableEvents(ComponentEvent.COMPONENT_RESIZED);
    setVisible(true);
}

From source file:BoxLayoutPane.java

public BoxLayoutPane() {
    // Use a BorderLayout layout manager to arrange various Box components
    this.setLayout(new BorderLayout());

    // Give the entire panel a margin by adding an empty border
    // We could also do this by overriding getInsets()
    this.setBorder(new EmptyBorder(10, 10, 10, 10));

    // Add a plain row of buttons along the top of the pane
    Box row = Box.createHorizontalBox();
    for (int i = 0; i < 4; i++) {
        JButton b = new JButton("B" + i);
        b.setFont(new Font("serif", Font.BOLD, 12 + i * 2));
        row.add(b);/*from  www  .  j a v a 2  s. c  o m*/
    }
    this.add(row, BorderLayout.NORTH);

    // Add a plain column of buttons along the right edge
    // Use BoxLayout with a different kind of Swing container
    // Give the column a border: can't do this with the Box class
    JPanel col = new JPanel();
    col.setLayout(new BoxLayout(col, BoxLayout.Y_AXIS));
    col.setBorder(new TitledBorder(new EtchedBorder(), "Column"));
    for (int i = 0; i < 4; i++) {
        JButton b = new JButton("Button " + i);
        b.setFont(new Font("sanserif", Font.BOLD, 10 + i * 2));
        col.add(b);
    }
    this.add(col, BorderLayout.EAST); // Add column to right of panel

    // Add a button box along the bottom of the panel.
    // Use "Glue" to space the buttons evenly
    Box buttonbox = Box.createHorizontalBox();
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Okay"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Cancel"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    buttonbox.add(new JButton("Help"));
    buttonbox.add(Box.createHorizontalGlue()); // stretchy space
    this.add(buttonbox, BorderLayout.SOUTH);

    // Create a component to display in the center of the panel
    JTextArea textarea = new JTextArea();
    textarea.setText("This component has 12-pixel margins on left and top"
            + " and has 72-pixel margins on right and bottom.");
    textarea.setLineWrap(true);
    textarea.setWrapStyleWord(true);

    // Use Box objects to give the JTextArea an unusual spacing
    // First, create a column with 3 kids. The first and last kids
    // are rigid spaces. The middle kid is the text area
    Box fixedcol = Box.createVerticalBox();
    fixedcol.add(Box.createVerticalStrut(12)); // 12 rigid pixels
    fixedcol.add(textarea); // Component fills in the rest
    fixedcol.add(Box.createVerticalStrut(72)); // 72 rigid pixels

    // Now create a row. Give it rigid spaces on the left and right,
    // and put the column from above in the middle.
    Box fixedrow = Box.createHorizontalBox();
    fixedrow.add(Box.createHorizontalStrut(12));
    fixedrow.add(fixedcol);
    fixedrow.add(Box.createHorizontalStrut(72));

    // Now add the JTextArea in the column in the row to the panel
    this.add(fixedrow, BorderLayout.CENTER);
}

From source file:fxts.stations.ui.ApplicationFrame.java

/**
 * Fires creation of menu, statusbar and toolbar.
 *//*  w  w w .j a v  a  2 s.  c  o m*/
public void create() {
    //creating of the toolbar
    mToolBar = createToolBar();
    //creating of the statusbar
    mStatusBar = createStatusBar();
    //creating of the menu
    mMenuBar = createMenu();
    //setting of childmanager
    mChildManager = new ChildManager();

    //adds the menu
    if (mMenuBar != null) {
        setJMenuBar(mMenuBar);
    }
    Container cp = getContentPane();

    //adds the StatusBar
    if (mStatusBar != null) {
        mStatusBar.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
        cp.add(BorderLayout.SOUTH, mStatusBar);
    }

    //adds ToolBar
    if (mToolBar != null) {
        mToolBar.setFloatable(true);
        mToolBar.setBorder(new EtchedBorder());
        cp.add(BorderLayout.NORTH, mToolBar);
    }

    //adds childmanager
    if (mChildManager != null) {
        cp.add(BorderLayout.CENTER, mChildManager);
    }
}

From source file:SwingDnDTest.java

public SwingDnDFrame() {
    setTitle("SwingDnDTest");
    JTabbedPane tabbedPane = new JTabbedPane();

    JList list = SampleComponents.list();
    tabbedPane.addTab("List", list);
    JTable table = SampleComponents.table();
    tabbedPane.addTab("Table", table);
    JTree tree = SampleComponents.tree();
    tabbedPane.addTab("Tree", tree);
    JFileChooser fileChooser = new JFileChooser();
    tabbedPane.addTab("File Chooser", fileChooser);
    JColorChooser colorChooser = new JColorChooser();
    tabbedPane.addTab("Color Chooser", colorChooser);

    final JTextArea textArea = new JTextArea(4, 40);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setBorder(new TitledBorder(new EtchedBorder(), "Drag text here"));

    JTextField textField = new JTextField("Drag color here");
    textField.setTransferHandler(new TransferHandler("background"));

    tabbedPane.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            textArea.setText("");
        }/*from   w ww . java 2s. co m*/
    });

    tree.setDragEnabled(true);
    table.setDragEnabled(true);
    list.setDragEnabled(true);
    fileChooser.setDragEnabled(true);
    colorChooser.setDragEnabled(true);
    textField.setDragEnabled(true);

    add(tabbedPane, BorderLayout.NORTH);
    add(scrollPane, BorderLayout.CENTER);
    add(textField, BorderLayout.SOUTH);
    pack();
}

From source file:com.googlecode.vfsjfilechooser2.accessories.DefaultAccessoriesPanel.java

private void initBorder() {
    Border outsideBorder = new EtchedBorder();
    Border insideBorder = new EmptyBorder(2, 4, 0, 2);

    Border insideBorder1 = new CompoundBorder(outsideBorder, insideBorder);
    Border outsideBorder1 = new EmptyBorder(0, 2, 0, 2);

    setBorder(new CompoundBorder(outsideBorder1, insideBorder1));
}