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:gui.SignUpGUI.java

public SignUpGUI() {
    super("Sign Up");
    setResizable(false);/*w  w  w  .  j  av a  2 s .c  o  m*/
    setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
    setSize(500, 250);
    JPanel panelServer = new JPanel();
    addComponentToPanel(panelServer, labelServer, textFieldServer);
    add(panelServer);
    JPanel panelPort = new JPanel();
    addComponentToPanel(panelPort, labelPort, textFieldPort);
    add(panelPort);
    JPanel panelID = new JPanel();
    addComponentToPanel(panelID, labelID, textFieldID);
    add(panelID);
    JPanel panelPassword = new JPanel();
    pwdFieldPwd.setEchoChar('*');
    pwdFieldConfirmPwd.setEchoChar('*');
    addComponentToPanel(panelPassword, labelPassword, pwdFieldPwd);
    add(panelPassword);
    JPanel panelConfirmPwd = new JPanel();
    addComponentToPanel(panelConfirmPwd, labelConfirmPwd, pwdFieldConfirmPwd);
    add(panelConfirmPwd);
    JPanel panelNickname = new JPanel();
    addComponentToPanel(panelNickname, labelNickname, textFieldNickname);
    add(panelNickname);
    JPanel panelButton = new JPanel();
    panelButton.setLayout(new FlowLayout());
    buttonSignUp.addActionListener(new SignUpActionListener());
    panelButton.add(buttonSignUp);
    add(panelButton);
    setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    setVisible(true);
}

From source file:DataBufferGrabber.java

private static void createAndShowGUI() {
    JFrame f = new JFrame("DataBufferGrabber");
    f.getContentPane().setLayout(new FlowLayout());
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setSize(100, 100);// www. ja  v a  2s. co m
    f.add(new DataBufferGrabber());
    f.validate();
    f.pack();
    f.setVisible(true);
}

From source file:com.przemo.probabilities.gui.SimulatorPanel.java

private void addMainChart() {
    JFreeChart chart = ChartFactory.createBarChart("Account balance simulation", "Iteration", "Balance", null);
    chart.getCategoryPlot().getDomainAxis().setVisible(false);
    p = new ChartPanel(chart);
    p.setPreferredSize(new Dimension(mainChartPanel.getWidth() - 2, mainChartPanel.getHeight() - 20));
    chart.getCategoryPlot().setBackgroundPaint(Color.WHITE);
    mainChartPanel.setLayout(new FlowLayout());
    mainChartPanel.add(p);/*  w w  w .  j a  v  a  2s . c o m*/
    //mainChartPanel.validate();
}

From source file:AnotherMenuDemo.java

AnotherMenuDemo(String s) {
    super("MenuDemo: " + s);

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

    mb = new MenuBar();
    setMenuBar(mb); // Frame implements MenuContainer

    MenuItem mi;//from  w  ww  .j a  v  a 2  s.co m
    // The File Menu...
    fm = new Menu("File");
    fm.add(mi = new MenuItem("Open", new MenuShortcut('O')));
    mi.addActionListener(this);
    fm.add(mi = new MenuItem("Close", new MenuShortcut('W')));
    mi.addActionListener(this);
    fm.addSeparator();
    fm.add(mi = new MenuItem("Print", new MenuShortcut('P')));
    mi.addActionListener(this);
    fm.addSeparator();
    fm.add(mi = new MenuItem("Exit", new MenuShortcut('Q')));
    exitItem = mi; // save for action handler
    mi.addActionListener(this);
    mb.add(fm);

    // The Options Menu...
    om = new Menu("Options");
    cb = new CheckboxMenuItem("AutoSave");
    cb.setState(true);
    cb.addItemListener(this);
    om.add(cb);
    opSubm = new Menu("SubOptions");
    opSubm.add(new MenuItem("Alpha"));
    opSubm.add(new MenuItem("Gamma"));
    opSubm.add(new MenuItem("Delta"));
    om.add(opSubm);
    mb.add(om);

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

    // the main window
    cp.add(new Label("Menu Demo Window", 200, 150));
    pack();
}

From source file:org.pmedv.core.dialogs.AbstractDialog.java

