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:YAxisAlignX.java
private static Container layoutComponents(String title, float alignment) { String labels[] = { "--", "----", "--------", "------------" }; JPanel container = new JPanel(); container.setBorder(BorderFactory.createTitledBorder(title)); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); container.setLayout(layout);//from ww w .ja v a 2 s . c o m for (int i = 0, n = labels.length; i < n; i++) { JButton button = new JButton(labels[i]); button.setAlignmentX(alignment); container.add(button); } return container; }
From source file:YAxisAlignXButtonMixed.java
private static Container makeIt(String title) { JPanel container = new JPanel(); container.setBorder(BorderFactory.createTitledBorder(title)); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); container.setLayout(layout);/*from w w w . j a v a 2s. c om*/ AButton button = new AButton("0.0", 0.0f); container.add(button); button = new AButton(".25", .25f); container.add(button); button = new AButton(".50", .50f); container.add(button); button = new AButton(".75", .75f); container.add(button); button = new AButton("1.0", 1.0f); container.add(button); return container; }
From source file:YAxisDiffAlign.java
private static Container makeIt(String title, boolean more) { JPanel container = new JPanel() { public void paintComponent(Graphics g) { super.paintComponent(g); Insets insets = getInsets(); int width = getWidth() - insets.left - insets.right; int halfWidth = width / 2 + insets.left; int height = getHeight(); int halfHeight = height / 2 + insets.top; g.drawLine(halfWidth, 0, halfWidth, height); }//from w ww. ja v a 2s .c om }; container.setBorder(BorderFactory.createTitledBorder(title)); BoxLayout layout = new BoxLayout(container, BoxLayout.Y_AXIS); container.setLayout(layout); JButton button; button = new JButton("0.0"); button.setOpaque(false); button.setAlignmentX(Component.LEFT_ALIGNMENT); container.add(button); if (more) { button = new JButton(".25"); button.setOpaque(false); button.setAlignmentX(0.25f); container.add(button); button = new JButton(".5"); button.setOpaque(false); button.setAlignmentX(Component.CENTER_ALIGNMENT); container.add(button); button = new JButton(".75"); button.setOpaque(false); button.setAlignmentX(0.75f); container.add(button); } button = new JButton("1.0"); button.setOpaque(false); button.setAlignmentX(Component.RIGHT_ALIGNMENT); container.add(button); return container; }
From source file:Main.java
public Main() { Box box = new Box(BoxLayout.Y_AXIS); add(box);/*from w w w. j a v a2 s . com*/ JLabel label = new JLabel("I'm centered"); label.setAlignmentX(JComponent.CENTER_ALIGNMENT); box.add(Box.createVerticalGlue()); box.add(label); box.add(Box.createVerticalGlue()); }
From source file:Main.java
public static void showMessage(String title, String str) { JFrame info = new JFrame(title); JTextArea t = new JTextArea(str, 15, 40); t.setEditable(false);/*from www .j ava 2s.c o m*/ t.setLineWrap(true); t.setWrapStyleWord(true); JButton ok = new JButton("Close"); ok.addActionListener(windowCloserAction); info.getContentPane().setLayout(new BoxLayout(info.getContentPane(), BoxLayout.Y_AXIS)); info.getContentPane().add(new JScrollPane(t)); info.getContentPane().add(ok); ok.setAlignmentX(Component.CENTER_ALIGNMENT); info.pack(); //info.setResizable(false); centerFrame(info); //info.show(); info.setVisible(true); }
From source file:MainClass.java
public MainClass() { Box box = new Box(BoxLayout.Y_AXIS); box.add(new JButton("Test button")); box.add(new JSlider()); box.add(new JTextField("Text field with some text", 20)); box.add(new JButton("Another, bigger button")); getContentPane().add(box);/*from w w w. j a va 2s. c om*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); }
From source file:Main.java
public Main() { super(BoxLayout.Y_AXIS); try {/* www .j a v a 2 s . co m*/ for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); System.out.println("set"); break; } } } catch (Exception e) { e.printStackTrace(); } Object o = UIManager.get("TextArea[Enabled+NotInScrollPane].borderPainter"); UIDefaults paneDefaults = new UIDefaults(); paneDefaults.put("TextPane.borderPainter", o); JTextPane pane = new JTextPane(); pane.setMargin(new Insets(10, 10, 10, 10)); pane.putClientProperty("Nimbus.Overrides", paneDefaults); pane.putClientProperty("Nimbus.Overrides.InheritDefaults", false); pane.setText("this \nis \na \ntest\n"); add(pane); }
From source file:Main.java
public Main(JFrame frame) { super(BoxLayout.Y_AXIS); this.frame = frame; add(text);//from w ww.java 2 s. c om JButton button = new JButton("Click Me"); button.addActionListener(e -> launchDialog()); add(button); }
From source file:Main.java
public Main() { super(BoxLayout.Y_AXIS); Box info = Box.createVerticalBox(); info.add(new Label("Please wait 3 seconds")); final JButton continueButton = new JButton("Continue"); info.add(continueButton);/*w w w . j a va 2 s . c o m*/ JDialog d = new JDialog(); d.setModalityType(ModalityType.APPLICATION_MODAL); d.setContentPane(info); d.pack(); continueButton.addActionListener(e -> d.dispose()); continueButton.setVisible(false); SwingWorker sw = new SwingWorker<Integer, Integer>() { protected Integer doInBackground() throws Exception { int i = 0; while (i++ < 30) { System.out.println(i); Thread.sleep(100); } return null; } @Override protected void done() { continueButton.setVisible(true); } }; JButton button = new JButton("Click Me"); button.addActionListener(e -> { sw.execute(); d.setVisible(true); }); add(button); }
From source file:Main.java
public Main() { super(BoxLayout.Y_AXIS); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root"); for (int i = 0; i < 14; i++) { DefaultMutableTreeNode node = new DefaultMutableTreeNode("Root" + i); node.add(new DefaultMutableTreeNode("Child" + i)); root.add(node);/* w ww. j av a 2 s.com*/ } CustomTree tree = new CustomTree(root); tree.setRootVisible(false); JScrollPane pane = new JScrollPane(tree); add(pane); JButton button = new JButton("Expand"); button.addActionListener(e -> tree.expandSelectedPaths()); add(button); }