Search in sources :

Example 6 with Dimension

use of java.awt.Dimension in project cogtool by cogtool.

the class SplashForm method addFillComponents.

/**
    * Adds fill components to empty cells in the first row and first column of the grid.
    * This ensures that the grid spacing will be the same as shown in the designer.
    * @param cols an array of column indices in the first row where fill components should be added.
    * @param rows an array of row indices in the first column where fill components should be added.
    */
void addFillComponents(Container panel, int[] cols, int[] rows) {
    Dimension filler = new Dimension(10, 10);
    boolean filled_cell_11 = false;
    CellConstraints cc = new CellConstraints();
    if (cols.length > 0 && rows.length > 0) {
        if (cols[0] == 1 && rows[0] == 1) {
            /** add a rigid area  */
            panel.add(Box.createRigidArea(filler), cc.xy(1, 1));
            filled_cell_11 = true;
        }
    }
    for (int index = 0; index < cols.length; index++) {
        if (cols[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(cols[index], 1));
    }
    for (int index = 0; index < rows.length; index++) {
        if (rows[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(1, rows[index]));
    }
}
Also used : Dimension(java.awt.Dimension) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 7 with Dimension

use of java.awt.Dimension in project cogtool by cogtool.

the class VersionInfoForm method addFillComponents.

/**
    * Adds fill components to empty cells in the first row and first column of the grid.
    * This ensures that the grid spacing will be the same as shown in the designer.
    * @param cols an array of column indices in the first row where fill components should be added.
    * @param rows an array of row indices in the first column where fill components should be added.
    */
void addFillComponents(Container panel, int[] cols, int[] rows) {
    Dimension filler = new Dimension(10, 10);
    boolean filled_cell_11 = false;
    CellConstraints cc = new CellConstraints();
    if (cols.length > 0 && rows.length > 0) {
        if (cols[0] == 1 && rows[0] == 1) {
            /** add a rigid area  */
            panel.add(Box.createRigidArea(filler), cc.xy(1, 1));
            filled_cell_11 = true;
        }
    }
    for (int index = 0; index < cols.length; index++) {
        if (cols[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(cols[index], 1));
    }
    for (int index = 0; index < rows.length; index++) {
        if (rows[index] == 1 && filled_cell_11) {
            continue;
        }
        panel.add(Box.createRigidArea(filler), cc.xy(1, rows[index]));
    }
}
Also used : Dimension(java.awt.Dimension) CellConstraints(com.jgoodies.forms.layout.CellConstraints)

Example 8 with Dimension

use of java.awt.Dimension in project checkstyle by checkstyle.

the class InputSemantic method otherInstantiations.

void otherInstantiations() {
    // instantiation of classes in the same package
    Object o1 = new InputBraces();
    Object o2 = new InputModifier();
    // classes in another package with .* import
    ByteArrayOutputStream s = new ByteArrayOutputStream();
    File f = new File("/tmp");
    // classes in another package with explicit import
    Dimension dim = new Dimension();
    Color col = new Color(0, 0, 0);
}
Also used : Color(java.awt.Color) Dimension(java.awt.Dimension)

Example 9 with Dimension

use of java.awt.Dimension in project checkstyle by checkstyle.

the class InputSemantic method otherInstantiations.

void otherInstantiations() {
    // instantiation of classes in the same package
    Object o1 = new InputBraces();
    Object o2 = new InputModifier();
    // classes in another package with .* import
    ByteArrayOutputStream s = new ByteArrayOutputStream();
    File f = new File("/tmp");
    // classes in another package with explicit import
    Dimension dim = new Dimension();
    Color col = new Color(0, 0, 0);
}
Also used : Color(java.awt.Color) Dimension(java.awt.Dimension)

Example 10 with Dimension

use of java.awt.Dimension in project jna by java-native-access.

the class ShapedWindowDemo method main.

public static void main(String[] args) {
    try {
        System.setProperty("sun.java2d.noddraw", "true");
        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception e) {
    }
    final JFrame frame = new JFrame("Shaped Window Demo");
    MouseInputAdapter handler = new MouseInputAdapter() {

        private Point offset;

        private void showPopup(MouseEvent e) {
            final JPopupMenu m = new JPopupMenu();
            m.add(new AbstractAction("Hide") {

                public void actionPerformed(ActionEvent e) {
                    frame.setState(JFrame.ICONIFIED);
                }

                private static final long serialVersionUID = 1L;
            });
            m.add(new AbstractAction("Close") {

                public void actionPerformed(ActionEvent e) {
                    System.exit(0);
                }

                private static final long serialVersionUID = 1L;
            });
            m.pack();
            m.show(e.getComponent(), e.getX(), e.getY());
        }

        public void mousePressed(MouseEvent e) {
            offset = e.getPoint();
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }

        public void mouseDragged(MouseEvent e) {
            if (!SwingUtilities.isLeftMouseButton(e))
                return;
            Point where = e.getPoint();
            where.translate(-offset.x, -offset.y);
            Point loc = frame.getLocationOnScreen();
            loc.translate(where.x, where.y);
            frame.setLocation(loc.x, loc.y);
        }

        public void mouseReleased(MouseEvent e) {
            if (e.isPopupTrigger()) {
                showPopup(e);
            }
        }
    };
    frame.addMouseListener(handler);
    frame.addMouseMotionListener(handler);
    ClockFace face = new ClockFace(new Dimension(150, 150));
    frame.getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
    frame.getContentPane().add(face);
    frame.setUndecorated(true);
    try {
        Shape mask = new Area(new Ellipse2D.Float(0, 0, 150, 150));
        WindowUtils.setWindowMask(frame, mask);
        if (WindowUtils.isWindowAlphaSupported()) {
            WindowUtils.setWindowAlpha(frame, .7f);
        }
        frame.setIconImage(face.getIconImage());
        frame.setResizable(false);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocation(100, 100);
        frame.setVisible(true);
    } catch (UnsatisfiedLinkError e) {
        e.printStackTrace();
        String msg = e.getMessage() + "\nError loading the JNA library";
        JTextArea area = new JTextArea(msg);
        area.setOpaque(false);
        area.setFont(UIManager.getFont("Label.font"));
        area.setEditable(false);
        area.setColumns(80);
        area.setRows(8);
        area.setWrapStyleWord(true);
        area.setLineWrap(true);
        JOptionPane.showMessageDialog(frame, new JScrollPane(area), "Library Load Error: " + System.getProperty("os.name") + "/" + System.getProperty("os.arch"), JOptionPane.ERROR_MESSAGE);
        System.exit(1);
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) MouseEvent(java.awt.event.MouseEvent) Shape(java.awt.Shape) JTextArea(javax.swing.JTextArea) ActionEvent(java.awt.event.ActionEvent) Point(java.awt.Point) Dimension(java.awt.Dimension) JPopupMenu(javax.swing.JPopupMenu) Ellipse2D(java.awt.geom.Ellipse2D) Area(java.awt.geom.Area) JTextArea(javax.swing.JTextArea) JFrame(javax.swing.JFrame) AbstractAction(javax.swing.AbstractAction) MouseInputAdapter(javax.swing.event.MouseInputAdapter)

Aggregations

Dimension (java.awt.Dimension)3966 JPanel (javax.swing.JPanel)1083 JLabel (javax.swing.JLabel)737 Point (java.awt.Point)676 JButton (javax.swing.JButton)667 ActionEvent (java.awt.event.ActionEvent)642 ActionListener (java.awt.event.ActionListener)581 JScrollPane (javax.swing.JScrollPane)554 BorderLayout (java.awt.BorderLayout)490 Insets (java.awt.Insets)403 BoxLayout (javax.swing.BoxLayout)333 GridBagLayout (java.awt.GridBagLayout)308 GridBagConstraints (java.awt.GridBagConstraints)262 FlowLayout (java.awt.FlowLayout)240 JTextField (javax.swing.JTextField)231 ImageIcon (javax.swing.ImageIcon)216 Component (java.awt.Component)214 Color (java.awt.Color)202 ChangeEvent (javax.swing.event.ChangeEvent)200 ChangeListener (javax.swing.event.ChangeListener)198