private JPanel createButtonBar(boolean showNewButton, boolean showOkButton, boolean showCancelButton) {

    buttonPanel = new JPanel(new FlowLayout());

    if (showNewButton) {
        newButton = new JButton("New");
        newButton.setIcon(newIcon);/*from   w w w  .j a  va2  s  . co  m*/
        buttonPanel.add(newButton);
    }
    if (showOkButton) {
        okButton = new JButton("Ok");
        okButton.setIcon(okIcon);
        buttonPanel.add(okButton);
    }
    if (showCancelButton) {
        cancelButton = new JButton("Cancel");
        cancelButton.setIcon(cancelIcon);
        buttonPanel.add(cancelButton);
    }

    return buttonPanel;
}

From source file:com.github.woonsan.commons.scxml.examples.stopwatch.StopWatchFrame.java

private void initUI() {
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout());
    setContentPane(mainPanel);//w w w.  j a va2s.c o  m

    JPanel contentPanel = new JPanel();
    contentPanel.setLayout(new FlowLayout());
    displayLabel = new JLabel("0:00:00,000");
    contentPanel.add(displayLabel, BorderLayout.CENTER);

    mainPanel.add(contentPanel, BorderLayout.CENTER);

    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout());

    startButton = createButton("START", "Start");
    buttonPanel.add(startButton);

    stopButton = createButton("STOP", "Stop");
    stopButton.setEnabled(false);
    buttonPanel.add(stopButton);

    resetButton = createButton("RESET", "Reset");
    resetButton.setEnabled(false);
    buttonPanel.add(resetButton);

    mainPanel.add(buttonPanel, BorderLayout.SOUTH);

    pack();

    setLocation(200, 200);
    setSize(260, 80);

    setResizable(true);
    setVisible(true);

    setDefaultCloseOperation(EXIT_ON_CLOSE);

    Timer displayTimer = new Timer();
    displayTimer.scheduleAtFixedRate(new TimerTask() {
        @Override
        public void run() {
            displayLabel.setText(stopWatch.getDisplay());
        }
    }, 100, 100);
}

From source file:net.sf.taverna.t2.activities.wsdl.views.WSDLActivityContextualView.java

/**
 * Gets the component from the {@link HTMLBasedActivityContextualView} and adds buttons to it
 * allowing XML splitters to be added//from   w  ww .  j a  va  2s.  c  om
 */
@Override
public JComponent getMainFrame() {
    final JComponent mainFrame = super.getMainFrame();
    JPanel flowPanel = new JPanel(new FlowLayout());

    addInputSplitter(mainFrame, flowPanel);
    addOutputSplitter(mainFrame, flowPanel);

    mainFrame.add(flowPanel, BorderLayout.SOUTH);
    return mainFrame;
}

From source file:gtu._work.etc.SqlReplacerUI.java

private void initGUI() {
    try {//from  ww w .  ja  va  2 s  .co m
        BorderLayout thisLayout = new BorderLayout();
        setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
        getContentPane().setLayout(thisLayout);
        {
            jTabbedPane1 = new JTabbedPane();
            getContentPane().add(jTabbedPane1, BorderLayout.CENTER);
            {
                jPanel1 = new JPanel();
                BorderLayout jPanel1Layout = new BorderLayout();
                jPanel1.setLayout(jPanel1Layout);
                jTabbedPane1.addTab("jPanel1", null, jPanel1, null);
                {
                    jScrollPane1 = new JScrollPane();
                    jPanel1.add(jScrollPane1, BorderLayout.CENTER);
                    jScrollPane1.setPreferredSize(new java.awt.Dimension(387, 246));
                    {
                        jTextArea1 = new JTextArea();
                        jScrollPane1.setViewportView(jTextArea1);
                        jTextArea1.setText("");
                    }
                }
            }
            {
                jPanel2 = new JPanel();
                FlowLayout jPanel2Layout = new FlowLayout();
                jPanel2.setLayout(jPanel2Layout);
                jTabbedPane1.addTab("jPanel2", null, jPanel2, null);
                {
                    replaceFromText = new JTextField();
                    jPanel2.add(replaceFromText);
                    replaceFromText.setPreferredSize(new java.awt.Dimension(266, 22));
                }
                {
                    replaceToText = new JTextField();
                    jPanel2.add(replaceToText);
                    replaceToText.setPreferredSize(new java.awt.Dimension(266, 22));
                }
                {
                    execute = new JButton();
                    jPanel2.add(execute);
                    execute.setText("execute");
                    execute.setPreferredSize(new java.awt.Dimension(149, 42));
                    execute.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent evt) {
                            try {
                                String text = jTextArea1.getText();
                                if (StringUtils.isBlank(text)) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("area empty!");
                                    return;
                                }

                                String fromTxt = replaceFromText.getText();
                                String toTxt = StringUtils.defaultString(replaceToText.getText());
                                if (StringUtils.isBlank(fromTxt)) {
                                    JCommonUtil._jOptionPane_showMessageDialog_error("fromTxt empty!");
                                    return;
                                }

                                StringBuffer sb = new StringBuffer();
                                Pattern ptn = Pattern.compile("(.){0,1}" + fromTxt + "(.){0,1}",
                                        Pattern.CASE_INSENSITIVE);
                                Matcher mth = null;

                                String[] scopeStrs = { ",", " ", "(", ")", "[", "]" };
                                BufferedReader reader = new BufferedReader(new StringReader(text));

                                for (String line = null; (line = reader.readLine()) != null;) {
                                    mth = ptn.matcher(line);
                                    while (mth.find()) {
                                        String scope1 = mth.group(1);
                                        String scope2 = mth.group(2);
                                        boolean ok1 = scope1.length() == 0
                                                || StringUtils.indexOfAny(scope1, scopeStrs) != -1;
                                        boolean ok2 = scope2.length() == 0
                                                || StringUtils.indexOfAny(scope2, scopeStrs) != -1;
                                        if (ok1 && ok2) {
                                            mth.appendReplacement(sb, scope1 + toTxt + scope2);
                                        }
                                    }
                                    mth.appendTail(sb);
                                    sb.append("\n");
                                }

                                reader.close();
                                jTextArea1.setText(sb.toString());
                            } catch (Exception e) {
                                JCommonUtil.handleException(e);
                            }
                        }

                    });
                }
            }
        }
        pack();
        setSize(400, 300);
    } catch (Exception e) {
        //add your error handling code here
        e.printStackTrace();
    }
}

