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:arduinoserialread.SerialRead.java

private void initGUI() {

    // init the frame
    frame.setTitle("Arduino Serial Read");
    frame.setBounds(100, 100, 600, 500);
    frame.setMinimumSize(new Dimension(600, 500));
    frame.setLocationRelativeTo(null);//  ww  w  . ja v  a2  s.com
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // init control panel
    JPanel ctrlPanel = new JPanel();
    ctrlPanel.setLayout(new FlowLayout());

    // init the serial connection panel
    serialCOM = new SerialConnectionPanel();
    ctrlPanel.add(serialCOM);
    frame.getContentPane().add(ctrlPanel, BorderLayout.SOUTH);

    // init the connection status
    ConnectionStatus connectionStatus = new ConnectionStatus();
    ctrlPanel.add(connectionStatus);

    // init connect and disconnect button
    connect = new JButton("connect");
    ctrlPanel.add(connect);
    disconnect = new JButton("disconnect");
    ctrlPanel.add(disconnect);

    // init real time chart
    TimeSeries series = new TimeSeries("DATA");
    DateAxis timeAxis = new DateAxis("Time");
    dataset = new TimeSeriesCollection(series);
    NumberAxis rangeAxis = new NumberAxis("Data");
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setAutoRange(true);
    XYPlot plot = new XYPlot(dataset, timeAxis, rangeAxis, new StandardXYItemRenderer());
    plot.setBackgroundPaint(Color.white);
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);
    plot.getRenderer().setSeriesPaint(0, new Color(0, 142, 192));
    ValueAxis domainAxis = plot.getDomainAxis();
    domainAxis.setAutoRange(true);
    domainAxis.setFixedAutoRange(30000.0); // 30 seconds
    // init the JFreeChart
    JFreeChart chart = new JFreeChart("Real-Time Data Chart", plot);
    chart.setBorderPaint(Color.lightGray);
    chart.setBorderVisible(true);
    chart.setBackgroundPaint(Color.white);
    chart.removeLegend();
    // add real time chart to the frame
    ChartPanel chartPanel = new ChartPanel(chart);
    frame.getContentPane().add(chartPanel, BorderLayout.CENTER);

}

From source file:jesse.GA_ANN.DataVis.java

public DataVis() {
    initComponents();/*from  ww  w .  j  av a 2s . c om*/
    JFreeChart jct = createChart();
    this.setLayout(new FlowLayout());
    this.add(new ChartPanel(jct));
    this.setVisible(true);
}

From source file:Main.java

public MyDialog(JFrame frame) {
    super(frame, "Dialog", false);
    JButton but = new JButton("test");
    setLayout(new FlowLayout());

    add(but);/*w w w  .  ja v a 2s  .  c o m*/
    setPreferredSize(new Dimension(200, 200));
}

From source file:IDlookGetStream.java

