List of usage examples for javax.swing JFrame setLayout
public void setLayout(LayoutManager manager)
LayoutManager
. From source file:PictureScaler.java
private static void createAndShowGUI() { JFrame f = new JFrame(); f.setLayout(new BorderLayout()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); PictureScaler test = new PictureScaler(); //f.setSize(scaleW + (4 * PADDING), scaleH + (4 * PADDING)); f.add(test);//from www.ja v a2 s . com f.validate(); f.pack(); f.setVisible(true); }
From source file:ScaleTest_2008.java
private static void createAndShowGUI() { JFrame f = new JFrame(); f.setLayout(new BorderLayout()); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(900, 50 + (5 * FULL_SIZE) + (6 * PADDING)); ScaleTest_2008 test = new ScaleTest_2008(); f.add(test);//from w w w. j a va2 s. c o m f.setVisible(true); }
From source file:com.joey.software.memoryToolkit.MemoryUsagePanel.java
public static JFrame getMemoryUsagePanel(int dataNum, int delay) { final MemoryUsagePanel u = new MemoryUsagePanel(dataNum, delay); JFrame f = new JFrame("Memory Usage"); f.setLayout(new BorderLayout()); f.getContentPane().add(u, BorderLayout.CENTER); f.setSize(800, 400);//from w ww . ja v a2 s .c o m f.setVisible(true); final JButton runButton = new JButton("Start"); runButton.addActionListener(new ActionListener() { boolean running = false; @Override public void actionPerformed(ActionEvent e) { if (running) { running = false; u.stopUpdating(); runButton.setText("Start"); } else { running = true; u.startUpdating(); runButton.setText("Stop"); } } }); JButton garbage = new JButton("Run GC"); garbage.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.gc(); } }); JPanel temp = new JPanel(new GridLayout(1, 1)); temp.add(runButton); temp.add(garbage); f.getContentPane().add(temp, BorderLayout.SOUTH); return f; }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopComponentsHelper.java
/** * Determines real size of HTML label with text on screen. * * @param html text with html markup// ww w . ja v a 2 s . com * @return size of label */ public static Dimension measureHtmlText(String html) { JFrame testFrame = new JFrame(); testFrame.setLayout(new BoxLayout(testFrame.getContentPane(), BoxLayout.PAGE_AXIS)); JLabel testLabel = new JLabel(html); testFrame.add(testLabel); testFrame.pack(); Dimension size = testLabel.getSize(); testFrame.dispose(); return new Dimension(size); }
From source file:Main.java
Main() { JFrame jfrm = new JFrame("JTable Demo"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(460, 180);/*from w w w.j av a2 s . c o m*/ jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane jscrlp = new JScrollPane(jtabOrders); jtabOrders.setPreferredScrollableViewportSize(new Dimension(420, 60)); jtabOrders.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jfrm.setVisible(true); jtabOrders.setColumnSelectionAllowed(false); jtabOrders.setRowSelectionAllowed(true); }
From source file:Main.java
Main() { JFrame jfrm = new JFrame("JTable Demo"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(460, 180);//w w w . j a va 2 s. co m jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JScrollPane jscrlp = new JScrollPane(jtabOrders); jtabOrders.setPreferredScrollableViewportSize(new Dimension(420, 60)); jtabOrders.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jtabOrders.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); jfrm.setVisible(true); jtabOrders.setCellSelectionEnabled(true); }
From source file:Main.java
Main() { JFrame jfrm = new JFrame("Use JList"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(200, 160);//from w ww. j a v a2 s . com jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jlst.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); jlst.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent le) { int idx = jlst.getSelectedIndex(); if (idx != -1) System.out.println("Current selection: " + languages[idx]); else System.out.println("Please choose a language."); } }); jfrm.add(new JScrollPane(jlst)); jfrm.setSize(300, 300); jfrm.setVisible(true); }
From source file:Main.java
public Main() { JPanel jp = new JPanel(); jp.setLayout(new BorderLayout()); final JTabbedPane tb = new JTabbedPane(); JButton btn = new JButton("push me !!!"); btn.addActionListener(e -> {/* w w w .j a v a 2 s.c o m*/ tb.setEnabledAt(1, true); tb.setEnabledAt(2, true); tb.setEnabledAt(3, true); tb.setEnabledAt(4, true); }); JPanel pnl = new JPanel(); pnl.add(btn); tb.add("Tab1", pnl); tb.add("Tab2", new JTextArea(10, 20)); tb.add("Tab3", new JTextArea(10, 20)); tb.add("Tab4", new JTextArea(10, 20)); tb.add("Tab5", new JTextArea(10, 20)); jp.add(tb, BorderLayout.CENTER); tb.setEnabledAt(1, false); tb.setEnabledAt(2, false); tb.setEnabledAt(3, false); tb.setEnabledAt(4, false); JFrame frame = new JFrame(); frame.setLayout(new BorderLayout()); frame.add(jp, BorderLayout.CENTER); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }
From source file:Main.java
Main() { JFrame f = new JFrame(); f.setLayout(new FlowLayout()); f.setSize(280, 300);//from www.j a va2 s . c o m f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); scrollBarVertical.setPreferredSize(new Dimension(20, 200)); scrollbarHorizontal.setPreferredSize(new Dimension(200, 20)); scrollbarHorizontal.setValue(50); scrollBarVertical.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { if (scrollBarVertical.getValueIsAdjusting()) return; System.out.println("Value of vertical scroll bar: " + ae.getValue()); } }); scrollbarHorizontal.addAdjustmentListener(new AdjustmentListener() { public void adjustmentValueChanged(AdjustmentEvent ae) { System.out.println("Value of horizontal scroll bar: " + ae.getValue()); } }); f.add(scrollBarVertical); f.add(scrollbarHorizontal); f.setVisible(true); }
From source file:ButtonDemo.java
ButtonDemo() { JFrame jfrm = new JFrame("A Button Example"); jfrm.setLayout(new FlowLayout()); jfrm.setSize(220, 90);/*from ww w . ja v a 2 s . co m*/ jfrm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jbtnA.addActionListener(this); jbtnB.addActionListener(this); jfrm.add(jbtnA); jfrm.add(jbtnB); jfrm.setVisible(true); }