Example usage for javax.swing.border TitledBorder TOP

List of usage examples for javax.swing.border TitledBorder TOP

Introduction

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

Prototype

int TOP

To view the source code for javax.swing.border TitledBorder TOP.

Click Source Link

Document

Position the title in the middle of the border's top line.

Usage

From source file:DoubleTitle.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Double Title");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TitledBorder topBorder = BorderFactory.createTitledBorder("Top");
    topBorder.setTitlePosition(TitledBorder.TOP);
    TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT, TitledBorder.BOTTOM);
    JButton doubleButton = new JButton();
    doubleButton.setBorder(doubleBorder);
    Container contentPane = frame.getContentPane();
    contentPane.add(doubleButton, BorderLayout.CENTER);
    frame.setSize(300, 100);//  w w w .ja va 2s.  c  o m
    frame.setVisible(true);
}

From source file:DoubleTitle.java

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

    TitledBorder topBorder = BorderFactory.createTitledBorder("Top");
    topBorder.setTitlePosition(TitledBorder.TOP);

    TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT, TitledBorder.BOTTOM);

    JButton doubleButton = new JButton();
    doubleButton.setBorder(doubleBorder);

    Container contentPane = frame.getContentPane();
    contentPane.add(doubleButton, BorderLayout.CENTER);
    frame.setSize(300, 100);//w ww  .  j  ava 2 s  . c o  m
    frame.setVisible(true);
}

From source file:MainClass.java

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

    TitledBorder topBorder = BorderFactory.createTitledBorder("Top");
    topBorder.setTitlePosition(TitledBorder.TOP);

    TitledBorder doubleBorder = new TitledBorder(topBorder, "Bottom", TitledBorder.RIGHT, TitledBorder.BOTTOM);

    JButton doubleButton = new JButton();
    doubleButton.setBorder(doubleBorder);
    Container contentPane = frame.getContentPane();
    contentPane.add(doubleButton, BorderLayout.CENTER);
    frame.setSize(300, 100);/* ww  w . j  a  v a  2 s.co  m*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

    JPanel panel = new JPanel();
    panel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Table Title",
            TitledBorder.CENTER, TitledBorder.TOP));

    JTable table = new JTable(3, 3);

    panel.add(new JScrollPane(table));

    frame.add(panel);//from w w w . j ava2s. co  m
    frame.pack();
    frame.setVisible(true);
}

From source file:TitledPostBorder.java

public static void main(String args[]) {
    JFrame frame = new JFrame("Positioned Titled Borders");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop");
    aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP);
    JButton aboveTopButton = new JButton();
    aboveTopButton.setBorder(aboveTopBorder);
    TitledBorder topBorder = BorderFactory.createTitledBorder("Top");
    topBorder.setTitlePosition(TitledBorder.TOP);
    JButton topButton = new JButton();
    topButton.setBorder(topBorder);/*from  w w w.ja va 2 s . c  om*/
    TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop");
    belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP);
    JButton belowTopButton = new JButton();
    belowTopButton.setBorder(belowTopBorder);
    TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom");
    aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM);
    JButton aboveBottomButton = new JButton();
    aboveBottomButton.setBorder(aboveBottomBorder);
    TitledBorder bottomBorder = BorderFactory.createTitledBorder("Bottom");
    bottomBorder.setTitlePosition(TitledBorder.BOTTOM);
    JButton bottomButton = new JButton();
    bottomButton.setBorder(bottomBorder);
    TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom");
    belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM);
    JButton belowBottomButton = new JButton();
    belowBottomButton.setBorder(belowBottomBorder);
    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(3, 2));
    contentPane.add(aboveTopButton);
    contentPane.add(aboveBottomButton);
    contentPane.add(topButton);
    contentPane.add(bottomButton);
    contentPane.add(belowTopButton);
    contentPane.add(belowBottomButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:TitledPostBorder.java

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

    TitledBorder aboveTopBorder = BorderFactory.createTitledBorder("AboveTop");
    aboveTopBorder.setTitlePosition(TitledBorder.ABOVE_TOP);
    JButton aboveTopButton = new JButton();
    aboveTopButton.setBorder(aboveTopBorder);

    TitledBorder topBorder = BorderFactory.createTitledBorder("Top");
    topBorder.setTitlePosition(TitledBorder.TOP);
    JButton topButton = new JButton();
    topButton.setBorder(topBorder);/*from www.j ava2s . c o  m*/

    TitledBorder belowTopBorder = BorderFactory.createTitledBorder("BelowTop");
    belowTopBorder.setTitlePosition(TitledBorder.BELOW_TOP);
    JButton belowTopButton = new JButton();
    belowTopButton.setBorder(belowTopBorder);

    TitledBorder aboveBottomBorder = BorderFactory.createTitledBorder("AboveBottom");
    aboveBottomBorder.setTitlePosition(TitledBorder.ABOVE_BOTTOM);
    JButton aboveBottomButton = new JButton();
    aboveBottomButton.setBorder(aboveBottomBorder);

    TitledBorder bottomBorder = BorderFactory.createTitledBorder("Bottom");
    bottomBorder.setTitlePosition(TitledBorder.BOTTOM);
    JButton bottomButton = new JButton();
    bottomButton.setBorder(bottomBorder);

    TitledBorder belowBottomBorder = BorderFactory.createTitledBorder("BelowBottom");
    belowBottomBorder.setTitlePosition(TitledBorder.BELOW_BOTTOM);
    JButton belowBottomButton = new JButton();
    belowBottomButton.setBorder(belowBottomBorder);

    Container contentPane = frame.getContentPane();
    contentPane.setLayout(new GridLayout(3, 2));
    contentPane.add(aboveTopButton);
    contentPane.add(aboveBottomButton);
    contentPane.add(topButton);
    contentPane.add(bottomButton);
    contentPane.add(belowTopButton);
    contentPane.add(belowBottomButton);
    frame.setSize(300, 200);
    frame.setVisible(true);
}

