List of usage examples for java.awt BorderLayout BorderLayout
public BorderLayout()
From source file:Main.java
public Main() { MyCanvas thingy = new MyCanvas(); setLayout(new BorderLayout()); JPanel panel = new JPanel(); panel.add(thingy);//from ww w.j a va 2 s . c o m JScrollPane scroll = new JScrollPane(); scroll.setViewportView(panel); add(scroll, BorderLayout.CENTER); SpinnerNumberModel spmodel = new SpinnerNumberModel(thingy.getThingySize(), 10.0, 2000.0, 10.0); spmodel.addChangeListener(e -> thingy.setThingySize((Double) spmodel.getNumber())); add(new JSpinner(spmodel), BorderLayout.NORTH); }
From source file:Main.java
Main() { setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(900, 600);/* w w w . j av a 2 s . co m*/ JPanel left = new JPanel(); left.setBackground(Color.BLUE); JPanel right = new JPanel(new BorderLayout()); JLabel fox = new JLabel("The quick brown fox jumps over the lazy dog."); fox.setFont(new Font(null, 0, 50)); JPanel rightBottom = new JPanel(); rightBottom.setLayout(new GridLayout(10, 10)); for (int i = 1; i <= 100; i++) { rightBottom.add(new JButton("butt" + i)); } right.add(fox, BorderLayout.NORTH); right.add(rightBottom, BorderLayout.CENTER); add(right); }
From source file:MainClass.java
public MainClass() { setLayout(new BorderLayout()); model = new DefaultListModel(); list = new JList(model); JScrollPane pane = new JScrollPane(list); JButton addButton = new JButton("Add Element"); JButton removeButton = new JButton("Remove Element"); for (int i = 0; i < 15; i++) model.addElement("Element " + i); addButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { model.addElement("Element " + counter); counter++;//from www . jav a2 s .co m } }); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (model.getSize() > 0) model.removeElementAt(0); } }); add(pane, BorderLayout.NORTH); add(addButton, BorderLayout.WEST); add(removeButton, BorderLayout.EAST); }
From source file:Main.java
public Main() { setLayout(new BorderLayout()); list = new JList(label); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); }/*from w w w . java2 s . c o m*/ }); list.setSelectionModel(m); System.out.println(m.getValueIsAdjusting()); add(pane, BorderLayout.NORTH); }
From source file:Main.java
public Main() { JButton btn1 = new JButton("Button1"); JButton btn2 = new JButton("Button2"); JButton btn3 = new JButton("Button3"); JButton btn4 = new JButton("Button4"); JButton btn5 = new JButton("Button5"); JButton btn6 = new JButton("Button6"); setLayout(new BorderLayout()); add("North", btn1); add("West", btn2); add("Center", btn3); add("Center", btn4); add("South", btn5); add("East", btn6); }
From source file:Main.java
public Main() { setLayout(new BorderLayout()); list = new JList(label); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); }/*from ww w .ja v a2s. com*/ }); list.setSelectionModel(m); System.out.println(m.getSelectionMode() == ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); add(pane, BorderLayout.NORTH); }
From source file:Main.java
public Main() { setLayout(new BorderLayout()); list = new JList(label); JScrollPane pane = new JScrollPane(list); DefaultListSelectionModel m = new DefaultListSelectionModel(); m.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); m.setLeadAnchorNotificationEnabled(false); list.setSelectionModel(m);/*from w ww . j a v a 2s.c o m*/ ListSelectionListener lis = new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { System.out.println(e.toString()); } }; m.addListSelectionListener(lis); m.removeListSelectionListener(lis); add(pane, BorderLayout.NORTH); }
From source file:Main.java
public Main() { setPreferredSize(new Dimension(500, 500)); getContentPane().setLayout(new BorderLayout()); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(4, 4, 4, 4); panel.add(new JLabel("Label"), c); panel.add(new JTextField(20), c); c.gridwidth = GridBagConstraints.REMAINDER; panel.add(new JButton("btn"), c); c.gridwidth = 1;/*w w w . j a v a 2 s.co m*/ panel.add(new JLabel("Name"), c); panel.add(new JTextField(20), c); c.gridwidth = GridBagConstraints.REMAINDER; panel.add(new JButton("btn"), c); c.weighty = 1.0; panel.add(Box.createGlue(), c); add(panel, BorderLayout.LINE_START); pack(); setVisible(true); }
From source file:Main.java
public Main() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); panel.setLayout(new BorderLayout()); setContentPane(panel);/*from www .j a va2 s . c o m*/ JTextPane textA = new JTextPane(); textA.setName("text"); textA.setContentType("text/html"); DefaultCaret caret = (DefaultCaret) textA.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); JScrollPane filler = new JScrollPane(textA, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); JTextPane textB = new JTextPane(); textB.setName("text" + "_T"); textB.setFont(textA.getFont()); DefaultCaret caret_T = (DefaultCaret) textB.getCaret(); caret_T.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); JScrollPane filler_T = new JScrollPane(textB, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); panel.add(filler, BorderLayout.NORTH); panel.add(filler_T, BorderLayout.CENTER); pack(); }
From source file:Main.java
public static JComponent wrapBorder(Component content, Border border) { JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(content, BorderLayout.CENTER); wrapper.setBorder(border);/* w w w . j a v a 2 s . c o m*/ return wrapper; }