Example usage for javax.swing BoxLayout PAGE_AXIS

List of usage examples for javax.swing BoxLayout PAGE_AXIS

Introduction

In this page you can find the example usage for javax.swing BoxLayout PAGE_AXIS.

Prototype

int PAGE_AXIS

To view the source code for javax.swing BoxLayout PAGE_AXIS.

Click Source Link

Document

Specifies that components should be laid out in the direction that lines flow across a page as determined by the target container's ComponentOrientation property.

Usage

From source file:Main.java

public static void main(String args[]) throws ParseException {
    JFrame f = new JFrame();
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container content = f.getContentPane();
    content.setLayout(new BoxLayout(content, BoxLayout.PAGE_AXIS));

    MaskFormatter mf1 = new MaskFormatter("###-###-###");
    mf1.setPlaceholderCharacter('_');
    JFormattedTextField ftf1 = new JFormattedTextField(mf1);
    content.add(ftf1);//from w w  w  . java  2s . co m

    MaskFormatter mf2 = new MaskFormatter("(###) ###-####");
    JFormattedTextField ftf2 = new JFormattedTextField(mf2);
    content.add(ftf2);
    f.setSize(300, 100);
    f.setVisible(true);
}

From source file:Main.java

public static void main(String[] a) {
    JFrame frame = new JFrame("Alignment Example");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    String labels[] = { "--", "----", "--------", "------------" };

    JPanel container = new JPanel();
    BoxLayout layout = new BoxLayout(container, BoxLayout.PAGE_AXIS);
    container.setLayout(layout);//from   ww  w. ja va  2 s. com

    for (int i = 0; i < labels.length; i++) {
        JButton button = new JButton(labels[i]);
        container.add(button);
    }

    frame.add(container, BorderLayout.CENTER);

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

From source file:Main.java

public static void main(String[] argv) {
    JFrame f = new JFrame();
    f.setLayout(new BorderLayout());

    JPanel panel = new JPanel();
    JButton button = new JButton("A-ha!");
    button.setAlignmentX(Component.CENTER_ALIGNMENT);
    panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS));
    panel.add(Box.createVerticalGlue());
    panel.add(button);/*  w w  w.  j  a  v  a  2 s.  com*/
    panel.add(Box.createVerticalGlue());

    f.getContentPane().add(panel);

    f.setVisible(true);
}

From source file:Main.java

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

    JPanel controlPane = new JPanel();
    JPanel buttonPane = new JPanel();

    controlPane.setLayout(new BoxLayout(controlPane, BoxLayout.PAGE_AXIS));
    controlPane.setPreferredSize(new Dimension(200, 200));
    controlPane.add(new JScrollPane(new JTextArea()));

    buttonPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    buttonPane.setPreferredSize(new Dimension(100, 40));
    buttonPane.add(new JButton("Button1"));
    buttonPane.add(new JButton("Button2"));

    frame.add(controlPane, BorderLayout.NORTH);
    frame.add(buttonPane, BorderLayout.SOUTH);

    frame.pack();//from  www  . ja v a2  s  . c  om
    frame.setVisible(true);
}

From source file:BoxLayoutDemo.java

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

    JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
    p.add(createComponent("Component 1"));
    p.add(Box.createVerticalGlue());
    p.add(createComponent("Component 2"));
    p.add(createComponent("Component 3"));
    p.add(createComponent("Component 4"));
    frame.setContentPane(p);/*from  w w w .ja  v  a 2 s  . com*/

    //Display the window.
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    int BTN_COUNT = 3;
    int VERT_GAP = 10;
    int EB_GAP = 5;
    float TITLE_SIZE = 36f;
    String TITLE_TEXT = "This is my Title";

    JLabel titleLabel = new JLabel(TITLE_TEXT, SwingConstants.CENTER);
    titleLabel.setFont(titleLabel.getFont().deriveFont(TITLE_SIZE));
    JPanel titlePanel = new JPanel();
    titlePanel.add(titleLabel);/*from  w  ww.  ja  v a  2  s . c o m*/

    JPanel buttonPanel = new JPanel(new GridLayout(1, 0, 5, 0));
    for (int i = 0; i < BTN_COUNT; i++) {
        JButton btn = new JButton("Button " + (i + 1));
        buttonPanel.add(btn);
    }

    JTextArea textArea = new JTextArea(20, 30);

    JPanel mainPanel = new JPanel();
    mainPanel.setBorder(BorderFactory.createEmptyBorder(EB_GAP, EB_GAP, EB_GAP, EB_GAP));
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
    mainPanel.add(titlePanel);
    mainPanel.add(Box.createVerticalStrut(VERT_GAP));
    mainPanel.add(buttonPanel);
    mainPanel.add(Box.createVerticalStrut(VERT_GAP));
    mainPanel.add(new JScrollPane(textArea));

    JFrame frame = new JFrame();
    frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();
    frame.setVisible(true);

}

From source file:moviedatas.MovieDatas.java

