List of usage examples for javax.swing BoxLayout Y_AXIS
int Y_AXIS
To view the source code for javax.swing BoxLayout Y_AXIS.
Click Source Link
From source file:Main.java
public Main(int axis) { super(BoxLayout.Y_AXIS); container = new Box(axis); container.setAlignmentX(Box.LEFT_ALIGNMENT); add(container);/*from ww w . ja v a 2 s. c om*/ JTextArea text = new JTextArea(); container.add(new JScrollPane(text)); JButton split = new JButton("Split"); split.setAlignmentX(Box.LEFT_ALIGNMENT); split.addActionListener(e -> { JTextArea t = new JTextArea(); container.add(new JScrollPane(t)); revalidate(); }); add(split); JButton axisChanger = new JButton("Change Axis"); axisChanger.setAlignmentX(Box.LEFT_ALIGNMENT); axisChanger.addActionListener(e -> { Box newContainer; if (((BoxLayout) container.getLayout()).getAxis() == BoxLayout.X_AXIS) { newContainer = Box.createVerticalBox(); } else { newContainer = Box.createHorizontalBox(); } for (Component c : container.getComponents()) { container.remove(c); newContainer.add(c); } remove(container); add(newContainer, 0); container = newContainer; container.setAlignmentX(Box.LEFT_ALIGNMENT); revalidate(); }); add(axisChanger); }
From source file:Main.java
public Main() { super("JLayeredPane Demo"); setSize(256, 256);/* w w w .ja v a 2 s . c om*/ JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.setOpaque(false); JLabel label1 = new JLabel("Username:"); label1.setForeground(Color.white); content.add(label1); JTextField field = new JTextField(15); content.add(field); JLabel label2 = new JLabel("Password:"); label2.setForeground(Color.white); content.add(label2); JPasswordField fieldPass = new JPasswordField(15); content.add(fieldPass); setLayout(new FlowLayout()); add(content); ((JPanel) getContentPane()).setOpaque(false); ImageIcon earth = new ImageIcon("largeJava2sLogo.png"); JLabel backlabel = new JLabel(earth); getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE)); backlabel.setBounds(0, 0, earth.getIconWidth(), earth.getIconHeight()); super.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); }
From source file:AboutDialog.java
public AboutDialog() { setTitle("About"); setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); add(Box.createRigidArea(new Dimension(0, 10))); JLabel name = new JLabel("Notes"); name.setAlignmentX(0.5f);/*from www . j a v a 2s . co m*/ add(name); add(Box.createRigidArea(new Dimension(0, 100))); JButton close = new JButton("Close"); close.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dispose(); } }); close.setAlignmentX(0.5f); add(close); setModalityType(ModalityType.APPLICATION_MODAL); setDefaultCloseOperation(DISPOSE_ON_CLOSE); setSize(300, 200); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField field1 = new JTextField("Life's a drag", 20); JTextField field2 = new JTextField("and then you drop", 20); field1.setDragEnabled(true);/* www.j a v a2 s . c o m*/ field2.setDragEnabled(true); Container content = getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.add(field1); content.add(field2); pack(); }
From source file:DragDropText.java
public DragDropText() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField field1 = new JTextField("Life's a drag", 20); JTextField field2 = new JTextField("and then you drop", 20); field1.setDragEnabled(true);// www.j av a 2 s. c o m field2.setDragEnabled(true); Container content = getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.add(field1); content.add(field2); pack(); }
From source file:TextSlider.java
public TextSlider() { setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); textField = new JTextField(); scrollBar = new JScrollBar(JScrollBar.HORIZONTAL); BoundedRangeModel brm = textField.getHorizontalVisibility(); scrollBar.setModel(brm);/*www . java 2 s . c o m*/ add(textField); add(scrollBar); }
From source file:FramewithComponents.java
public FramewithComponents() { super("JLayeredPane Demo"); setSize(256, 256);//from ww w . j av a2 s . c o m JPanel content = new JPanel(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); content.setOpaque(false); JLabel label1 = new JLabel("Username:"); label1.setForeground(Color.white); content.add(label1); JTextField field = new JTextField(15); content.add(field); JLabel label2 = new JLabel("Password:"); label2.setForeground(Color.white); content.add(label2); JPasswordField fieldPass = new JPasswordField(15); content.add(fieldPass); getContentPane().setLayout(new FlowLayout()); getContentPane().add(content); ((JPanel) getContentPane()).setOpaque(false); ImageIcon earth = new ImageIcon("largeJava2sLogo.png"); JLabel backlabel = new JLabel(earth); getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE)); backlabel.setBounds(0, 0, earth.getIconWidth(), earth.getIconHeight()); WindowListener l = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(l); setVisible(true); }
From source file:Main.java
public PopupMenu() { super(BoxLayout.Y_AXIS); final JPopupMenu menu = new JPopupMenu("Options"); for (int i = 1; i < 20; i++) menu.add(new JMenuItem("Option" + i)); JLabel clickMe = new JLabel("ClickMe"); clickMe.setAlignmentX(RIGHT_ALIGNMENT); clickMe.addMouseListener(new MouseAdapter() { @Override/*from w w w . ja v a 2 s . c o m*/ public void mouseClicked(MouseEvent e) { menu.show(e.getComponent(), e.getX(), e.getY()); } }); add(clickMe); }
From source file:Main.java
public GameFrame() { setSize(300, 300);// ww w . j a va 2s. c o m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS)); if (FULLSCREEN_SUPPORTED) { fsButton.addActionListener(e -> toggleFullscreen()); add(fsButton); } else { add(new JLabel("Fullscreen mode is not supported on this device")); } }
From source file:Main.java
public Main() { panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); setSize(300, 400);/*from w ww . ja va 2s . c o m*/ getContentPane().add(panel, BorderLayout.EAST); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); loadLabel(); }