private void buildGUI() {
    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    accountNumberList = new JList();
    loadAccounts();/*from  w ww  .  j a va 2 s.  c  om*/
    accountNumberList.setVisibleRowCount(2);
    JScrollPane accountNumberListScrollPane = new JScrollPane(accountNumberList);

    //Do Get Account Button
    getAccountButton = new JButton("Get Account");
    getAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                rs.beforeFirst();
                while (rs.next()) {
                    if (rs.getString("acc_id").equals(accountNumberList.getSelectedValue()))
                        break;
                }
                if (!rs.isAfterLast()) {
                    accountIDText.setText(rs.getString("acc_id"));
                    thumbIDText.setText(rs.getString("thumb_id"));
                    Blob blob = rs.getBlob("pic");

                    int b;
                    InputStream bis = rs.getBinaryStream("pic");
                    FileOutputStream f = new FileOutputStream("pic.jpg");
                    while ((b = bis.read()) >= 0) {
                        f.write(b);
                    }
                    f.close();
                    bis.close();

                    icon = new ImageIcon(blob.getBytes(1L, (int) blob.length()));
                    createThumbnail();
                    photographLabel.setIcon(iconThumbnail);
                }
            } catch (Exception selectException) {
                displaySQLErrors(selectException);
            }
        }
    });

    //Do Update Account Button
    updateAccountButton = new JButton("Update Account");
    updateAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                byte[] bytes = new byte[50000];
                FileInputStream fs = new FileInputStream(nailFileText.getText());
                BufferedInputStream bis = new BufferedInputStream(fs);
                bis.read(bytes);

                rs.updateBytes("thumbnail.pic", bytes);
                rs.updateRow();
                bis.close();

                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            } catch (Exception generalE) {
                generalE.printStackTrace();
            }
        }
    });

    //Do insert Account Button
    insertAccountButton = new JButton("Insert Account");
    insertAccountButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                byte[] bytes = new byte[50000];
                FileInputStream fs = new FileInputStream(nailFileText.getText());
                BufferedInputStream bis = new BufferedInputStream(fs);
                bis.read(bytes);

                rs.moveToInsertRow();
                rs.updateInt("thumb_id", Integer.parseInt(thumbIDText.getText()));
                rs.updateInt("acc_id", Integer.parseInt(accountIDText.getText()));
                rs.updateBytes("pic", bytes);
                rs.updateObject("sysobject", null);
                rs.updateTimestamp("ts", new Timestamp(0));
                rs.updateTimestamp("act_ts", new Timestamp(new java.util.Date().getTime()));
                rs.insertRow();
                bis.close();

                accountNumberList.removeAll();
                loadAccounts();
            } catch (SQLException insertException) {
                displaySQLErrors(insertException);
            } catch (Exception generalE) {
                generalE.printStackTrace();
            }
        }
    });

    photographLabel = new JLabel();
    photographLabel.setHorizontalAlignment(JLabel.CENTER);
    photographLabel.setVerticalAlignment(JLabel.CENTER);
    photographLabel.setVerticalTextPosition(JLabel.CENTER);
    photographLabel.setHorizontalTextPosition(JLabel.CENTER);

    JPanel first = new JPanel(new GridLayout(4, 1));
    first.add(accountNumberListScrollPane);
    first.add(getAccountButton);
    first.add(updateAccountButton);
    first.add(insertAccountButton);

    accountIDText = new JTextField(15);
    thumbIDText = new JTextField(15);
    errorText = new JTextArea(5, 15);
    errorText.setEditable(false);

    JPanel second = new JPanel();
    second.setLayout(new GridLayout(2, 1));
    second.add(thumbIDText);
    second.add(accountIDText);

    JPanel third = new JPanel();
    third.add(new JScrollPane(errorText));

    nailFileText = new JTextField(25);

    c.add(first);
    c.add(second);
    c.add(third);
    c.add(nailFileText);
    c.add(photographLabel);

    setSize(500, 500);
    show();
}

From source file:JiltBefore.java

JiltBefore(String s) {
    super("JiltBefore: " + s);

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

    mb = new JMenuBar();
    setJMenuBar(mb);/*from  w  w w  . j a v  a  2  s.co  m*/

    JMenuItem mi;
    // The File Menu...
    fm = new JMenu("File");
    fm.add(mi = new JMenuItem("Open"));
    mi.addActionListener(this);
    fm.add(mi = new JMenuItem("Close"));
    mi.addActionListener(this);
    fm.addSeparator();
    fm.add(mi = new JMenuItem("Print"));
    mi.addActionListener(this);
    fm.addSeparator();
    fm.add(mi = new JMenuItem("Exit"));
    exitItem = mi; // save for action handler
    mi.addActionListener(this);
    mb.add(fm);

    // The Options Menu...
    om = new JMenu("Options");
    fm.add(mi = new JMenuItem("Enable"));
    opSubm = new JMenu("SubOptions");
    opSubm.add(new JMenuItem("Alpha"));
    opSubm.add(new JMenuItem("Gamma"));
    opSubm.add(new JMenuItem("Delta"));
    om.add(opSubm);
    mb.add(om);

    // The Help Menu...
    hm = new JMenu("Help");
    hm.add(mi = new JMenuItem("About"));
    mi.addActionListener(this);
    hm.add(mi = new JMenuItem("Topics"));
    mi.addActionListener(this);
    mb.add(hm);
    // mb.setHelpMenu(hm); // needed for portability (Motif, etc.).

    // the main window
    cp.add(new JLabel("Menu Demo Window"));
    // pack();
    setSize(250, 200);
}

From source file:InternalFrameListenerDemo.java

