List of usage examples for java.awt Panel add
public Component add(Component comp)
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 a 2 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); }
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 w w w . j a va 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:HBox.java
public HBox() { super("Horizontal Box Test Frame"); setSize(200, 100);/* ww w . ja va2s . c om*/ Panel box = new Panel(); // Use BoxLayout.Y_AXIS below if you want a vertical box box.setLayout(new BoxLayout(box, BoxLayout.X_AXIS)); setContentPane(box); for (int i = 0; i < 3; i++) { Button b = new Button("B" + i); box.add(b); } setDefaultCloseOperation(EXIT_ON_CLOSE); setVisible(true); }
From source file:Text3DLoad.java
public void init() { if (textString == null) { textString = "Java3D"; }/* ww w .j a v a2s. co m*/ 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:SimpleMorph2.java
public SimpleMorph2() { VirtualUniverse myUniverse = new VirtualUniverse(); Locale myLocale = new Locale(myUniverse); myLocale.addBranchGraph(buildViewBranch(myCanvas3D)); myLocale.addBranchGraph(buildContentBranch()); setTitle("SimpleMorph"); setSize(400, 400);/*from w w w. j a v a2s . c o m*/ setLayout(new BorderLayout()); Panel bottom = new Panel(); bottom.add(exitButton); add(BorderLayout.CENTER, myCanvas3D); add(BorderLayout.SOUTH, bottom); exitButton.addActionListener(this); setVisible(true); }
From source file:SimpleCollision.java
public SimpleCollision() { VirtualUniverse myUniverse = new VirtualUniverse(); Locale myLocale = new Locale(myUniverse); myLocale.addBranchGraph(buildViewBranch(myCanvas3D)); myLocale.addBranchGraph(buildContentBranch()); setTitle("SimpleWorld"); setSize(400, 400);/*from w w w . j a va 2 s .c om*/ setLayout(new BorderLayout()); Panel bottom = new Panel(); bottom.add(exitButton); add(BorderLayout.CENTER, myCanvas3D); add(BorderLayout.SOUTH, bottom); exitButton.addActionListener(this); setVisible(true); }
From source file:SimpleCollision2.java
public SimpleCollision2() { VirtualUniverse myUniverse = new VirtualUniverse(); Locale myLocale = new Locale(myUniverse); myLocale.addBranchGraph(buildViewBranch(myCanvas3D)); myLocale.addBranchGraph(buildContentBranch()); setTitle("SimpleWorld"); setSize(400, 400);// w w w. j a va 2s . co m setLayout(new BorderLayout()); Panel bottom = new Panel(); bottom.add(exitButton); add(BorderLayout.CENTER, myCanvas3D); add(BorderLayout.SOUTH, bottom); exitButton.addActionListener(this); setVisible(true); }
From source file:Presentation.MainWindow.java
/** Ajout la fentre de la liste de ports COM dtectes par l'ordinateur pour rcuprer les donnes */ public void addCOMPorts(ArrayList<String> Ports) { Panel panel = new Panel(); Label label = new Label("Ports COM"); Choice COMPorts = new Choice(); for (String port : Ports) { COMPorts.add(port);/* ww w . ja va 2 s . c o m*/ } panel.add(label); panel.add(COMPorts); mPanel.add(panel); show(); }
From source file:br.upe.ecomp.dosa.controller.chart.FileBoxplotChartManager.java
private Panel createContents(double[][] values, boolean logarithmicYAxis, int step) { Panel chartPanel = new Panel(); chartPanel.setLayout(new java.awt.GridLayout(1, 1)); JFreeChart chart = createChart("", "Iterations", "Fitness", createSampleDataset(values, step), logarithmicYAxis);/* w w w .j av a 2 s. c om*/ ChartPanel jFreeChartPanel = new ChartPanel(chart); chartPanel.add(jFreeChartPanel); return chartPanel; }
From source file:Sampler.java
private void createUI() { setFont(new Font("Serif", Font.PLAIN, 12)); setLayout(new BorderLayout()); // Set our location to the left of the image frame. setSize(200, 350);// ww w.j a v a 2 s .c o m Point pt = mImageFrame.getLocation(); setLocation(pt.x - getSize().width, pt.y); final Checkbox accumulateCheckbox = new Checkbox("Accumulate", false); final Label statusLabel = new Label(""); // Make a sorted list of the operators. Enumeration e = mOps.keys(); Vector names = new Vector(); while (e.hasMoreElements()) names.addElement(e.nextElement()); Collections.sort(names); final java.awt.List list = new java.awt.List(); for (int i = 0; i < names.size(); i++) list.add((String) names.elementAt(i)); add(list, BorderLayout.CENTER); // When an item is selected, do the corresponding transformation. list.addItemListener(new ItemListener() { public void itemStateChanged(ItemEvent ie) { if (ie.getStateChange() != ItemEvent.SELECTED) return; String key = list.getSelectedItem(); BufferedImageOp op = (BufferedImageOp) mOps.get(key); BufferedImage source = mSplitImageComponent.getSecondImage(); boolean accumulate = accumulateCheckbox.getState(); if (source == null || accumulate == false) source = mSplitImageComponent.getImage(); String previous = mImageFrame.getTitle() + " + "; if (accumulate == false) previous = ""; mImageFrame.setTitle(previous + key); statusLabel.setText("Performing " + key + "..."); list.setEnabled(false); accumulateCheckbox.setEnabled(false); BufferedImage destination = op.filter(source, null); mSplitImageComponent.setSecondImage(destination); mSplitImageComponent.setSize(mSplitImageComponent.getPreferredSize()); mImageFrame.setSize(mImageFrame.getPreferredSize()); list.setEnabled(true); accumulateCheckbox.setEnabled(true); statusLabel.setText("Performing " + key + "...done."); } }); Button loadButton = new Button("Load..."); loadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ae) { FileDialog fd = new FileDialog(Sampler.this); fd.show(); if (fd.getFile() == null) return; String path = fd.getDirectory() + fd.getFile(); mSplitImageComponent.setImage(path); mSplitImageComponent.setSecondImage(null); // Utilities.sizeContainerToComponent(mImageFrame, // mSplitImageComponent); mImageFrame.validate(); mImageFrame.repaint(); } }); Panel bottom = new Panel(new GridLayout(2, 1)); Panel topBottom = new Panel(); topBottom.add(accumulateCheckbox); topBottom.add(loadButton); bottom.add(topBottom); bottom.add(statusLabel); add(bottom, BorderLayout.SOUTH); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { mImageFrame.dispose(); dispose(); System.exit(0); } }); }