From source file:org.wsm.database.tools.editor.ui.GraphPane.java

public GraphPane() {
    GridBagLayout gbl = new GridBagLayout();
    this.setLayout(gbl);

    this.qesi = new QueryExecStatsInfo();
    this.qesi.addPropertyChangeListener(this);
    dcd = new DefaultCategoryDataset();
    JFreeChart chart = getChart(CHART_TYPE_BAR_3D);

    chart.setBackgroundPaint(Color.white);

    cp = new ChartPanel(chart);
    cp.setBorder(BorderFactory.createTitledBorder(null, "Graph", TitledBorder.LEADING, TitledBorder.TOP,
            UIConstants.LABEL_FONT));//  www.j  ava2 s  . c  o  m

    cp.setMouseZoomable(true, true);
    //cp.setPreferredSize(new Dimension(700, 500));
    gbl.setConstraints(cp, SwingUtils.getGridBagConstraints(0, 0, 2, 1));

    this.add(cp);
    JPanel graphTypeSelectionPanel = new JPanel();
    viewBarGraph = new JRadioButton("View Bar Graph", true);
    viewLineGraph = new JRadioButton("View Line Graph", false);
    viewLineGraph.setEnabled(false);
    ButtonGroup bg = new ButtonGroup();
    bg.add(viewBarGraph);
    bg.add(viewLineGraph);

    GridBagLayout graphTypeGBL = new GridBagLayout();
    graphTypeSelectionPanel.setLayout(graphTypeGBL);

    graphTypeGBL.setConstraints(viewBarGraph, SwingUtils.getGridBagConstraints(0, 0));
    graphTypeGBL.setConstraints(viewLineGraph, SwingUtils.getGridBagConstraints(1, 0));
    graphTypeSelectionPanel.add(viewBarGraph);
    graphTypeSelectionPanel.add(viewLineGraph);
    viewBarGraph.addActionListener(this);
    viewLineGraph.addActionListener(this);

    graphTypeSelectionPanel.setBorder(BorderFactory.createTitledBorder(null, "Graph Type", TitledBorder.LEADING,
            TitledBorder.TOP, UIConstants.LABEL_FONT));

    gbl.setConstraints(graphTypeSelectionPanel, SwingUtils.getGridBagConstraints(0, 1, 2, 1));

    this.add(graphTypeSelectionPanel);
    //this.setBounds(50, 100, 100, 200);
    this.setBackground(Color.WHITE);
}

From source file:com.jbombardier.console.panels.ProcessTelemetryPanel.java

/**
 * Create the panel./*from www  . j a v a2s.  co m*/
 */
public ProcessTelemetryPanel() {
    setBorder(new TitledBorder(null, "Process Telemetry", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    setLayout(new MigLayout("ins 0", "[grow]", "[grow]"));

    stackedBarCPU = ChartBuilder.startStackedBar().setTitle("CPU").setYAxisLabel("Percentage cpu")
            .setXAxisLabel("").setYAxisLabel("").setOrientation(PlotOrientation.HORIZONTAL).setYMaximum(100)
            .toChart();
    stackedBarMemory = ChartBuilder.startStackedBar().setTitle("Memory").setYAxisLabel("MBytes")
            .setXAxisLabel("").setOrientation(PlotOrientation.HORIZONTAL).toChart();

    add(stackedBarCPU.getComponent(), "cell 0 0,grow");
    add(stackedBarMemory.getComponent(), "cell 1 0,grow");

    xyCPU = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("CPU").setYAxisLabel("Percentage cpu used")
            .toChart();
    xyMemory = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("Memory").setYAxisLabel("MBytes free")
            .toChart();

    add(xyCPU.getComponent(), "cell 0 1,grow");
    add(xyMemory.getComponent(), "cell 1 1,grow");

    timer = TimerUtils.every("ProcessTelemetryPanel-Updater", 500, TimeUnit.MILLISECONDS, new Runnable() {
        public void run() {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    updateInternal2();
                }
            });

        }
    });
}

