List of usage examples for java.awt Dimension Dimension
public Dimension(int width, int height)
From source file:Main.java
public static void main(final String[] args) { JFrame frame = new JFrame("Test"); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.getContentPane().setBackground(Color.red); frame.setPreferredSize(new Dimension(400, 300)); frame.pack();/* w ww .j av a 2s. com*/ frame.setVisible(true); }
From source file:FlowLayoutExample.java
public static void main(String[] args) { JPanel panel = new JPanel(); JTextArea area = new JTextArea("text area"); area.setPreferredSize(new Dimension(100, 100)); JButton button = new JButton("button"); panel.add(button);/*from w w w .j a v a 2 s . c om*/ panel.add(new JScrollPane(area)); JFrame f = new JFrame(); f.add(panel); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); Box b = Box.createVerticalBox(); JTextField field1 = new JTextField(); JTextField field2 = new JTextField(); field1.setMaximumSize(new Dimension(Integer.MAX_VALUE, field1.getPreferredSize().height)); field2.setMaximumSize(new Dimension(Integer.MAX_VALUE, field2.getPreferredSize().height)); b.add(field1);/* w w w . j a v a 2 s . com*/ b.add(field2); b.add(Box.createVerticalGlue()); f.setContentPane(b); f.setSize(500, 200); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame("Fixed size content"); f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Container c = f.getContentPane(); c.setBackground(Color.YELLOW); Dimension d = new Dimension(400, 40); c.setPreferredSize(d);//from ww w . ja va 2s.c o m f.pack(); f.setResizable(false); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(new Dimension(500, 500)); JDialog dialog = new JDialog(frame, "Export", ModalityType.MODELESS); dialog.setSize(300, 300);//from www .ja v a 2s . c om JDialog dialog1 = new JDialog(dialog, "Export", ModalityType.APPLICATION_MODAL); dialog1.setSize(200, 200); frame.add(new JButton(new AbstractAction("Dialog") { @Override public void actionPerformed(ActionEvent e) { frame.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); dialog.setVisible(true); dialog1.setVisible(true); } })); frame.setVisible(true); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); int width = (int) screenSize.getWidth(); int height = (int) screenSize.getHeight(); Dimension newDim = new Dimension(width, height - 40); frame.setSize(newDim);/* www . ja v a 2 s. c o m*/ frame.setVisible(true); // FIRST visible = true frame.setResizable(false); // THEN resizable = false frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
From source file:Main.java
public static void main(String[] args) throws Exception { File f = new File("index.html"); JEditorPane jep = new JEditorPane(f.toURI().toURL()); JScrollPane sp = new JScrollPane(jep); sp.setPreferredSize(new Dimension(400, 200)); JOptionPane.showMessageDialog(null, sp); }
From source file:Main.java
public static void main(String args[]) { JFrame f = new JFrame(); f.setSize(new Dimension(300, 300)); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLayout(new FlowLayout()); JLabel label = new JLabel("Update"); String[] data = { "one", "two", "three", "four" }; JList<String> dataList = new JList<>(data); dataList.addListSelectionListener(new ListSelectionListener() { @Override/*w ww .jav a 2s .c o m*/ public void valueChanged(ListSelectionEvent arg0) { if (!arg0.getValueIsAdjusting()) { label.setText(dataList.getSelectedValue().toString()); } } }); f.add(new JScrollPane(dataList)); f.add(label); f.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JFrame f = new JFrame(); f.add(new JPanel() { @Override/*from ww w .j ava2 s .c om*/ public Dimension getPreferredSize() { return new Dimension(320, 240); } }); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice defaultScreen = ge.getDefaultScreenDevice(); Rectangle rect = defaultScreen.getDefaultConfiguration().getBounds(); int x = (int) rect.getMaxX() - f.getWidth(); int y = (int) rect.getMaxY() - f.getHeight(); f.setLocation(x, y); f.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTable table = new JTable(); Dimension d = table.getIntercellSpacing(); // d.width == 1, d.height == 1 //Add 5 spaces to the left and right sides of a cell int gapWidth = 10; int gapHeight = 4; table.setIntercellSpacing(new Dimension(gapWidth, gapHeight)); }