List of usage examples for javax.swing JFrame pack
@SuppressWarnings("deprecation") public void pack()
From source file:Main.java
public static void main(String[] args) { JTable table = new JTable(5, 5) { @Override//ww w .j a v a 2s . c o m public Component prepareRenderer(TableCellRenderer renderer, int row, int col) { Component comp = super.prepareRenderer(renderer, row, col); ((JLabel) comp).setHorizontalAlignment(JLabel.RIGHT); return comp; } }; table.setPreferredScrollableViewportSize(table.getPreferredSize()); JScrollPane scrollPane = new JScrollPane(table); JFrame f = new JFrame(); f.getContentPane().add(scrollPane); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] a) { int HORIZSPLIT = JSplitPane.HORIZONTAL_SPLIT; int VERTSPLIT = JSplitPane.VERTICAL_SPLIT; boolean continuousLayout = true; JLabel label1 = new JLabel("a"); JLabel label2 = new JLabel("b"); JLabel label3 = new JLabel("c"); JSplitPane splitPane1 = new JSplitPane(VERTSPLIT, continuousLayout, label1, label2); splitPane1.setOneTouchExpandable(true); splitPane1.setDividerSize(2);// w w w . j a v a 2 s. c o m splitPane1.setDividerLocation(0.5); JSplitPane splitPane2 = new JSplitPane(HORIZSPLIT, splitPane1, label3); splitPane2.setOneTouchExpandable(true); splitPane2.setDividerLocation(0.4); splitPane2.setDividerSize(2); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(splitPane2); frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new Main()); frame.pack(); frame.setVisible(true);//from w w w. j a va 2 s . com }
From source file:Main.java
public static void main(String... s) { DefaultTableModel model = new DefaultTableModel(4, 4) { @Override//from w w w . j a v a 2s . c o m public boolean isCellEditable(int row, int column) { return column == 3; } @Override public Class<?> getColumnClass(int columnIndex) { if (columnIndex == 3) { return Boolean.class; } return super.getColumnClass(columnIndex); } }; JTable t = new JTable(model); JFrame f = new JFrame(); f.add(new JScrollPane(t)); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); }
From source file:FlowLayoutComponentOrientationRIGHT_TO_LEFT.java
public static void main(String[] argv) { JFrame frame = new FlowLayoutComponentOrientationRIGHT_TO_LEFT(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);//w ww . jav a2s.c o m }
From source file:Main.java
public static void main(String[] args) { Main mainPanel = new Main(); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.getContentPane().add(mainPanel);//from w w w . ja va 2s . c o m f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { JEditorPane jep = new JEditorPane(); jep.setContentType("text/html"); StringBuilder sb = new StringBuilder(); sb.append("<b>Welcome</b>:<br><hr>"); for (int i = 1; i <= 3; i++) { sb.append(create(i));//from w w w.ja va 2s . c o m } sb.append("<hr>"); jep.setText(sb.toString()); jep.setEditable(false); jep.addHyperlinkListener(e -> { if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) { System.out.println(e.getURL()); Desktop desktop = Desktop.getDesktop(); try { desktop.browse(e.getURL().toURI()); } catch (Exception ex) { ex.printStackTrace(); } } }); JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(jep); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JComboBox<String> combo = new JComboBox<>(new String[] { "One", "Two", "Three" }); JButton arrowBtn = getButtonSubComponent(combo); if (arrowBtn != null) { arrowBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { System.out.println("arrow button pressed"); }//from w w w . j ava 2s . co m }); } JFrame f = new JFrame(); f.getContentPane().add(combo); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.pack(); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new ClockPane()); frame.pack(); frame.setVisible(true);// w w w . j a va 2 s . c o m }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame("JTable"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); f.add(new Main()); f.pack(); f.setVisible(true);//from w ww .ja v a2s .c o m }