List of usage examples for java.awt Button Button
public Button(String label) throws HeadlessException
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 ww . j a v a2 s.c o 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); }
From source file:BehaviorTest.java
public BehaviorTest() { initJava3d();// ww w .j a v a2 s.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:HiResCoordTest.java
protected void addCanvas3D(Canvas3D c3d) { setLayout(new BorderLayout()); Panel controlPanel = new Panel(); controlPanel.add(c3d);/*from ww w . j a va2 s.c om*/ Button button = null; button = new Button("Sun"); button.addActionListener(this); controlPanel.add(button); button = new Button("Earth"); button.addActionListener(this); controlPanel.add(button); button = new Button("House"); button.addActionListener(this); controlPanel.add(button); add(controlPanel, BorderLayout.SOUTH); add(c3d, BorderLayout.CENTER); doLayout(); }
From source file:Align_Projections.java
Button addButton(String label) { Button b = new Button(label); b.addActionListener(this); b.addKeyListener(IJ.getInstance());//from ww w . j av a 2 s .c o m add(b); return b; }
From source file:width.java
public void init() { Button button = new Button("Clear"); add(label);/*from ww w.j av a 2 s . c o m*/ add(button); button.addActionListener(this); add(new Label("(My name is " + getParameter("name") + ".)", Label.LEFT)); }
From source file:AlphaTest.java
/** * Helper method to add a Button to the UI. *//*from w w w . jav a2s . c o m*/ protected void addButton(final String szText) { Button button = new Button(szText); button.addActionListener(this); add(button); }
From source file:Text3DLoad.java
public void init() { if (textString == null) { textString = "Java3D"; }// ww w. ja v a 2s . com setLayout(new BorderLayout()); button = new Button("remove behaviors"); button.addActionListener(this); Panel p = new Panel(); p.add(button); add("South", p); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); Canvas3D c = new Canvas3D(config); add("Center", c); // Create a simple scene and attach it to the virtual universe BranchGroup scene = createSceneGraph(); // create a SimpleUniverse with 4 TransformGroups for the mouse // behaviors u = new SimpleUniverse(c); // add the behaviors to the ViewingPlatform ViewingPlatform viewingPlatform = u.getViewingPlatform(); viewingPlatform.setNominalViewingTransform(); // add orbit behavior to ViewingPlatform orbit = new OrbitBehavior(c, OrbitBehavior.REVERSE_ALL | OrbitBehavior.STOP_ZOOM); BoundingSphere bounds = new BoundingSphere(new Point3d(0.0, 0.0, 0.0), 100.0); orbit.setSchedulingBounds(bounds); viewingPlatform.setViewPlatformBehavior(orbit); behaviorsOn = true; u.addBranchGraph(scene); }
From source file:net.sf.freecol.FreeCol.java
public static void startYourAddition() throws FontFormatException, IOException { Frame mainFrame;/* w w w .ja v a 2 s . co m*/ Frame mainFrame2; TextField t1; TextField t2; TextField t3; TextField t4; Frame mainFrame3 = new Frame("Haha, am i middle?"); mainFrame = new Frame("Haha, am I right?!"); mainFrame.setSize(400, 400); mainFrame.setLayout(null); t1 = new TextField("Enter here"); t1.setBounds(160, 200, 150, 50); t2 = new TextField("What grade do we deserve?"); t3 = new TextField("Enter here"); t3.setBounds(160, 200, 150, 50); t4 = new TextField("What letter grade do we deserve?"); Button b = new Button("click ----->"); b.setBounds(30, 250, 130, 30); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { t2.setText("I think you meant 100"); } }); Button c = new Button("Submit"); c.setBounds(150, 250, 80, 30); c.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String in = t1.getText(); if (in.equals("100")) { t1.setText("Correct"); t1.setEditable(false); t1.setBackground(new Color(95, 216, 109)); if (t3.getText().equals("Correct")) { mainFrame3.setVisible(true); } } else { t1.setText("Wrong"); t1.setBackground(new Color(214, 81, 96)); } } }); t2.setBounds(160, 0, 175, 100); t2.setEditable(false); mainFrame.add(b); mainFrame.add(c); mainFrame.add(t1); mainFrame.add(t2); mainFrame.setLocation(1280, 0); mainFrame.setVisible(true); ///////////////The left area below and above is right mainFrame2 = new Frame("Haha, am i left?"); mainFrame2.setSize(400, 400); mainFrame2.setLayout(null); Button b2 = new Button("click ----->"); b2.setBounds(30, 250, 130, 30); b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { t4.setText("I think you meant A"); } }); Button c2 = new Button("Submit"); c2.setBounds(150, 250, 80, 30); c2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String in = t3.getText(); if (in.equals("A")) { t3.setText("Correct"); t3.setEditable(false); t3.setBackground(new Color(95, 216, 109)); if (t1.getText().equals("Correct")) { mainFrame3.setVisible(true); } } else { t3.setText("Wrong"); t3.setBackground(new Color(214, 81, 96)); } } }); t4.setBounds(120, 0, 220, 100); t4.setEditable(false); mainFrame2.add(b2); mainFrame2.add(c2); mainFrame2.add(t3); mainFrame2.add(t4); mainFrame2.setVisible(true); //Overall correct mainFrame3.setSize(400, 400); mainFrame3.setLayout(null); mainFrame3.setLocation(640, 420); mainFrame3.setBackground(new Color(95, 216, 109)); TextField t6 = new TextField("Soooooo give us an A!!!"); t6.setBounds(160, 200, 200, 50); t6.setBackground(new Color(102, 136, 232)); mainFrame3.add(t6); }
From source file:CustomAlphaTest.java
protected void addButton(final String szText) { Button button = new Button(szText); button.addActionListener(this); add(button);//w w w .j a v a 2 s . c o m }
From source file:PlatformTest.java
ViewingPlatform createViewer(Canvas3D c, String szName, Color3f objColor, double x, double z) { // create a Viewer and attach to its canvas // a Canvas3D can only be attached to a single Viewer Viewer viewer2 = new Viewer(c); // create a ViewingPlatform with 1 TransformGroups above the // ViewPlatform ViewingPlatform vp2 = new ViewingPlatform(1); // create and assign the PlatformGeometry to the Viewer vp2.setPlatformGeometry(createPlatformGeometry(szName)); // create and assign the ViewerAvatar to the Viewer viewer2.setAvatar(createViewerAvatar(szName, objColor)); // set the initial position for the Viewer Transform3D t3d = new Transform3D(); t3d.setTranslation(new Vector3d(x, 0, z)); vp2.getViewPlatformTransform().setTransform(t3d); // set capabilities on the TransformGroup so that the // KeyNavigatorBehavior // can modify the Viewer's position vp2.getViewPlatformTransform().setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE); vp2.getViewPlatformTransform().setCapability(TransformGroup.ALLOW_TRANSFORM_READ); // attach a navigation behavior to the position of the viewer KeyNavigatorBehavior key = new KeyNavigatorBehavior(vp2.getViewPlatformTransform()); key.setSchedulingBounds(m_Bounds); key.setEnable(false);//from w ww . j a v a 2 s . c o m // add the KeyNavigatorBehavior to the ViewingPlatform vp2.addChild(key); // set the ViewingPlatform for the Viewer viewer2.setViewingPlatform(vp2); // associate the name of the Viewer with its KeyNavigatorBehavior m_KeyHashtable.put(szName, key); // create a button to switch the Viewer ON. Button button = new Button(szName); button.addActionListener(this); add(button); return vp2; }