From source file:com.jbombardier.console.panels.MachineTelemetryPanel.java

/**
 * Create the panel./*  w  w  w  . j a  v  a 2s.  co  m*/
 */
public MachineTelemetryPanel() {
    setBorder(new TitledBorder(null, "Machine Telemetry", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    setLayout(new MigLayout("ins 0", "[grow,fill]0[grow,fill]0[grow,fill]0[grow,fill]", "[grow]0[grow]"));

    stackedBarCPU = ChartBuilder.startStackedBar().setTitle("CPU").setOrientation(PlotOrientation.HORIZONTAL)
            .setYAxisLabel("Percentage cpu").setYMaximum(100).setXAxisLabel("").setYAxisLabel("").toChart();
    stackedBarMemory = ChartBuilder.startStackedBar().setTitle("Memory")
            .setOrientation(PlotOrientation.HORIZONTAL).setYAxisLabel("MBytes").toChart();
    ioBarChart = ChartBuilder.startBar().setTitle("IO").setYAxisLabel("KBytes/sec")
            .setOrientation(PlotOrientation.HORIZONTAL).yAxisLock(1024).setVerticalXAxisLabels(true).toChart();

    // add(stackedBarCPU.getComponent(), "cell 0 0,grow");
    JPanel a = new JPanel();
    a.add(stackedBarCPU.getComponent());
    add(a, "cell 0 0,grow");
    a.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]"));

    // add(stackedBarMemory.getComponent(), "cell 1 0,grow");
    JPanel b = new JPanel();
    b.add(stackedBarMemory.getComponent());
    add(b, "cell 1 0,grow");
    b.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]"));

    // add(stackedBarIO.getComponent(), "cell 2 0,grow, wrap");
    JPanel c = new JPanel();
    c.add(ioBarChart.getComponent());
    add(c, "cell 2 0 2 1,grow");
    c.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]"));

    xyCPU = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("CPU").setYAxisLabel("Percentage cpu used")
            .toChart();
    xyMemory = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("Memory").setYAxisLabel("MBytes free")
            .toChart();
    xyIORx = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("Network IO").setYAxisLabel("KBytes/sec")
            .toChart();
    xyIOTx = (XYTimeChartPanel) ChartBuilder.startXY().setTitle("Network IO").setYAxisLabel("KBytes/sec")
            .toChart();

    // add(xyCPU.getComponent(), "cell 0 1,grow");
    JPanel d = new JPanel();
    d.add(xyCPU.getComponent());
    add(d, "cell 0 1,grow");
    d.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]"));

    // add(xyMemory.getComponent(), "cell 1 1,grow");
    JPanel e = new JPanel();
    e.add(xyMemory.getComponent());
    add(e, "cell 1 1,grow");
    e.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]"));

    JPanel f = new JPanel();
    f.add(xyIORx.getComponent());
    add(f, "cell 2 1,grow");
    f.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]"));

    JPanel g = new JPanel();
    g.add(xyIOTx.getComponent());
    add(g, "cell 3 1,grow");
    g.setLayout(new MigLayout("ins 0", "[grow,fill]", "[grow,fill]"));

    timer = TimerUtils.every("MachineTelemetryPanel-Updater", 500, TimeUnit.MILLISECONDS, new Runnable() {
        public void run() {
            SwingUtilities.invokeLater(new Runnable() {
                @Override
                public void run() {
                    updateInternal2();
                }
            });

        }
    });
}

From source file:gdt.jgui.tool.JTextEncrypter.java

/**
 * The default constructor./*from   w w w.  jav a2  s .c o  m*/
 */
public JTextEncrypter() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    JPanel panel = new JPanel();
    panel.setBorder(
            new TitledBorder(null, "Master password", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panel);
    panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
    JCheckBox chckbxNewCheckBox = new JCheckBox("Show");
    chckbxNewCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
    chckbxNewCheckBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() != ItemEvent.SELECTED) {
                passwordField.setEchoChar('*');
            } else {
                passwordField.setEchoChar((char) 0);
            }
        }
    });
    panel.add(chckbxNewCheckBox);
    panel.setFocusTraversalPolicy(
            new FocusTraversalOnArray(new Component[] { chckbxNewCheckBox, passwordField }));
    passwordField = new JPasswordField();
    passwordField.setMaximumSize(new Dimension(Integer.MAX_VALUE, passwordField.getPreferredSize().height));
    panel.add(passwordField);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(new TitledBorder(null, "Text", TitledBorder.LEADING, TitledBorder.TOP, null, null));
    add(panel_1);
    panel_1.setLayout(new BorderLayout(0, 0));

    textArea = new JTextArea();
    textArea.setColumns(1);
    panel_1.add(textArea);

}