public InternalFrameListenerDemo() {
    setTitle("Animated InternalFrameListener");
    m_count = m_tencount = 0;//  w ww  .j  ava2s.c  o m

    JPanel innerListenerPanel = new JPanel(new GridLayout(7, 1));
    JPanel listenerPanel = new JPanel(new BorderLayout());
    m_ifEventCanvas = new IFEventCanvas();

    m_lOpened = new JLabel("internalFrameOpened");
    m_lClosing = new JLabel("internalFrameClosing");
    m_lClosed = new JLabel("internalFrameClosed");
    m_lIconified = new JLabel("internalFrameIconified");
    m_lDeiconified = new JLabel("internalFrameDeiconified");
    m_lActivated = new JLabel("internalFrameActivated");
    m_lDeactivated = new JLabel("internalFrameDeactivated");

    innerListenerPanel.add(m_lOpened);
    innerListenerPanel.add(m_lClosing);
    innerListenerPanel.add(m_lClosed);
    innerListenerPanel.add(m_lIconified);
    innerListenerPanel.add(m_lDeiconified);
    innerListenerPanel.add(m_lActivated);
    innerListenerPanel.add(m_lDeactivated);

    listenerPanel.add("Center", m_ifEventCanvas);
    listenerPanel.add("West", innerListenerPanel);
    listenerPanel.setOpaque(true);
    listenerPanel.setBackground(Color.white);

    m_desktop = new JDesktopPane();
    m_desktop.setBorder(new SoftBevelBorder(BevelBorder.LOWERED));
    m_newFrame = new JButton("New Frame");
    m_newFrame.addActionListener(this);
    m_infos = UIManager.getInstalledLookAndFeels();
    String[] LAFNames = new String[m_infos.length];
    for (int i = 0; i < m_infos.length; i++) {
        LAFNames[i] = m_infos[i].getName();
    }
    m_UIBox = new JComboBox(LAFNames);
    m_UIBox.addActionListener(this);
    JPanel topPanel = new JPanel(true);
    topPanel.setLayout(new FlowLayout());
    topPanel.setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED),
            new CompoundBorder(new EmptyBorder(2, 2, 2, 2), new SoftBevelBorder(BevelBorder.RAISED))));
    getContentPane().setLayout(new BorderLayout());
    getContentPane().add("North", topPanel);
    getContentPane().add("Center", m_desktop);
    getContentPane().add("South", listenerPanel);
    ((JPanel) getContentPane()).setBorder(new CompoundBorder(new SoftBevelBorder(BevelBorder.LOWERED),
            new CompoundBorder(new EmptyBorder(1, 1, 1, 1), new SoftBevelBorder(BevelBorder.RAISED))));
    topPanel.add(m_newFrame);
    topPanel.add(new JLabel("Look & Feel:", SwingConstants.RIGHT));
    topPanel.add(m_UIBox);
    setSize(645, 500);
    Dimension dim = getToolkit().getScreenSize();
    setLocation(dim.width / 2 - getWidth() / 2, dim.height / 2 - getHeight() / 2);
    setVisible(true);
    WindowListener l = new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    };
    addWindowListener(l);
    m_eventTimer = new Timer(1000, this);
    m_eventTimer.setRepeats(true);
    m_eventTimer.start();
}

From source file:gtu._work.ui.RetryByPassUI.java

private void initGUI() {
    try {/*from   w w w.j  ava 2 s .c om*/
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                FlowLayout jPanel1Layout = new FlowLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("?", null, jPanel1, null);
                {
                    DefaultComboBoxModel countryComboBoxModel = new DefaultComboBoxModel();
                    for (CountyEnum e : CountyEnum.values()) {
                        countryComboBoxModel.addElement(e.countyLabel);
                    }
                    countryComboBox = new JComboBox();
                    jPanel1.add(countryComboBox);
                    countryComboBox.setModel(countryComboBoxModel);
                }
                {
                    ComboBoxModel passRetryComboBoxModel = new DefaultComboBoxModel(
                            new String[] { "byPass", "reTry", "status" });
                    passRetryComboBox = new JComboBox();
                    jPanel1.add(passRetryComboBox);
                    passRetryComboBox.setModel(passRetryComboBoxModel);
                }
                {
                    sendBtn = new JButton();
                    jPanel1.add(sendBtn);
                    sendBtn.setText("\u9001\u51fa");
                    sendBtn.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            //TODO add your code for sendBtn.actionPerformed
                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    readMessageId();
                                }
                            }).start();
                        }
                    });
                }
            }
            {
                jPanel2 = new JPanel();
                BorderLayout jPanel2Layout = new BorderLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("messageId", null, jPanel2, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel2.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(604, 375));
                    {
                        messageIdArea = new JTextArea();
                        jScrollPane1.setViewportView(messageIdArea);
                    }
                }
            }
            {
                jPanel3 = new JPanel();
                BorderLayout jPanel3Layout = new BorderLayout();
                jPanel3.setLayout(jPanel3Layout);
                jTabbedPane1.addTab("?", null, jPanel3, null);
                {
                    jScrollPane2 = new JScrollPane();
                    jPanel3.add(jScrollPane2, BorderLayout.CENTER);
                    jScrollPane2.setPreferredSize(new java.awt.Dimension(604, 375));
                    {
                        executeLogArea = new JTextArea();
                        jScrollPane2.setViewportView(executeLogArea);
                    }
                }
            }
        }
        pack();
        this.setSize(617, 429);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:jotp.java

