Example usage for java.awt BorderLayout BorderLayout

List of usage examples for java.awt BorderLayout BorderLayout

Introduction

In this page you can find the example usage for java.awt BorderLayout BorderLayout.

Prototype

public BorderLayout() 

Source Link

Document

Constructs a new border layout with no gaps between components.

Usage

From source file:MainClass.java

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

    SpinnerModel model1 = new SpinnerListModel();
    JSpinner spinner1 = new JSpinner(model1);
    JLabel label1 = new JLabel("None");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.NORTH);

    frame.setSize(200, 90);/*w  w w  .j  ava2 s  .co  m*/
    frame.setVisible(true);

}

From source file:HelloWorld.java

public static void main(String[] args) {
    Frame frame = new Frame();
    frame.setSize(640, 480);// ww  w  . ja v a2  s.co m
    frame.setLayout(new BorderLayout());

    Canvas3D canvas = new Canvas3D(null);
    frame.add("Center", canvas);

    SimpleUniverse univ = new SimpleUniverse(canvas);
    univ.getViewingPlatform().setNominalViewingTransform();

    BranchGroup scene = createSceneGraph();
    scene.compile();
    univ.addBranchGraph(scene);

    frame.show();
}

From source file:SpinnerNumberSample.java

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

    SpinnerModel model1 = new SpinnerNumberModel();
    JSpinner spinner1 = new JSpinner(model1);

    JLabel label1 = new JLabel("Numbers");
    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(label1, BorderLayout.WEST);
    panel1.add(spinner1, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.SOUTH);

    frame.setSize(200, 90);//  w w  w  .java  2 s  . co  m
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel bottomPanel = new JPanel();
    bottomPanel.add(new JButton("Bottom Button"));
    bottomPanel.setBorder(BorderFactory.createTitledBorder("Bottom Panel"));

    JPanel centerPanel = new JPanel();
    centerPanel.setBorder(BorderFactory.createTitledBorder("Center Panel"));

    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.add(centerPanel, BorderLayout.CENTER);
    mainPanel.add(bottomPanel, BorderLayout.PAGE_END);

    int eb = 25;/*from w ww  .jav  a 2s.  c o  m*/
    mainPanel.setBorder(BorderFactory.createEmptyBorder(eb, eb, eb, eb));

    mainPanel.setPreferredSize(new Dimension(500, 400));

    JFrame frame = new JFrame("Main");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(mainPanel);
    frame.pack();
    frame.setLocationByPlatform(true);
    frame.setVisible(true);
}

From source file:MainClass.java

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

    SpinnerModel model3 = new SpinnerNumberModel();
    JSpinner spinner3 = new JSpinner(model3);

    JLabel label3 = new JLabel("Numbers");
    JPanel panel3 = new JPanel(new BorderLayout());
    panel3.add(label3, BorderLayout.WEST);
    panel3.add(spinner3, BorderLayout.CENTER);
    frame.add(panel3, BorderLayout.SOUTH);

    frame.setSize(200, 90);//from w ww.ja  v  a2 s  . co  m
    frame.setVisible(true);

}

From source file:Main.java

public static void main(String[] args) {
    final JTextPane pane = new JTextPane();
    pane.setText("Some text");

    JButton buttonButton = new JButton("Insert label");
    buttonButton.addActionListener(e -> {
        JLabel label = new JLabel("label");
        label.setAlignmentY(0.85f);/* w w w .j  ava  2  s.co m*/
        pane.insertComponent(label);

    });

    JPanel panel = new JPanel(new BorderLayout());
    panel.add(buttonButton, BorderLayout.SOUTH);
    panel.add(pane, BorderLayout.CENTER);

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(panel);
    frame.setSize(400, 200);
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JTextArea ta = new JTextArea(20, 20);
    ((AbstractDocument) ta.getDocument()).setDocumentFilter(new MyFilter());

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(new JScrollPane(ta));
    frame.pack();/*from  w  w  w  .  j  ava2 s  . com*/
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JEditorPane htmlPane = new JEditorPane();
    String description = "<html><body>Hello<table border=1>"
            + "<tr><td><img alt='Bad' src='http://www.java2s.com/style/download.png'/></tr></td></table></body></html>";
    htmlPane.setContentType("text/html");
    htmlPane.setText(description);/*ww w.ja  v  a 2s  .co m*/

    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLayout(new BorderLayout());
    frame.add(new JScrollPane(htmlPane));
    frame.pack();
    frame.setVisible(true);
}

From source file:JDK6TextComponentDemo.java

public static void main(String[] args) throws Exception {
    final JTextArea textArea = new JTextArea();
    textArea.setText("text");
    JScrollPane jScrollPane = new JScrollPane(textArea);
    final MessageFormat header = new MessageFormat("My Header");
    final MessageFormat footer = new MessageFormat("My Footer");

    JPanel contentPane = new JPanel();
    contentPane.setLayout(new BorderLayout());
    contentPane.add(jScrollPane, BorderLayout.CENTER);

    JFrame frame = new JFrame();
    frame.setTitle("Text-component Printing Demo");
    frame.setSize(400, 200);/*from   w w  w  .j a  v  a2  s  .  c  om*/
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    frame.setContentPane(contentPane);
    frame.setVisible(true);
    textArea.print(header, footer, true, null, null, true);

}

From source file:Main.java

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

    SpinnerModel model = new SpinnerNumberModel(50, 0, 100, .25);
    JSpinner spinner = new JSpinner(model);
    JComponent editor = new JSpinner.NumberEditor(spinner, "#,##0.###");
    spinner.setEditor(editor);//from w w  w . ja  v a2 s  .c  o m

    JPanel panel1 = new JPanel(new BorderLayout());
    panel1.add(spinner, BorderLayout.CENTER);
    frame.add(panel1, BorderLayout.SOUTH);

    frame.setSize(200, 90);
    frame.setVisible(true);
}