Java 类java.awt.Panel 实例源码

项目:incubator-netbeans    文件:ProcessorTest.java   
public void testCanHandleComplexData() throws Exception {
    Panel p = new Panel();
    p.setForeground(Color.BLUE);

    FileObject template = FileUtil.createData(root, "some.txt");
    OutputStream os = template.getOutputStream();
    String txt = "<html><h1>${panel.foreground.red} ${panel.foreground.green} ${panel.foreground.blue}</h1></html>";
    os.write(txt.getBytes());
    os.close();
    template.setAttribute("panel", p);

    StringWriter w = new StringWriter();

    apply(template, w);

    String exp = "<html><h1>0 0 255</h1></html>";
    assertEquals(exp, w.toString());
}
项目:OpenJSharp    文件:WPrinterJob.java   
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
项目:parabuild-ci    文件:ConnectionDialog.java   
/**
 * Method declaration
 *
 *
 * @param center
 *
 * @return
 */
protected static Panel createBorderPanel(Component center) {

    Panel p = new Panel();

    p.setBackground(SystemColor.control);
    p.setLayout(new BorderLayout());
    p.add("Center", center);
    p.add("North", createLabel(""));
    p.add("South", createLabel(""));
    p.add("East", createLabel(""));
    p.add("West", createLabel(""));
    p.setBackground(SystemColor.control);

    return p;
}
项目:parabuild-ci    文件:ConnectionDialog.java   
/**
 * Method declaration
 *
 *
 * @param center
 *
 * @return
 */