From source file:org.csml.tommo.sugar.modules.heatmap.InteractiveHeatmapDialog.java

protected JPanel createButtonsPanel() {
    JPanel bottomPanel = new JPanel(new FlowLayout());
    prevButton = new JButton("Previous");
    prevButton.addActionListener(this);
    nextButton = new JButton("Next");
    nextButton.addActionListener(this);
    animationButton = new JButton("Start Animation");
    animationButton.addActionListener(this);
    bottomPanel.add(prevButton);/*w  w w  .ja  v a 2  s.co  m*/
    bottomPanel.add(animationButton);
    bottomPanel.add(nextButton);
    return bottomPanel;
}

From source file:piilSource.BarChart.java

public BarChart(final String title, List<List<String>> list, Character meta) {

    super(title);
    geneName = title;/*from ww w  .j  av  a 2  s.  c o  m*/
    metaLabel = (meta.equals('M')) ? "beta" : "expression";
    final CategoryDataset dataset = createDataset(list, metaLabel);
    final JFreeChart chart = createChart(title, dataset, metaLabel);
    final ChartPanel chartPanel = new ChartPanel(chart);
    chartPanel.setPreferredSize(new Dimension(600, 300));
    setContentPane(chartPanel);

    exportButton = new JButton("Export to image");
    exportButton.setPreferredSize(new Dimension(150, 30));
    closeButton = new JButton("Close");
    closeButton.setPreferredSize(new Dimension(150, 30));
    buttonsPanel = new JPanel();
    buttonsPanel.setLayout(new FlowLayout());
    buttonsPanel.setBackground(Color.WHITE);
    buttonsPanel.add(exportButton);
    buttonsPanel.add(closeButton);

    exportButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent bc) {
            ExportDialog export = new ExportDialog();
            export.showExportDialog(chartFrame, "Export view as ...", chartPanel,
                    "Barplot of the " + metaLabel + " values for all samples - " + title);
        }
    });
    closeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            chartFrame.dispose();
        }
    });

    chartFrame = new JFrame();
    chartFrame.setLayout(new BorderLayout());
    chartFrame.setSize(400, 100);
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension dim = tk.getScreenSize();
    int xPos = (dim.width / 2) - (chartFrame.getWidth() / 2);
    int yPos = (dim.height / 2) - (chartFrame.getHeight() / 2);
    chartFrame.setLocation(xPos, yPos);
    chartFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    chartFrame.add(chartPanel, BorderLayout.CENTER);
    chartFrame.add(buttonsPanel, BorderLayout.SOUTH);

    chartFrame.setSize(800, 400);
    chartFrame.setVisible(true);

}