Search in sources :

Example 96 with Dimension

use of java.awt.Dimension in project jdk8u_jdk by JetBrains.

the class Test6524757 method addSize.

private static void addSize(List<Object> list, Component component, int x, int y, int w, int h) {
    Dimension size = component.getPreferredSize();
    int width = (size.width + 1) / w - x;
    int height = (size.height + 1) / h - y;
    list.add(new Dimension(width, height));
}
Also used : Dimension(java.awt.Dimension)

Example 97 with Dimension

use of java.awt.Dimension in project jdk8u_jdk by JetBrains.

the class bug8136998 method runTest.

public void runTest() throws Exception {
    try {
        SwingUtilities.invokeAndWait(this::setupUI);
        robot.waitForIdle();
        SwingUtilities.invokeAndWait(() -> scrollPane.getViewport().scrollRectToVisible(comboBox.getBounds()));
        robot.waitForIdle();
        // Move mouse pointer to the center of the combo box
        Point p = comboBox.getLocationOnScreen();
        Dimension d = comboBox.getSize();
        robot.mouseMove(p.x + d.width / 2, p.y + d.height / 2);
        // The currently visible rectangle in scrollPane
        Rectangle viewRect0 = Util.invokeOnEDT(scrollPane.getViewport()::getViewRect);
        // Scroll the scrollPane with mouse wheel
        robot.mouseWheel(1);
        robot.waitForIdle();
        // The updated rectangle
        Rectangle viewRect1 = Util.invokeOnEDT(scrollPane.getViewport()::getViewRect);
        if (viewRect0.y == viewRect1.y) {
            throw new RuntimeException("Mouse wheel should have scrolled the JScrollPane");
        }
    } finally {
        if (frame != null) {
            frame.dispose();
        }
    }
    System.out.println("Test passed");
}
Also used : Rectangle(java.awt.Rectangle) Point(java.awt.Point) Dimension(java.awt.Dimension)

Example 98 with Dimension

use of java.awt.Dimension in project jdk8u_jdk by JetBrains.

the class MaximizedNormalBoundsUndecoratedTest method doTest.

boolean doTest() {
    Dimension beforeMaximizeCalled = new Dimension(300, 300);
    frame = new Frame("Test Frame");
    frame.setUndecorated(true);
    frame.setFocusable(true);
    frame.setSize(beforeMaximizeCalled);
    frame.setVisible(true);
    frame.setExtendedState(Frame.MAXIMIZED_BOTH);
    frame.setExtendedState(Frame.NORMAL);
    Dimension afterMaximizedCalled = frame.getBounds().getSize();
    frame.dispose();
    if (beforeMaximizeCalled.equals(afterMaximizedCalled)) {
        return true;
    }
    return false;
}
Also used : Frame(java.awt.Frame) Dimension(java.awt.Dimension)

Example 99 with Dimension

use of java.awt.Dimension in project jdk8u_jdk by JetBrains.

the class bug8032667 method getCheckBox.

static JCheckBox getCheckBox(String text, boolean selected) {
    JCheckBox checkBox = new JCheckBox(text);
    checkBox.setSelected(selected);
    checkBox.setSize(new Dimension(width, height));
    return checkBox;
}
Also used : JCheckBox(javax.swing.JCheckBox) Dimension(java.awt.Dimension)

Example 100 with Dimension

use of java.awt.Dimension in project jdk8u_jdk by JetBrains.

the class Test6910490 method init.

@Override
public void init() {
    Insets insets = new Insets(10, 10, 10, 10);
    Dimension size = new Dimension(getWidth() / 2, getHeight());
    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, create("Color", size, new MatteBorder(insets, RED)), create("Icon", size, new MatteBorder(insets, this)));
    pane.setDividerLocation(size.width - pane.getDividerSize() / 2);
    add(pane);
}
Also used : MatteBorder(javax.swing.border.MatteBorder) Insets(java.awt.Insets) Dimension(java.awt.Dimension) JSplitPane(javax.swing.JSplitPane)

Aggregations

Dimension (java.awt.Dimension)4003 JPanel (javax.swing.JPanel)1091 JLabel (javax.swing.JLabel)742 Point (java.awt.Point)683 JButton (javax.swing.JButton)671 ActionEvent (java.awt.event.ActionEvent)644 ActionListener (java.awt.event.ActionListener)583 JScrollPane (javax.swing.JScrollPane)558 BorderLayout (java.awt.BorderLayout)492 Insets (java.awt.Insets)411 BoxLayout (javax.swing.BoxLayout)334 GridBagLayout (java.awt.GridBagLayout)312 GridBagConstraints (java.awt.GridBagConstraints)266 FlowLayout (java.awt.FlowLayout)242 JTextField (javax.swing.JTextField)235 ImageIcon (javax.swing.ImageIcon)216 Component (java.awt.Component)215 Color (java.awt.Color)205 ChangeEvent (javax.swing.event.ChangeEvent)200 ChangeListener (javax.swing.event.ChangeListener)198