Example usage for java.awt FlowLayout FlowLayout

List of usage examples for java.awt FlowLayout FlowLayout

Introduction

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

Prototype

public FlowLayout() 

Source Link

Document

Constructs a new FlowLayout with a centered alignment and a default 5-unit horizontal and vertical gap.

Usage

From source file:MonthPanel.java

protected JPanel createTitleGUI() {
    JPanel titlePanel = new JPanel(true);
    titlePanel.setLayout(new FlowLayout());
    titlePanel.setBackground(Color.WHITE);

    JLabel label = new JLabel(monthNames[month] + " " + year);
    label.setForeground(SystemColor.activeCaption);
    titlePanel.add(label, BorderLayout.CENTER);
    return titlePanel;
}

From source file:FramewithComponents.java

public FramewithComponents() {
    super("JLayeredPane Demo");
    setSize(256, 256);/*from  www .jav a2s .  c  o  m*/

    JPanel content = new JPanel();
    content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS));
    content.setOpaque(false);

    JLabel label1 = new JLabel("Username:");
    label1.setForeground(Color.white);
    content.add(label1);

    JTextField field = new JTextField(15);
    content.add(field);

    JLabel label2 = new JLabel("Password:");
    label2.setForeground(Color.white);
    content.add(label2);

    JPasswordField fieldPass = new JPasswordField(15);
    content.add(fieldPass);

    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(content);
    ((JPanel) getContentPane()).setOpaque(false);

    ImageIcon earth = new ImageIcon("largeJava2sLogo.png");
    JLabel backlabel = new JLabel(earth);
    getLayeredPane().add(backlabel, new Integer(Integer.MIN_VALUE));
    backlabel.setBounds(0, 0, earth.getIconWidth(), earth.getIconHeight());

    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);

    setVisible(true);
}

From source file:StereoCube.java

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

    c1.setSize(180, 180);//from   w  w  w. ja v a 2  s.c o  m
    c1.setMonoscopicViewPolicy(View.LEFT_EYE_VIEW);
    add(c1);

    c2.setSize(180, 180);
    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:Faces.java

public void init() {
    faces = new Icon[] { new ImageIcon(getClass().getResource("Face0.gif")),
            new ImageIcon(getClass().getResource("Face1.gif")),
            new ImageIcon(getClass().getResource("Face2.gif")),
            new ImageIcon(getClass().getResource("Face3.gif")),
            new ImageIcon(getClass().getResource("Face4.gif")), };
    jb = new JButton("JButton", faces[3]);
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    jb.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (mad) {
                jb.setIcon(faces[3]);// w  ww .j a  v a  2 s  . c o  m
                mad = false;
            } else {
                jb.setIcon(faces[0]);
                mad = true;
            }
            jb.setVerticalAlignment(JButton.TOP);
            jb.setHorizontalAlignment(JButton.LEFT);
        }
    });
    jb.setRolloverEnabled(true);
    jb.setRolloverIcon(faces[1]);
    jb.setPressedIcon(faces[2]);
    jb.setDisabledIcon(faces[4]);
    jb.setToolTipText("Yow!");
    cp.add(jb);
    jb2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (jb.isEnabled()) {
                jb.setEnabled(false);
                jb2.setText("Enable");
            } else {
                jb.setEnabled(true);
                jb2.setText("Disable");
            }
        }
    });
    cp.add(jb2);
}

From source file:MyViewChooser.java

