Example usage for java.awt Panel Panel

List of usage examples for java.awt Panel Panel

Introduction

In this page you can find the example usage for java.awt Panel Panel.

Prototype

public Panel() 

Source Link

Document

Creates a new panel using the default layout manager.

Usage

From source file:Align_Projections.java

public void run(String arg) {
    if (instance != null) {
        instance.toFront();/*w  w  w .j  a  v  a  2 s  .  co m*/
        return;
    }
    instance = this;
    addKeyListener(IJ.getInstance());

    if (sourceStackImp == null) {
        sourceStackImp = WindowManager.getCurrentImage();
        if (sourceStackImp != null) {
            centerPixel = 0.5 * (sourceStackImp.getWidth() - 1);
        } else {
            centerPixel = 50; // completely arbitrary
        }
    }

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));

    Panel valuesPanel = new Panel();
    valuesPanel.setLayout(new GridLayout(6, 2));

    Label centerPixelLabel = new Label("Center Pixel");
    valuesPanel.add(centerPixelLabel);
    centerPixelText = new TextField(IJ.d2s(centerPixel, 1), 15);
    valuesPanel.add(centerPixelText);

    Label detectorAngleLabel = new Label("Detector Angle");
    valuesPanel.add(detectorAngleLabel);
    detectorAngleText = new TextField(IJ.d2s(0, 4), 15);
    valuesPanel.add(detectorAngleText);

    Label horizontalBorderLabel = new Label("Horizontal Border");
    valuesPanel.add(horizontalBorderLabel);
    horizontalBorderText = new TextField("0", 15);
    valuesPanel.add(horizontalBorderText);

    Label topBorderLabel = new Label("Top Border");
    valuesPanel.add(topBorderLabel);
    topBorderText = new TextField("0", 15);
    valuesPanel.add(topBorderText);

    Label bottomBorderLabel = new Label("Bottom Border");
    valuesPanel.add(bottomBorderLabel);
    bottomBorderText = new TextField("0", 15);
    valuesPanel.add(bottomBorderText);

    Label crossCorrelationLabel = new Label("Cross-Correlation");
    valuesPanel.add(crossCorrelationLabel);
    crossCorrelationText = new Label("-");
    valuesPanel.add(crossCorrelationText);

    this.add(valuesPanel);

    updateButton = addButton("Update");
    optimizeButton = addButton("Optimize");
    applyButton = addButton("Apply to stack and save");
    resetButton = addButton("Reset");

    pack();
    GUI.center(this);
    show();
}

From source file:com.abelsky.idea.geekandpoke.ui.SettingsPanel.java

@Override
public JComponent createComponent() {
    if (panel == null) {
        panel = new Panel();
    }
    return panel;
}

From source file:ControlQueryPApplet.java

/***************************************************************************
 * Respond to ControllerEvents from the Player that was created. For the
 * bare bones player the only event of import is the RealizeCompleteEvent.
 * At that stage the visual component and controller for the Player can
 * finally be obtained and thus displayed.
 **************************************************************************/
public synchronized void controllerUpdate(ControllerEvent e) {

    if (e instanceof RealizeCompleteEvent) {
        Control[] allControls = player.getControls();
        System.out.println("" + allControls.length + " controls for a Player @ REALIZED:");
        for (int i = 0; i < allControls.length; i++)
            System.out.println("" + (i + 1) + ": " + allControls[i]);
        add(player.getVisualComponent(), "North");
        add(player.getControlPanelComponent(), "South");
        validate();/*  w w w .j  ava2s  .  co  m*/
    } else if (e instanceof StartEvent) {
        Control[] allControls = player.getControls();
        System.out.println("" + allControls.length + " controls for a Player @ START:");
        Panel panel = new Panel();
        for (int i = 0; i < allControls.length; i++) {
            System.out.println("" + (i + 1) + ": " + allControls[i]);
            Component cont = allControls[i].getControlComponent();
            if (cont != null) {
                System.out.println("Has a graphical component");
                panel.add(cont);
            }
        }
        panel.validate();
        add(panel, "Center");
        validate();
        FrameGrabbingControl frameControl = (FrameGrabbingControl) player
                .getControl("javax.media.control.FrameGrabbingControl");
        if (frameControl == null)
            System.out.println("Unable to obtain FrameRateControl");
        else {
            System.out.println("Have Frame Rate control");
            panel.add(frameControl.getControlComponent());
            panel.validate();
        }

    }

}

From source file:SumUp.java

/** init() is an Applet method called by the browser to initialize */
public void init() {
    setBackground(Color.magenta);
    // The layout of the Applet is a Grid; always add things in pairs!
    setLayout(new GridLayout(0, 2));
    Choice c;/*from   ww  w. ja v  a  2  s  .c  o  m*/
    add(new Label("Option 1"));
    add(c = new Choice());
    c.addItem("0");
    c.addItem("100");
    c.addItem("200");
    c.addItem("400");
    cs[numChoices++] = c;

    add(new Label("Option 2"));
    add(c = new Choice());
    c.addItem("0");
    c.addItem("100");
    c.addItem("200");
    c.addItem("400");
    cs[numChoices++] = c;

    Panel p = new Panel();
    p.setBackground(Color.pink);
    p.add(new Label("Total:"));
    p.add(resultField = new Label("000000"));
    add(p);

    sendButton = new Button("Send it");
    add(sendButton); // connect Button into Applet
    sendButton.addActionListener(this); // connect it back to Applet
}