public void init() {

    setBackground(Color.white);//  w ww  . java 2 s .  c  o  m
    setLayout(new GridLayout(6, 1));

    Panel panel1 = new Panel();
    add(panel1);
    Font titlefont = new Font("TimesRoman", Font.BOLD, 14);
    panel1.setFont(titlefont);
    panel1.add(new Label(String.valueOf(version) + ": The Java OTP (aka S/Key) calculator!"));
    Panel panel2 = new Panel();
    panel2.setLayout(new FlowLayout());
    add(panel2);
    panel2.add(new Label("Challenge (e.g. \"55 latour1\"):"));
    chaltf = new TextField(24);
    panel2.add(chaltf);

    Panel panel3 = new Panel();
    panel3.setLayout(new FlowLayout());
    add(panel3);
    panel3.add(new Label("Secret Password:"));
    pwtf = new TextField(24);
    pwtf.setEchoCharacter('*');
    panel3.add(pwtf);

    Panel panel4 = new Panel();
    panel4.setLayout(new FlowLayout());
    add(panel4);

    panel4.add(new Button(String.valueOf(md4label)));
    panel4.add(new Button(String.valueOf(md5label)));

    Panel panel6 = new Panel();
    panel6.setLayout(new FlowLayout());
    add(panel6);
    panel6.add(new Label("One-Time Password:", Label.LEFT));
    otptf = new TextField(40);
    panel6.add(otptf);

    Panel panel7 = new Panel();
    add(panel7);
    panel7.add(new Label("jotp by Harry Mantakos, " + "http://www.cs.umd.edu/~harry/jotp"));
}

From source file:org.apache.commons.httpclient.contrib.proxy.PluginProxyTestApplet.java

@Override
public void init() {
    Container content = getContentPane();
    content.setLayout(new BorderLayout());

    // Proxy info table
    grid = getPanel(new GridLayout(2, 3, 2, 2));
    grid.add(getHeaderLabel("URL"));
    grid.add(getHeaderLabel("Proxy Host"));
    grid.add(getHeaderLabel("Proxy Port"));
    grid.add(urlTextField);/*from  w w w  .jav a  2s  .  c  o  m*/
    hostLabel = getLabel("");
    portLabel = getLabel("");
    grid.add(hostLabel);
    grid.add(portLabel);
    grid.validate();
    content.add(grid, BorderLayout.CENTER);

    // Button panel - SOUTH
    JPanel buttonPanel = getPanel(new FlowLayout());
    JButton button = new JButton("Detect Proxy");
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    detectProxy();
                }
            });
        }
    });
    buttonPanel.add(button);
    content.add(buttonPanel, BorderLayout.SOUTH);

    // version panel - NORTH
    JPanel versionPanel = getPanel(new FlowLayout());
    String javaVersion = System.getProperty("java.runtime.version");
    JLabel versionLabel = getLabel("Java Version: " + javaVersion);
    versionPanel.add(versionLabel);
    content.add(versionPanel, BorderLayout.NORTH);
    validate();

    super.setSize(400, 100);
}

From source file:LNFSwitcher.java

/** Construct a program... */
public LNFSwitcher() {
    super();/*from  w  w  w .j  a  v a 2  s.  c  om*/
    theFrame = new JFrame("LNF Switcher");
    theFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    cp = theFrame.getContentPane();
    cp.setLayout(new FlowLayout());

    ButtonGroup bg = new ButtonGroup();

    JRadioButton bJava = new JRadioButton("Java");
    bJava.addActionListener(new LNFSetter("javax.swing.plaf.metal.MetalLookAndFeel", bJava));
    bg.add(bJava);
    cp.add(bJava);

    JRadioButton bMSW = new JRadioButton("MS-Windows");
    bMSW.addActionListener(new LNFSetter("com.sun.java.swing.plaf.windows.WindowsLookAndFeel", bMSW));
    bg.add(bMSW);
    cp.add(bMSW);

    JRadioButton bMotif = new JRadioButton("Motif");
    bMotif.addActionListener(new LNFSetter("com.sun.java.swing.plaf.motif.MotifLookAndFeel", bMotif));
    bg.add(bMotif);
    cp.add(bMotif);

    JRadioButton bMac = new JRadioButton("Sun-MacOS");
    bMac.addActionListener(new LNFSetter("com.sun.java.swing.plaf.mac.MacLookAndFeel", bMac));
    bg.add(bMac);
    cp.add(bMac);

    String defaultLookAndFeel = UIManager.getSystemLookAndFeelClassName();
    // System.out.println(defaultLookAndFeel);
    JRadioButton bDefault = new JRadioButton("Default");
    bDefault.addActionListener(new LNFSetter(defaultLookAndFeel, bDefault));
    bg.add(bDefault);
    cp.add(bDefault);

    (previousButton = bDefault).setSelected(true);

    theFrame.pack();
    theFrame.setVisible(true);
}