public MyViewChooser() {
    super("File View Test Frame");
    setSize(350, 200);/*from w  w  w.  j a v  a  2s  . com*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    parent = this;

    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    JButton openButton = new JButton("Open");
    final JLabel statusbar = new JLabel("Output of your selection will go here");

    openButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            JFileChooser chooser = new JFileChooser();

            // Ok, set up our own file view for the chooser
            chooser.setFileView(new ThumbNailFileView(MyViewChooser.this));

            int option = chooser.showOpenDialog(parent);
            if (option == JFileChooser.APPROVE_OPTION) {
                statusbar.setText("You chose " + chooser.getSelectedFile().getName());
            } else {
                statusbar.setText("You cancelled.");
            }
        }
    });

    c.add(openButton);
    c.add(statusbar);
}

From source file:MyApplet.java

private void guiInit() {
    // Set the applet to use flow layout. 
    setLayout(new FlowLayout());

    // Create two buttons and a label. 
    jbtnOne = new JButton("One");
    jbtnTwo = new JButton("Two");

    jlab = new JLabel("Press a button.");

    // Add action listeners for the buttons. 
    jbtnOne.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent le) {
            jlab.setText("Button One pressed.");
        }//  w ww . java  2  s.c  o  m
    });

    jbtnTwo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent le) {
            jlab.setText("Button Two pressed.");
        }
    });

    // Add the components to the applet's content pane. 
    getContentPane().add(jbtnOne);
    getContentPane().add(jbtnTwo);
    getContentPane().add(jlab);
}

From source file:AccessoryFileChooser.java

public AccessoryFileChooser() {
    super("Accessory Test Frame");
    setSize(350, 200);/*from   w  ww .j ava  2s  .  c  o  m*/
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    JButton accButton = new JButton("Accessory");
    statusbar = new JLabel("Output of your selection will go here");
    chooser = new JFileChooser();
    AudioAccessory aa = new AudioAccessory();
    chooser.setAccessory(aa);
    chooser.addPropertyChangeListener(aa); // to receive selection changes
    chooser.addActionListener(aa); // to receive approve/cancel button
    // events

    accButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            int option = chooser.showOpenDialog(AccessoryFileChooser.this);
            if (option == JFileChooser.APPROVE_OPTION) {
                statusbar.setText("You chose "
                        + ((chooser.getSelectedFile() != null) ? chooser.getSelectedFile().getName()
                                : "nothing"));
            } else {
                statusbar.setText("You canceled.");
            }
        }
    });
    c.add(accButton);
    c.add(statusbar);
}

From source file:Main.java

public Main() {
    rOne.addActionListener(new ROneAction());
    rTwo.addActionListener(new RTwoAction());
    group = new ButtonGroup();
    group.add(rOne);/*ww w.ja v  a 2 s .  c  o m*/
    group.add(rTwo);

    combo = new JComboBox();
    combo.addItem("No Values");
    combo.addPopupMenuListener(new PopupMenuListener() {
        public void popupMenuCanceled(PopupMenuEvent evt) {
        }

        public void popupMenuWillBecomeInvisible(PopupMenuEvent evt) {
            jComboBox1PopupMenuWillBecomeInvisible(evt);
        }

        public void popupMenuWillBecomeVisible(PopupMenuEvent evt) {
        }
    });

    label = new JLabel("labelLabel");

    this.setLayout(new FlowLayout());
    this.add(rOne);
    this.add(rTwo);
    this.add(combo);
    this.add(label);
    this.pack();
    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

From source file:SwingRadioButtons.java

public void init() {
    rb1.addActionListener(al);//from   w  ww.jav  a2  s  .  com
    rb2.addActionListener(al);
    rb3.addActionListener(al);
    g.add(rb1);
    g.add(rb2);
    g.add(rb3);
    t.setEditable(false);
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(t);
    cp.add(rb1);
    cp.add(rb2);
    cp.add(rb3);
}

From source file:SwingCheckBoxes.java

public void init() {
    cb1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            trace("1", cb1);
        }//from w  w  w.j a  va2  s  . c  om
    });
    cb2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            trace("2", cb2);
        }
    });
    cb3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            trace("3", cb3);
        }
    });
    Container cp = getContentPane();
    cp.setLayout(new FlowLayout());
    cp.add(new JScrollPane(t));
    cp.add(cb1);
    cp.add(cb2);
    cp.add(cb3);
}