protected static Panel createBorderPanel(Component center) {

    Panel p = new Panel();

    p.setBackground(SystemColor.control);
    p.setLayout(new BorderLayout());
    p.add("Center", center);
    p.add("North", createLabel(""));
    p.add("South", createLabel(""));
    p.add("East", createLabel(""));
    p.add("West", createLabel(""));
    p.setBackground(SystemColor.control);

    return p;
}
项目:etomica    文件:DisplayPolytopeCanvasG3DSys.java   
public DisplayPolytopeCanvasG3DSys(DisplayPolytope _box) {
    super(null);
    displayPolytope = _box;

    // init G3DSys
    // adding JPanel flickers, Panel does not. Nobody knows why.
    /*
     * Set visible false here to be toggled later; seems to fix the
     * 'sometimes gray' bug
     */
    // this.setVisible(false); // to be set visible later by
    // SimulationGraphic
    panel = new Panel();
    this.setLayout(new java.awt.GridLayout());
    panel.setLayout(new java.awt.GridLayout());
    panel.setSize(1600, 1600);
    this.add(panel);
    gsys = new G3DSys(panel);
    setBackgroundColor(Color.BLACK);
    setBoundaryFrameColor(Color.WHITE);
}
项目:jdk8u-jdk    文件:WPrinterJob.java   
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
项目:jdk8u-jdk    文件:SelectionAutoscrollTest.java   
void createObjects() {
    textArea = new TextArea( bigString() );
    robot = Util.createRobot();

    Panel panel = new Panel();
    panel.setLayout( new GridLayout(3,3) );

    for( int y=0; y<3; ++y ) {
        for( int x=0; x<3; ++x ) {
            if( x==1 && y==1 ) {
                panel.add( textArea );
            } else {
                panel.add( new Panel() );
            }
        }
    }

    Frame frame = new Frame( "TextArea cursor icon test" );
    frame.setSize( 300, 300 );
    frame.add( panel );
    frame.setVisible( true );
}
项目:jdk8u-jdk    文件:SelectionVisible.java   
@Override
public void init() {
    ta = new TextArea(4, 20);
    ta.setText("01234\n56789");
    ta.select(3, 9);

    final TextArea instruction = new TextArea("INSTRUCTIONS:\n"
                                             + "The text 34567 should be selected in the TextArea.\n"
                                             + "If this is what you observe, then the test passes.\n"
                                             + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    instruction.setEditable(false);
    instruction.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(ta);
    setLayout(new BorderLayout());
    add(instruction, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
项目:jdk8u-jdk    文件:SelectionInvisibleTest.java   
public static void main(String[] args) throws Exception {

        Frame frame = new Frame();
        frame.setSize(300, 200);
        TextField textField = new TextField(TEXT + LAST_WORD, 30);
        Panel panel = new Panel(new FlowLayout());
        panel.add(textField);
        frame.add(panel);
        frame.setVisible(true);

        SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
        toolkit.realSync();

        Robot robot = new Robot();
        robot.setAutoDelay(50);

        Point point = textField.getLocationOnScreen();
        int x = point.x + textField.getWidth() / 2;
        int y = point.y + textField.getHeight() / 2;
        robot.mouseMove(x, y);
        robot.mousePress(InputEvent.BUTTON1_MASK);
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        robot.mousePress(InputEvent.BUTTON1_MASK);
        int N = 10;
        int dx = textField.getWidth() / N;
        for (int i = 0; i < N; i++) {
            x += dx;
            robot.mouseMove(x, y);
        }
        robot.mouseRelease(InputEvent.BUTTON1_MASK);
        toolkit.realSync();

        if (!textField.getSelectedText().endsWith(LAST_WORD)) {
            throw new RuntimeException("Last word is not selected!");
        }
    }
项目:jdk8u-jdk    文件:SelectionVisible.java   
@Override
public void init() {
    tf = new TextField(20);
    tf.setText("0123456789");
    tf.select(0, 6);

    final TextArea ta = new TextArea("INSTRUCTIONS:\n"
                                     + "The text 012345 should be selected in the TextField.\n"
                                     + "If this is what you observe, then the test passes.\n"
                                     + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    ta.setEditable(false);
    ta.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(tf);
    setLayout(new BorderLayout());
    add(ta, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
项目:jdk8u-jdk    文件:MultiResolutionSplashTest.java   
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        final float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = ((SunGraphics2D) g).surfaceData.getDefaultScale();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
项目:anti-fanmei    文件:FunPlot.java   
private void init()
{
    f = new Frame("Demo");
    bt1 = new Button("SIN");
    bt2 = new Button("COS");
    bt3 = new Button("EXIT");
    mc = new MyCanvas();
    p = new Panel();


    f.setBounds(100, 100, 500, 500);
    f.setLayout(new BorderLayout());

    p.add(bt1);
    p.add(bt2);
    p.add(bt3);
    f.add(p, BorderLayout.NORTH);
    f.add(mc, BorderLayout.CENTER);

    addEvent();
    f.setVisible(true);
}
项目:openjdk-jdk10    文件:KeyboardFocusManagerPeerImpl.java   
public static boolean shouldFocusOnClick(Component component) {
    boolean acceptFocusOnClick = false;

    // A component is generally allowed to accept focus on click
    // if its peer is focusable. There're some exceptions though.


    // CANVAS & SCROLLBAR accept focus on click
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    if (component instanceof Canvas ||
        component instanceof Scrollbar)
    {
        acceptFocusOnClick = true;

    // PANEL, empty only, accepts focus on click
    } else if (component instanceof Panel) {
        acceptFocusOnClick = (((Panel)component).getComponentCount() == 0);


    // Other components
    } else {
        ComponentPeer peer = (component != null ? acc.getPeer(component) : null);
        acceptFocusOnClick = (peer != null ? peer.isFocusable() : false);
    }
    return acceptFocusOnClick && acc.canBeFocusOwner(component);
}
项目:openjdk-jdk10    文件:WPrinterJob.java   
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
项目:openjdk-jdk10    文件:SelectionAutoscrollTest.java   
void createObjects() {
    textArea = new TextArea( bigString() );
    robot = Util.createRobot();

    Panel panel = new Panel();
    panel.setLayout( new GridLayout(3,3) );

    for( int y=0; y<3; ++y ) {
        for( int x=0; x<3; ++x ) {
            if( x==1 && y==1 ) {
                panel.add( textArea );
            } else {
                panel.add( new Panel() );
            }
        }
    }

    Frame frame = new Frame( "TextArea cursor icon test" );
    frame.setSize( 300, 300 );
    frame.add( panel );
    frame.setVisible( true );
}
项目:openjdk-jdk10    文件:SelectionVisible.java   
@Override
public void init() {
    ta = new TextArea(4, 20);
    ta.setText("01234\n56789");
    ta.select(3, 9);

    final TextArea instruction = new TextArea("INSTRUCTIONS:\n"
                                             + "The text 34567 should be selected in the TextArea.\n"
                                             + "If this is what you observe, then the test passes.\n"
                                             + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    instruction.setEditable(false);
    instruction.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(ta);
    setLayout(new BorderLayout());
    add(instruction, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
项目:openjdk-jdk10    文件:DisabledUndoTest.java   
public static void initTestWindow() {
    mainFrame = new Frame();
    p1 = new Panel();
    mainFrame.setTitle("TestWindow");
    mainFrame.setBounds(700, 10, 400, 100);

    tf = new TextField(20);
    tf.select(0, 10);
    bt = new Button("Disable textfield");
    p1.add(tf);
    p1.add(bt);
    mainFrame.add(p1);
    bt.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            tf.setEditable(false);
        }
    });
    mainFrame.setVisible(true);
}
项目:openjdk-jdk10    文件:ScrollSelectionTest.java   
public TestDialog(Frame frame, String name) {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    buttonP = new Panel();
    passB = new Button("pass");
    passB.setActionCommand("pass");
    passB.addActionListener(this);
    buttonP.add("East", passB);

    failB = new Button("Fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("West", failB);

    add("South", buttonP);
    pack();
    setVisible(true);
}
项目:openjdk-jdk10    文件:SelectionVisible.java   
@Override
public void init() {
    tf = new TextField(20);
    tf.setText("0123456789");
    tf.select(0, 6);

    final TextArea ta = new TextArea("INSTRUCTIONS:\n"
                                     + "The text 012345 should be selected in the TextField.\n"
                                     + "If this is what you observe, then the test passes.\n"
                                     + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    ta.setEditable(false);
    ta.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(tf);
    setLayout(new BorderLayout());
    add(ta, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
项目:openjdk-jdk10    文件:SetShapeTest.java   
private static void createUI() throws Exception {
    SwingUtilities.invokeAndWait(new Runnable() {
        @Override
        public void run() {
            background = new Frame();
            background.setUndecorated(true);
            background.setBackground(Color.blue);
            background.setSize(300, 300);
            background.setLocation(100, 100);
            background.setVisible(true);
            window = new Window(background);
            window.setBackground(Color.red);
            window.add(new Panel(), BorderLayout.CENTER);
            window.setLocation(200, 200);
            window.setSize(100, 100);
            Area a = new Area();
            a.add(new Area(new Rectangle2D.Double(0, 0, 100, 100)));
            window.setShape(a);
            window.setVisible(true);
            window.toFront();
        }
    });
}
项目:openjdk-jdk10    文件:ChildWindowProperties.java   
public void testPanelBackground() {
    Window window = new Frame();
    window.setBackground(Color.GREEN);
    Panel panel = new Panel();
    window.add(panel);
    window.pack();
    window.setVisible(true);
    if (panel.getBackground() != Color.GREEN) {
        window.dispose();
        throw new RuntimeException("Panel Background Color Not Valid");
    }
    window.dispose();
}
项目:openjdk-jdk10    文件:WindowResizingOnMovingToAnotherDisplay.java   
public TestFrame(int width, int height) throws HeadlessException {
    super("Test Frame");
    setSize(width, height);
    mrImage = new TestMultiResolutionImage(width, height);

    Panel panel = new Panel(new FlowLayout()) {
        @Override
        public void paint(Graphics g) {
            super.paint(g);
            AffineTransform tx = ((Graphics2D) g).getTransform();
            mrImage.scaleX = tx.getScaleX();
            mrImage.scaleY = tx.getScaleY();
            Insets insets = getInsets();
            g.drawImage(mrImage, insets.left, insets.bottom, null);
        }
    };
    add(panel);
}
项目:openjdk-jdk10    文件:WindowResizingOnDPIChangingTest.java   
public TestFrame(int width, int height, boolean undecorated) throws HeadlessException {
    super("Test Frame. Undecorated: " + undecorated);
    setSize(width, height);
    mrImage = new TestMultiResolutionImage(width, height);

    setUndecorated(undecorated);
    Panel panel = new Panel(new FlowLayout()) {
        @Override
        public void paint(Graphics g) {
            super.paint(g);
            AffineTransform tx = ((Graphics2D) g).getTransform();
            mrImage.scaleX = tx.getScaleX();
            mrImage.scaleY = tx.getScaleY();
            Insets insets = getInsets();
            g.drawImage(mrImage, insets.left, insets.bottom, null);
        }
    };
    add(panel);
}
项目:openjdk-jdk10    文件:MultiResolutionSplashTest.java   
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        final float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                float scaleFactor = 1;
                if (g instanceof SunGraphics2D) {
                    scaleFactor = getScreenScaleFactor();
                }
                scaleFactors[0] = scaleFactor;
                dialog.setVisible(false);
            }
        };

        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();

        return scaleFactors[0];
    }
项目:openjdk-jdk10    文件:UnixMultiResolutionSplashTest.java   
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                String scaleStr = System.getenv("GDK_SCALE");
                if (scaleStr != null && !scaleStr.equals("")) {
                    try {
                        scaleFactors[0] = Float.valueOf(scaleStr);
                    } catch (NumberFormatException ex) {
                        scaleFactors[0] = 1.0f;
                    }
                }
                dialog.setVisible(false);
            }
        };
        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();
        return scaleFactors[0];
    }
项目:openjdk-jdk10    文件:AltGraphModifierTest.java   
public TestDialog(Frame frame, String name) {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    buttonP = new Panel();
    failB = new Button("Fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("Center", failB);

    add("South", buttonP);
    pack();
    setVisible(true);
}
项目:openjdk-jdk10    文件:bug8049533.java   
public static void main(String[] args) {
    Frame frame = new Frame();
    Panel panel = new Panel();
    frame.add(panel);

    MouseWheelEvent event = new MouseWheelEvent(panel,
            0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0,
            2, // wheelRotation
            PRECISE_WHEEL_ROTATION); // preciseWheelRotation

    MouseWheelEvent convertedEvent = (MouseWheelEvent) SwingUtilities.
            convertMouseEvent(event.getComponent(), event, null);

    if (convertedEvent.getPreciseWheelRotation() != PRECISE_WHEEL_ROTATION) {
        throw new RuntimeException("PreciseWheelRotation field is not copied!");
    }
}
项目:openjdk9    文件:KeyboardFocusManagerPeerImpl.java   
public static boolean shouldFocusOnClick(Component component) {
    boolean acceptFocusOnClick = false;

    // A component is generally allowed to accept focus on click
    // if its peer is focusable. There're some exceptions though.


    // CANVAS & SCROLLBAR accept focus on click
    final ComponentAccessor acc = AWTAccessor.getComponentAccessor();
    if (component instanceof Canvas ||
        component instanceof Scrollbar)
    {
        acceptFocusOnClick = true;

    // PANEL, empty only, accepts focus on click
    } else if (component instanceof Panel) {
        acceptFocusOnClick = (((Panel)component).getComponentCount() == 0);


    // Other components
    } else {
        ComponentPeer peer = (component != null ? acc.getPeer(component) : null);
        acceptFocusOnClick = (peer != null ? peer.isFocusable() : false);
    }
    return acceptFocusOnClick && acc.canBeFocusOwner(component);
}
项目:openjdk9    文件:WPrinterJob.java   
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
项目:openjdk9    文件:SelectionAutoscrollTest.java   
void createObjects() {
    textArea = new TextArea( bigString() );
    robot = Util.createRobot();

    Panel panel = new Panel();
    panel.setLayout( new GridLayout(3,3) );

    for( int y=0; y<3; ++y ) {
        for( int x=0; x<3; ++x ) {
            if( x==1 && y==1 ) {
                panel.add( textArea );
            } else {
                panel.add( new Panel() );
            }
        }
    }

    Frame frame = new Frame( "TextArea cursor icon test" );
    frame.setSize( 300, 300 );
    frame.add( panel );
    frame.setVisible( true );
}
项目:openjdk9    文件:SelectionVisible.java   
@Override
public void init() {
    ta = new TextArea(4, 20);
    ta.setText("01234\n56789");
    ta.select(3, 9);

    final TextArea instruction = new TextArea("INSTRUCTIONS:\n"
                                             + "The text 34567 should be selected in the TextArea.\n"
                                             + "If this is what you observe, then the test passes.\n"
                                             + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    instruction.setEditable(false);
    instruction.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(ta);
    setLayout(new BorderLayout());
    add(instruction, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
项目:openjdk9    文件:ScrollSelectionTest.java   
public TestDialog(Frame frame, String name) {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    buttonP = new Panel();
    passB = new Button("pass");
    passB.setActionCommand("pass");
    passB.addActionListener(this);
    buttonP.add("East", passB);

    failB = new Button("Fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("West", failB);

    add("South", buttonP);
    pack();
    setVisible(true);
}
项目:openjdk9    文件:SelectionVisible.java   
@Override
public void init() {
    tf = new TextField(20);
    tf.setText("0123456789");
    tf.select(0, 6);

    final TextArea ta = new TextArea("INSTRUCTIONS:\n"
                                     + "The text 012345 should be selected in the TextField.\n"
                                     + "If this is what you observe, then the test passes.\n"
                                     + "Otherwise, the test fails.", 40, 5,
                                     TextArea.SCROLLBARS_NONE);
    ta.setEditable(false);
    ta.setPreferredSize(new Dimension(300, 70));
    final Panel panel = new Panel();
    panel.setLayout(new FlowLayout());
    panel.add(tf);
    setLayout(new BorderLayout());
    add(ta, BorderLayout.CENTER);
    add(panel, BorderLayout.PAGE_END);
}
项目:openjdk9    文件:UnixMultiResolutionSplashTest.java   
static float getScaleFactor() {

        final Dialog dialog = new Dialog((Window) null);
        dialog.setSize(100, 100);
        dialog.setModal(true);
        float[] scaleFactors = new float[1];
        Panel panel = new Panel() {

            @Override
            public void paint(Graphics g) {
                String scaleStr = System.getenv("GDK_SCALE");
                if (scaleStr != null && !scaleStr.equals("")) {
                    try {
                        scaleFactors[0] = Float.valueOf(scaleStr);
                    } catch (NumberFormatException ex) {
                        scaleFactors[0] = 1.0f;
                    }
                }
                dialog.setVisible(false);
            }
        };
        dialog.add(panel);
        dialog.setVisible(true);
        dialog.dispose();
        return scaleFactors[0];
    }
项目:openjdk9    文件:AltGraphModifierTest.java   
public TestDialog(Frame frame, String name) {
    super(frame, name);
    int scrollBoth = TextArea.SCROLLBARS_BOTH;
    instructionsText = new TextArea("", 15, maxStringLength, scrollBoth);
    add("North", instructionsText);

    messageText = new TextArea("", 5, maxStringLength, scrollBoth);
    add("Center", messageText);

    buttonP = new Panel();
    failB = new Button("Fail");
    failB.setActionCommand("fail");
    failB.addActionListener(this);
    buttonP.add("Center", failB);

    add("South", buttonP);
    pack();
    setVisible(true);
}
项目:openjdk9    文件:bug8049533.java   
public static void main(String[] args) {
    Frame frame = new Frame();
    Panel panel = new Panel();
    frame.add(panel);

    MouseWheelEvent event = new MouseWheelEvent(panel,
            0, 0, 0, 0, 0, 0, 0, 0, false, 0, 0,
            2, // wheelRotation
            PRECISE_WHEEL_ROTATION); // preciseWheelRotation

    MouseWheelEvent convertedEvent = (MouseWheelEvent) SwingUtilities.
            convertMouseEvent(event.getComponent(), event, null);

    if (convertedEvent.getPreciseWheelRotation() != PRECISE_WHEEL_ROTATION) {
        throw new RuntimeException("PreciseWheelRotation field is not copied!");
    }
}
项目:ccu-historian    文件:RadialLayout.java   
/**
 * Run a demonstration.
 *
 * @param args  ignored.
 * 
 * @throws Exception when an error occurs.
 */
public static void main(final String[] args) throws Exception {
    final Frame frame = new Frame();
    final Panel panel = new Panel();
    panel.setLayout(new RadialLayout());

    panel.add(new Checkbox("One"));
    panel.add(new Checkbox("Two"));
    panel.add(new Checkbox("Three"));
    panel.add(new Checkbox("Four"));
    panel.add(new Checkbox("Five"));
    panel.add(new Checkbox("One"));
    panel.add(new Checkbox("Two"));
    panel.add(new Checkbox("Three"));
    panel.add(new Checkbox("Four"));
    panel.add(new Checkbox("Five"));

    frame.add(panel);
    frame.setSize(300, 500);
    frame.setVisible(true);
}
项目:gcs    文件:WeaponEditor.java   
/**
 * Creates a new {@link WeaponEditor}.
 *
 * @param owner The owning row.
 * @param weapons The weapons to modify.
 * @param weaponClass The {@link Class} of weapons.
 */
public WeaponEditor(ListRow owner, List<WeaponStats> weapons, Class<? extends WeaponStats> weaponClass) {
    super(new BorderLayout());
    mOwner = owner;
    mWeaponClass = weaponClass;
    mAddButton = new IconButton(StdImage.ADD, ADD_TOOLTIP, () -> addWeapon());
    mDeleteButton = new IconButton(StdImage.REMOVE, REMOVE_TOOLTIP, () -> mOutline.deleteSelection());
    mDeleteButton.setEnabled(false);
    Panel top = new Panel(new BorderLayout());
    Panel left = new Panel(new PrecisionLayout());
    left.add(mAddButton);
    left.add(mDeleteButton);
    top.add(left, BorderLayout.WEST);
    top.add(createOutline(weapons, weaponClass), BorderLayout.CENTER);
    add(top, BorderLayout.NORTH);
    add(createEditorPanel(), BorderLayout.CENTER);
    setName(toString());
}
项目:PhET    文件:ConfigurationForm.java   
public void drawForm()
{

    removeAll();    
    cRightAxis = new Choice();

    Panel mainPanel = new Panel();
    mainPanel.setLayout( new GridLayout(recorder.plotSize + 2, 0) );

    mainPanel.add(L1);
    cRightAxis.addItem("Parameters (0 to 1)");
    cRightAxis.addItem("Currents");
    mainPanel.add(cRightAxis);

    for (int x = 0; x < recorder.plotSize; x++)
    {
        c[x] = new Checkbox(recorder.names[x] );
        c[x].setForeground( recorder.colorArray[x] );
        c[x].setState( recorder.plot[x] );
        mainPanel.add(c[x]);
    }

    setLayout( new BorderLayout());
    add("Center", mainPanel);
    validate();
}
项目:JMiniZinc    文件:VariableDialog.java   
public VariableDialog(File mznFile) throws IOException {
    VariableDialog.mznFile = mznFile;
   MiniZincCP mznCp = new MiniZincCP(mznFile);
    decisionVariables = mznCp.getElementsFromFile();
    mapWithControls = new ArrayList<>();
    userConstraints = new ArrayList<>();
    controlPanel = new Panel();

    prepareGUI();
    displayDecisionVariables();
    addComponents();

    mainFrame.pack();
    mainFrame.setLocationRelativeTo(null);
    mainFrame.setResizable(false);
    mainFrame.setVisible(true);

}