From source file:TexCoordTest.java

protected void addCanvas3D(Canvas3D c3d) {
    setLayout(new BorderLayout());
    add(c3d, BorderLayout.CENTER);

    Panel controlPanel = new Panel();

    // creates some GUI components so we can modify the
    // scene and texure coordinate generation at runtime
    Button eyeButton = new Button("EYE_LINEAR");
    eyeButton.addActionListener(this);
    controlPanel.add(eyeButton);/*w  ww . j av a2s . c  om*/

    Button objectButton = new Button("OBJECT_LINEAR");
    objectButton.addActionListener(this);
    controlPanel.add(objectButton);

    Button sphereButton = new Button("SPHERE_MAP");
    sphereButton.addActionListener(this);
    controlPanel.add(sphereButton);

    Button rotateButton = new Button("Rotate");
    rotateButton.addActionListener(this);
    controlPanel.add(rotateButton);

    Button translateButton = new Button("Translate");
    translateButton.addActionListener(this);
    controlPanel.add(translateButton);

    add(controlPanel, BorderLayout.SOUTH);

    doLayout();
}

From source file:PlayerOfMedia.java

/***************************************************************************
 * Construct a PlayerOfMedia. The Frame will have the title supplied by the
 * user. All initial actions on the PlayerOfMedia object are initiated
 * through its menu (or shotcut key).//  w w  w .j a  v a  2 s  .c o m
 **************************************************************************/
PlayerOfMedia(String name) {

    super(name);
    ///////////////////////////////////////////////////////////
    // Setup the menu system: a "File" menu with Open and Quit.
    ///////////////////////////////////////////////////////////
    bar = new MenuBar();
    fileMenu = new Menu("File");
    MenuItem openMI = new MenuItem("Open...", new MenuShortcut(KeyEvent.VK_O));
    openMI.setActionCommand("OPEN");
    openMI.addActionListener(this);
    fileMenu.add(openMI);
    MenuItem quitMI = new MenuItem("Quit", new MenuShortcut(KeyEvent.VK_Q));
    quitMI.addActionListener(this);
    quitMI.setActionCommand("QUIT");
    fileMenu.add(quitMI);
    bar.add(fileMenu);
    setMenuBar(bar);

    ///////////////////////////////////////////////////////
    // Layout the frame, its position on screen, and ensure
    // window closes are dealt with properly, including
    // relinquishing the resources of any Player.
    ///////////////////////////////////////////////////////
    setLayout(new BorderLayout());
    setLocation(100, 100);
    addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            if (player != null) {
                player.stop();
                player.close();
            }
            System.exit(0);
        }
    });

    /////////////////////////////////////////////////////
    // Build the Dialog box by which the user can select
    // the media to play.
    /////////////////////////////////////////////////////
    selectionDialog = new Dialog(this, "Media Selection");
    Panel pan = new Panel();
    pan.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    mediaName = new TextField(40);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;
    pan.add(mediaName, gbc);
    choose = new Button("Choose File...");
    gbc.ipadx = 10;
    gbc.ipady = 10;
    gbc.gridx = 2;
    gbc.gridwidth = 1;
    pan.add(choose, gbc);
    choose.addActionListener(this);
    open = new Button("Open");
    gbc.gridy = 1;
    gbc.gridx = 1;
    pan.add(open, gbc);
    open.addActionListener(this);
    cancel = new Button("Cancel");
    gbc.gridx = 2;
    pan.add(cancel, gbc);
    cancel.addActionListener(this);
    selectionDialog.add(pan);
    selectionDialog.pack();
    selectionDialog.setLocation(200, 200);

    ////////////////////////////////////////////////////
    // Build the error Dialog box by which the user can
    // be informed of any errors or problems.
    ////////////////////////////////////////////////////
    errorDialog = new Dialog(this, "Error", true);
    errorLabel = new Label("");
    errorDialog.add(errorLabel, "North");
    ok = new Button("OK");
    ok.addActionListener(this);
    errorDialog.add(ok, "South");
    errorDialog.pack();
    errorDialog.setLocation(150, 300);

    Manager.setHint(Manager.PLUGIN_PLAYER, new Boolean(true));
}

From source file:LightTest.java

protected void createLight(LightObject light, BranchGroup objRoot) {
    Frame frame = new Frame(light.getName());
    Panel aPanel = new Panel();
    frame.add(aPanel);/*from w  w  w . jav  a2s  . co m*/
    light.addUiToPanel(aPanel);
    frame.pack();
    frame.setSize(new Dimension(400, 250));
    frame.validate();
    frame.setVisible(true);

    // add the geometry that depicts the light
    // to the scenegraph
    objRoot.addChild(light.createGeometry());

    // finally add the light itself to the scenegraph
    objRoot.addChild(light.getLight());
}

From source file:Seek.java

