List of usage examples for java.awt FlowLayout FlowLayout
public FlowLayout()
From source file:BeanContainer.java
public BeanContainer() { super("Simple Bean Container"); getContentPane().setLayout(new FlowLayout()); // w ww . j a v a2s . c o m setSize(300, 300); JPopupMenu.setDefaultLightWeightPopupEnabled(false); JMenuBar menuBar = createMenuBar(); setJMenuBar(menuBar); WindowListener wndCloser = new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }; addWindowListener(wndCloser); setVisible(true); }
From source file:PopUpColorMenu.java
public PopUpColorMenu() { JFrame frame = new JFrame(); final JPopupMenu colorMenu = new JPopupMenu("Color"); colorMenu.add(makeMenuItem("Red")); colorMenu.add(makeMenuItem("Green")); colorMenu.add(makeMenuItem("Blue")); MouseListener mouseListener = new MouseAdapter() { public void mousePressed(MouseEvent e) { checkPopup(e);//ww w .j a v a2 s . c o m } public void mouseClicked(MouseEvent e) { checkPopup(e); } public void mouseReleased(MouseEvent e) { checkPopup(e); } private void checkPopup(MouseEvent e) { if (e.isPopupTrigger()) { selectedComponent = e.getComponent(); colorMenu.show(e.getComponent(), e.getX(), e.getY()); } } }; frame.setLayout(new FlowLayout()); JButton button = new JButton("Uno"); button.addMouseListener(mouseListener); frame.add(button); button = new JButton("Due"); button.addMouseListener(mouseListener); frame.add(button); button = new JButton("Tre"); button.addMouseListener(mouseListener); frame.add(button); frame.getContentPane().addMouseListener(mouseListener); frame.setSize(200, 50); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:PersistentFrameTest.java
public void init() { frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setTitle("PersistentFrameTest"); frame.setSize(400, 200);/* w ww. ja v a 2 s.c o m*/ JButton loadButton = new JButton("Load"); frame.add(loadButton); loadButton.addActionListener(EventHandler.create(ActionListener.class, this, "load")); JButton saveButton = new JButton("Save"); frame.add(saveButton); saveButton.addActionListener(EventHandler.create(ActionListener.class, this, "save")); frame.setVisible(true); }
From source file:com.oracle.cch.swingtest.ChartJFrame.java
/** * Creates new form ChartJFrame//from w w w . j a va 2 s . com */ public ChartJFrame() { initComponents(); XYSeries Goals = new XYSeries("Goals Scored"); Goals.add(1, 1.0); Goals.add(2, 3.0); Goals.add(3, 2.0); Goals.add(4, 0.0); Goals.add(5, 3.0); XYDataset xyDataset = new XYSeriesCollection(Goals); chart = ChartFactory.createXYLineChart("Goals Scored Over Time", "Fixture Number", "Goals", xyDataset, PlotOrientation.VERTICAL, true, true, false); ChartPanel cp = new ChartPanel(chart) { @Override public Dimension getPreferredSize() { return new Dimension(320, 240); } }; FlowLayout fl = new FlowLayout(); this.setLayout(fl); this.add(cp); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); }
From source file:SimpleMenus.java
public void init() { for (int i = 0; i < items.length; i++) { items[i].addActionListener(al);//from ww w . j av a2 s .c o m menus[i % 3].add(items[i]); } JMenuBar mb = new JMenuBar(); for (int i = 0; i < menus.length; i++) mb.add(menus[i]); setJMenuBar(mb); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(t); }
From source file:StereoGirl.java
public void init() { setLayout(new FlowLayout()); GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration(); String v = getParameter("url"); if (v != null) { URLString = v;/*from w w w . j av a 2 s .com*/ } c1.setSize(140, 140); c1.setMonoscopicViewPolicy(View.LEFT_EYE_VIEW); add(c1); c2.setSize(140, 140); c2.setMonoscopicViewPolicy(View.RIGHT_EYE_VIEW); add(c2); // Create a simple scene and attach it to the virtual universe scene = createSceneGraph(0); u = new SimpleUniverse(c1); View view0 = u.getViewer().getView(); View view = new View(); PhysicalBody myBod = view0.getPhysicalBody(); myBod.setLeftEyePosition(new Point3d(-.006, 0.0, 0.0)); // default // is(-0.033, // 0.0, 0.0) myBod.setRightEyePosition(new Point3d(+.006, 0.0, 0.0)); view.setPhysicalBody(myBod); view.setPhysicalEnvironment(view0.getPhysicalEnvironment()); view.attachViewPlatform(u.getViewingPlatform().getViewPlatform()); view.addCanvas3D(c2); // This will move the ViewPlatform back a bit so the // objects in the scene can be viewed. u.getViewingPlatform().setNominalViewingTransform(); u.addBranchGraph(scene); }
From source file:SimpleDraw.java
public SimpleDraw() { this.setTitle("Simple DRAW"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // add check box group ButtonGroup cbg = new ButtonGroup(); JRadioButton lineButton = new JRadioButton("Line"); JRadioButton ovalButton = new JRadioButton("Oval"); JRadioButton rectangleButton = new JRadioButton("Rectangle"); cbg.add(lineButton);/* ww w . j a va 2 s. c o m*/ cbg.add(ovalButton); cbg.add(rectangleButton); lineButton.addActionListener(this); ovalButton.addActionListener(this); rectangleButton.addActionListener(this); rectangleButton.setSelected(true); JPanel radioPanel = new JPanel(new FlowLayout()); radioPanel.add(lineButton); radioPanel.add(ovalButton); radioPanel.add(rectangleButton); this.addMouseListener(this); this.setLayout(new BorderLayout()); this.add(radioPanel, BorderLayout.NORTH); }
From source file:ExecDemoNS.java
/** Constructor - set up strings and things. */ public ExecDemoNS(String prog) { super("ExecDemo: " + prog); String osname = System.getProperty("os.name"); if (osname == null) throw new IllegalArgumentException("no os.name"); if (prog.equals("netscape")) program = // Windows or UNIX only for now, sorry Mac fans (osname.toLowerCase().indexOf("windows") != -1) ? "c:/program files/netscape/communicator/program/netscape.exe" : "/usr/local/netscape/netscape"; else/*www . j ava2s .c o m*/ program = prog; Container cp = getContentPane(); cp.setLayout(new FlowLayout()); JButton b; cp.add(b = new JButton("Exec")); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { runProg(); } }); cp.add(b = new JButton("Wait")); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { doWait(); } }); cp.add(b = new JButton("Exit")); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { System.exit(0); } }); pack(); }
From source file:ComboBoxes.java
public void init() { for (int i = 0; i < 4; i++) c.addItem(description[count++]); t.setEditable(false);//from w ww . j av a 2s. c o m b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (count < description.length) c.addItem(description[count++]); } }); c.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { t.setText("index: " + c.getSelectedIndex() + " " + ((JComboBox) e.getSource()).getSelectedItem()); } }); Container cp = getContentPane(); cp.setLayout(new FlowLayout()); cp.add(t); cp.add(c); cp.add(b); }
From source file:JTextFieldFilter.java
public Main() { JTextField tf1, tf1b, tf1c, tf2, tf3; JLabel l1, l1b, l1c, l2, l3;/* w w w.j ava 2s . c o m*/ setLayout(new FlowLayout()); // l1 = new JLabel("only numerics"); tf1 = new JTextField(10); getContentPane().add(l1); getContentPane().add(tf1); tf1.setDocument(new JTextFieldFilter(JTextFieldFilter.NUMERIC)); setSize(300, 300); setVisible(true); }