Java Code Examples for javax.swing.JPanel.setLocation()

The following are Jave code examples for showing how to use setLocation() of the javax.swing.JPanel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: openjdk-jdk10   File: CursorOverlappedPanelsTest.java   View Source Code Vote up 7 votes
private static JPanel createPanel(Point location, boolean enabled) {
    final JPanel panel = new JPanel();
    panel.setOpaque(false);
    panel.setEnabled(enabled);
    panel.setSize(new Dimension(200, 200));
    panel.setLocation(location);
    panel.setBorder(BorderFactory.createTitledBorder(
            enabled ? "Enabled" : "Disabled"));
    panel.setCursor(Cursor.getPredefinedCursor(
            enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
    System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
    return panel;
}
 
Example 2
Project: jdk8u-jdk   File: CursorOverlappedPanelsTest.java   View Source Code Vote up 6 votes
private static JPanel createPanel(Point location, boolean enabled) {
    final JPanel panel = new JPanel();
    panel.setOpaque(false);
    panel.setEnabled(enabled);
    panel.setSize(new Dimension(200, 200));
    panel.setLocation(location);
    panel.setBorder(BorderFactory.createTitledBorder(
            enabled ? "Enabled" : "Disabled"));
    panel.setCursor(Cursor.getPredefinedCursor(
            enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
    System.out.println("cursor: " + Cursor.getPredefinedCursor(enabled ? Cursor.CROSSHAIR_CURSOR : Cursor.DEFAULT_CURSOR));
    return panel;
}
 
Example 3
Project: jdk8u-jdk   File: javax_swing_JLayeredPane.java   View Source Code Vote up 6 votes
private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
    JPanel panel = new JPanel();
    panel.setBackground(color);
    panel.setLocation(x, y);
    panel.setSize(w, h);
    pane.add(panel, new Integer(layer));
}
 
Example 4
Project: openjdk-jdk10   File: javax_swing_JLayeredPane.java   View Source Code Vote up 6 votes
private static void init(JLayeredPane pane, int layer, int x, int y, int w, int h, Color color) {
    JPanel panel = new JPanel();
    panel.setBackground(color);
    panel.setLocation(x, y);
    panel.setSize(w, h);
    pane.add(panel, new Integer(layer));
}
 
Example 5
Project: freecol   File: InfoPanel.java   View Source Code Vote up 4 votes
/**
 * Adds a panel to show information
 *
 * @param panel The panel to add.
 * @param internalTop The top position.
 * @param internalHeight The enclosing height.
 */
private void add(JPanel panel, int internalTop, int internalHeight) {
    panel.setVisible(false);
    panel.setLocation((getWidth() - panel.getWidth()) / 2, internalTop
            + (internalHeight - panel.getHeight()) / 2);
    add(panel);
}
 
Example 6
Project: FreeCol   File: InfoPanel.java   View Source Code Vote up 3 votes
/**
 * Adds a panel to show information
 *
 * @param panel The panel to add.
 * @param internalTop The top position.
 * @param internalHeight The enclosing height.
 */
private void add(JPanel panel, int internalTop, int internalHeight) {
    panel.setVisible(false);
    panel.setLocation((getWidth() - panel.getWidth()) / 2, internalTop
            + (internalHeight - panel.getHeight()) / 2);
    add(panel);
}