/**
 * Given a DataSource, create a player and use that player
 * as a player to playback the media./*from   w ww  . j av a  2s  .  c  o m*/
 */
public boolean open(DataSource ds) {

    System.err.println("create player for: " + ds.getContentType());

    try {
        p = Manager.createPlayer(ds);
    } catch (Exception e) {
        System.err.println("Failed to create a player from the given DataSource: " + e);
        return false;
    }

    p.addControllerListener(this);

    p.realize();
    if (!waitForState(p.Realized)) {
        System.err.println("Failed to realize the player.");
        return false;
    }

    // Try to retrieve a FramePositioningControl from the player.
    fpc = (FramePositioningControl) p.getControl("javax.media.control.FramePositioningControl");

    if (fpc == null) {
        System.err.println("The player does not support FramePositioningControl.");
        System.err.println("There's no reason to go on for the purpose of this demo.");
        return false;
    }

    Time duration = p.getDuration();

    if (duration != Duration.DURATION_UNKNOWN) {
        System.err.println("Movie duration: " + duration.getSeconds());

        totalFrames = fpc.mapTimeToFrame(duration);
        if (totalFrames != FramePositioningControl.FRAME_UNKNOWN)
            System.err.println("Total # of video frames in the movies: " + totalFrames);
        else
            System.err.println("The FramePositiongControl does not support mapTimeToFrame.");

    } else {
        System.err.println("Movie duration: unknown");
    }

    // Prefetch the player.
    p.prefetch();
    if (!waitForState(p.Prefetched)) {
        System.err.println("Failed to prefetch the player.");
        return false;
    }

    // Display the visual & control component if there's one.

    setLayout(new BorderLayout());

    cntlPanel = new Panel();

    fwdButton = new Button("Forward");
    bwdButton = new Button("Backward");
    rndButton = new Button("Random");

    fwdButton.addActionListener(this);
    bwdButton.addActionListener(this);
    rndButton.addActionListener(this);

    cntlPanel.add(fwdButton);
    cntlPanel.add(bwdButton);
    cntlPanel.add(rndButton);

    Component vc;
    if ((vc = p.getVisualComponent()) != null) {
        add("Center", vc);
    }

    add("South", cntlPanel);

    setVisible(true);

    return true;
}

From source file:BehaviorTest.java

public BehaviorTest() {
    initJava3d();/*w  w  w.  j a va2s  .co m*/

    Panel controlPanel = new Panel();

    Button rotateButton = new Button("Rotate");
    rotateButton.addActionListener(this);
    controlPanel.add(rotateButton);

    Button objSizeButton = new Button("Object Size");
    objSizeButton.addActionListener(this);
    controlPanel.add(objSizeButton);

    Button explodeButton = new Button("Explode");
    explodeButton.addActionListener(this);
    controlPanel.add(explodeButton);

    Button stretchButton = new Button("Stretch");
    stretchButton.addActionListener(this);
    controlPanel.add(stretchButton);

    Button boundsButton = new Button("Bounds");
    boundsButton.addActionListener(this);
    controlPanel.add(boundsButton);

    Button fpsButton = new Button("FPS");
    fpsButton.addActionListener(this);
    controlPanel.add(fpsButton);

    add(controlPanel, BorderLayout.SOUTH);
}

From source file:PrintFromButton.java

public void init() {
    setLayout(new BorderLayout());
    GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();

    BufferedImage bImage = new BufferedImage(200, 200, BufferedImage.TYPE_INT_ARGB);

    ImageComponent2D buffer = new ImageComponent2D(ImageComponent.FORMAT_RGBA, bImage);
    buffer.setCapability(ImageComponent2D.ALLOW_IMAGE_READ);

    Raster drawRaster = new Raster(new Point3f(0.0f, 0.0f, 0.0f), Raster.RASTER_COLOR, 0, 0, 200, 200, buffer,
            null);/*from  w  w w  .j a  v a2  s  .  co m*/

    drawRaster.setCapability(Raster.ALLOW_IMAGE_WRITE);

    // create the main scene graph
    BranchGroup scene = createSceneGraph(drawRaster);

    // create the on-screen canvas
    Canvas3D d = new Canvas3D(config, false);
    add("Center", d);

    // create a simple universe
    u = new SimpleUniverse(d);

    // This will move the ViewPlatform back a bit so the
    // objects in the scene can be viewed.
    u.getViewingPlatform().setNominalViewingTransform();

    // create an off Screen Buffer

    c = new OffScreenCanvas3D(config, true, drawRaster);

    // set the offscreen to match the onscreen
    Screen3D sOn = d.getScreen3D();
    Screen3D sOff = c.getScreen3D();
    sOff.setSize(sOn.getSize());
    sOff.setPhysicalScreenWidth(sOn.getPhysicalScreenWidth());
    sOff.setPhysicalScreenHeight(sOn.getPhysicalScreenHeight());

    // attach the same view to the offscreen canvas
    u.getViewer().getView().addCanvas3D(c);

    // create the gui
    Button b = new Button("Print");
    b.addActionListener(this);
    Panel p = new Panel();
    p.add(b);
    add("North", p);

    u.addBranchGraph(scene);
}