List of usage examples for java.awt Dimension Dimension
public Dimension(int width, int height)
From source file:Main.java
public static void main(String[] args) { JLabel label = new JLabel("java2s.com", JLabel.LEFT); label.setPreferredSize(new Dimension(150, 100)); JOptionPane.showMessageDialog(null, label); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame("Hello World"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setMinimumSize(new Dimension(100, 100)); frame.setVisible(true);//from w w w. ja v a2 s . c o m }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTable table = new JTable(); int gapWidth = 10; int gapHeight = 4; table.setIntercellSpacing(new Dimension(gapWidth, gapHeight)); }
From source file:Main.java
public static void main(String[] args) { JLabel image = new JLabel("java2s.com"); image.setPreferredSize(new Dimension(2000, 2000)); JScrollPane js = new JScrollPane(image); js.setPreferredSize(new Dimension(200, 200)); JOptionPane.showMessageDialog(null, js); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setMaximumSize(new Dimension(350, 250)); frame.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { Dimension size = frame.getSize(); Dimension max = frame.getMaximumSize(); if (size.getWidth() > max.getWidth()) { frame.setSize((int) max.getWidth(), (int) size.getHeight()); }/*from w w w. j a v a 2 s . c o m*/ if (size.getHeight() > max.getHeight()) { frame.setSize((int) size.getWidth(), (int) max.getHeight()); } } }); frame.setSize(200, 100); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
public static void main(String[] args) { final JFrame frame = new JFrame(); frame.setMinimumSize(new Dimension(200, 200)); frame.addComponentListener(new ComponentAdapter() { public void componentResized(ComponentEvent evt) { Dimension size = frame.getSize(); Dimension min = frame.getMinimumSize(); if (size.getWidth() < min.getWidth()) { frame.setSize((int) min.getWidth(), (int) size.getHeight()); }// w ww . j a v a 2 s .c o m if (size.getHeight() < min.getHeight()) { frame.setSize((int) size.getWidth(), (int) min.getHeight()); } } }); frame.setSize(300, 300); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
public static void main(String[] args) { Main frame = new Main(); frame.setSize(new Dimension(200, 200)); frame.add(new Button("Hello World")); frame.addWindowListener(new WindowAdapter() { @Override/* ww w .ja v a 2 s . c om*/ public void windowClosing(WindowEvent e) { System.exit(0); } }); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JTable table = new JTable(22, 5); table.setPreferredScrollableViewportSize(new Dimension(400, 300)); final JScrollPane scrollPane = new JScrollPane(table); JButton cornerButton = new JButton("#"); scrollPane.setCorner(JScrollPane.UPPER_TRAILING_CORNER, cornerButton); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); JFrame frame = new JFrame(); frame.add(scrollPane);/*from www. j av a 2 s. c o m*/ frame.pack(); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { final JEditorPane editPane1 = new JEditorPane("text/html", "Try ty\tping some tabs"); editPane1.setPreferredSize(new Dimension(400, 300)); JOptionPane.showMessageDialog(null, new JScrollPane(editPane1)); JOptionPane.showMessageDialog(null, new JScrollPane(new JEditorPane("text/html", editPane1.getText()))); }
From source file:Main.java
public static void main(String[] args) { JPanel panel = new JPanel(); panel.setPreferredSize(new Dimension(800, 600)); String test[] = { "alpha", "bravo", "charlie", "delta", "echo", "omega", "zeta" }; JList<String> list = new JList<>(test); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setLayoutOrientation(JList.VERTICAL); list.setVisibleRowCount(5);//www .j a v a 2 s .com list.setBounds(50, 150, 75, 90); JScrollPane jScrollPane1 = new JScrollPane(); jScrollPane1.setViewportView(list); panel.add(jScrollPane1); JFrame f = new JFrame(); f.add(panel); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setResizable(false); f.setFocusable(true); }