public static void main(String[] args) {
    FilterController fpc = new FilterController();

    SortController spc = new SortController();

    //1. Create the frame.
    JFrame frame = new JFrame("Movies Open Datas by Harp-e");
    frame.setPreferredSize(new Dimension(1280, 800));

    //2. Optional: What happens when the frame closes?
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    MovieListView movieListView = new MovieListView();
    JPanel movieListPanel = movieListView.createViewPanel();
    TitledBorder moviesTitle;/*from ww  w .jav a  2 s. com*/
    moviesTitle = BorderFactory.createTitledBorder("Movies");
    movieListPanel.setBorder(moviesTitle);

    //3. Create components and put them in the frame.
    //----------------------------------------------------------------------
    // Sort & Filter panel (right)
    //----------------------------------------------------------------------
    SortPanelView sortFilterView = new SortPanelView();
    FilterPanelView filterPanelView = new FilterPanelView();

    JPanel sortPanel = sortFilterView.createSortPanel();
    JPanel filterPanel = filterPanelView.createFilterPanel();
    JPanel sortFilterPanel = new JPanel();

    sortFilterPanel.setLayout(new BoxLayout(sortFilterPanel, BoxLayout.PAGE_AXIS));

    sortFilterPanel.add(sortPanel);
    sortFilterPanel.add(filterPanel);

    frame.getContentPane().add(sortFilterPanel, BorderLayout.WEST);
    //----------------------------------------------------------------------
    // Movie Info Panel (left)
    //----------------------------------------------------------------------
    MovieInfoController movieInfoController = new MovieInfoController();
    JPanel movieInfoView = movieInfoController.initView();
    TitledBorder infoTitle;
    infoTitle = BorderFactory.createTitledBorder("Informations");
    movieInfoView.setBorder(infoTitle);
    //----------------------------------------------------------------------
    // Movie List Panel (middle)
    //----------------------------------------------------------------------   
    JPanel listPanel = new JPanel();
    listPanel.setLayout(new BorderLayout());
    listPanel.setPreferredSize(new Dimension(1280, 400));
    listPanel.add(sortFilterPanel, BorderLayout.WEST);
    listPanel.add(movieInfoView, BorderLayout.EAST);
    listPanel.add(movieListPanel, BorderLayout.CENTER);
    frame.getContentPane().add(listPanel, BorderLayout.NORTH);
    //----------------------------------------------------------------------
    // Charts Panel (bottom)
    //----------------------------------------------------------------------
    JPanel chartPanel = new JPanel();

    // Spider chart Panel
    //______________________________________________________________________
    // Create the panel
    JPanel spiderPanel = new JPanel();
    // Create the view
    SpiderChartView spiderChartView = new SpiderChartView();
    // Create a tilte
    TitledBorder spiderTitle;
    // Put a border around the title
    spiderTitle = BorderFactory.createTitledBorder("Spider chart");
    // Put the border on the panel
    spiderPanel.setBorder(spiderTitle);
    // Put the view on the panel
    spiderPanel.add(spiderChartView.initView());
    // Put the spider panel on the global panel
    chartPanel.add(spiderPanel);
    //______________________________________________________________________

    // Bar chart Panel
    //______________________________________________________________________
    JPanel barPanel = new JPanel();
    BarChartView barChartView = new BarChartView();
    TitledBorder barTitle;
    barTitle = BorderFactory.createTitledBorder("Bar chart");
    barPanel.setBorder(barTitle);
    barPanel.add(barChartView.initView());
    chartPanel.add(barPanel);
    //______________________________________________________________________

    // Global chart Panel
    //______________________________________________________________________
    JPanel globalChartPanel = new JPanel();
    GlobalChart globalChartView = new GlobalChart();
    TitledBorder globalTitle;
    globalTitle = BorderFactory.createTitledBorder("Global chart");
    globalChartPanel.setBorder(globalTitle);
    globalChartPanel.add(globalChartView.initView());
    chartPanel.add(globalChartPanel);
    //______________________________________________________________________

    frame.getContentPane().add(chartPanel, BorderLayout.CENTER);
    //----------------------------------------------------------------------

    //4. Size the frame.
    frame.pack();

    //5. Show it.
    frame.setVisible(true);
    //ArrayList<Movie> movies = new ArrayList<>();
    //FilterController.filter(10,SortController.byTitle(movies));

}

From source file:Main.java

public static JPanel createPageBoxLaidOutPanel() {
    final JPanel p = new JPanel();
    p.setLayout(new BoxLayout(p, BoxLayout.PAGE_AXIS));
    return p;//from www  . jav  a  2  s  .  c o  m
}

From source file:Main.java

public static final Component groupVertical(final Component... components) {
    return group(components, BoxLayout.PAGE_AXIS);
}

From source file:Main.java

public static JPanel getComponentColumn(JComponent[] components) {
    JPanel columnPanel = new JPanel();
    columnPanel.setLayout(new BoxLayout(columnPanel, BoxLayout.PAGE_AXIS));

    for (int i = 0; i < components.length; i++) {
        components[i].setMinimumSize(new Dimension(components[i].getPreferredSize().width, ROW_HEIGHT));
        components[i].setPreferredSize(new Dimension(components[i].getPreferredSize().width, ROW_HEIGHT));
        components[i].setMaximumSize(new Dimension(components[i].getPreferredSize().width, ROW_HEIGHT));
        components[i].setAlignmentX(JComponent.LEFT_ALIGNMENT);
        columnPanel.add(components[i]);/*w  ww.j av  a 2 s. c  o  m*/
    }
    return columnPanel;
}