Example usage for java.awt FlowLayout CENTER

List of usage examples for java.awt FlowLayout CENTER

Introduction

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

Prototype

int CENTER

To view the source code for java.awt FlowLayout CENTER.

Click Source Link

Document

This value indicates that each row of components should be centered.

Usage

From source file:CardFrame.java

public CardFrame(String title) {
    setLayout(new BorderLayout(10, 10));
    nextCard.addActionListener(this);
    prevCard.addActionListener(this);
    firstCard.addActionListener(this);
    lastCard.addActionListener(this);

    Panel buttonsPanel = new Panel(new FlowLayout(FlowLayout.CENTER));
    buttonsPanel.add(firstCard);/*from   w w w .  j  a  v  a2 s  .  c om*/
    buttonsPanel.add(prevCard);
    buttonsPanel.add(nextCard);
    buttonsPanel.add(lastCard);

    setCardLayout();
    add(BorderLayout.CENTER, cardPanel);
    add(BorderLayout.NORTH, buttonsPanel);
}

From source file:SwingSuspendResume.java

public SwingSuspendResume() {
    symbolTF = new JTextField();
    symbolTF.setEditable(false);//from  w  ww  .  j a v  a2  s.c  o m
    symbolTF.setFont(new Font("Monospaced", Font.BOLD, 26));
    symbolTF.setHorizontalAlignment(JTextField.CENTER);

    final JButton suspendB = new JButton("Suspend");
    final JButton resumeB = new JButton("Resume");

    suspendB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            suspendNow();
        }
    });

    resumeB.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            resumeNow();
        }
    });

    JPanel innerStackP = new JPanel();
    innerStackP.setLayout(new GridLayout(0, 1, 3, 3));
    innerStackP.add(symbolTF);
    innerStackP.add(suspendB);
    innerStackP.add(resumeB);

    this.setLayout(new FlowLayout(FlowLayout.CENTER));
    this.add(innerStackP);
}

From source file:Main.java

public Main() throws HeadlessException {
    setSize(200, 200);//from  www  . j ava2s .  co m
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    JButton button1 = new JButton("Message dialog");
    button1.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            JOptionPane.showMessageDialog((Component) e.getSource(), "Thank you!");
        }
    });

    JButton button2 = new JButton("Input dialog");
    button2.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String text = JOptionPane.showInputDialog((Component) e.getSource(), "What is your name?");
            if (text != null && !text.equals("")) {
                JOptionPane.showMessageDialog((Component) e.getSource(), "Hello " + text);
            }
        }
    });

    JButton button3 = new JButton("Yes no dialog");
    button3.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int result = JOptionPane.showConfirmDialog((Component) e.getSource(), "Close this application?");
            if (result == JOptionPane.YES_OPTION) {
                System.exit(0);
            } else if (result == JOptionPane.NO_OPTION) {
                System.out.println("Do nothing");
            }
        }
    });

    setLayout(new FlowLayout(FlowLayout.CENTER));
    getContentPane().add(button1);
    getContentPane().add(button2);
    getContentPane().add(button3);
}

From source file:utybo.branchingstorytree.swing.visuals.AboutDialog.java

@SuppressWarnings("unchecked")
public AboutDialog(OpenBSTGUI parent) {
    super(parent);
    setTitle(Lang.get("about.title"));
    setModalityType(ModalityType.APPLICATION_MODAL);

    JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER));
    banner.setBackground(OpenBSTGUI.OPENBST_BLUE);
    JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48)));
    lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    banner.add(lblOpenbst, "flowx,cell 0 0,alignx center");
    getContentPane().add(banner, BorderLayout.NORTH);

    JPanel pan = new JPanel();
    pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]"));
    getContentPane().add(pan, BorderLayout.CENTER);

    JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/");
    Font f = lblWebsite.getFont();
    @SuppressWarnings("rawtypes")
    Map attrs = f.getAttributes();
    attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    lblWebsite.setFont(f.deriveFont(attrs));
    lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE);
    lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblWebsite.addMouseListener(new MouseAdapter() {
        @Override//  w ww. j a v  a2  s  . c  o  m
        public void mouseClicked(MouseEvent e) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI());
                } catch (IOException | URISyntaxException e1) {
                    OpenBST.LOG.warn("Exception when trying to open website", e1);
                }
            }
        }
    });
    pan.add(lblWebsite, "cell 0 0,alignx center");

    JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION));
    pan.add(lblVersion, "flowy,cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false));
    pan.add(scrollPane, "cell 0 2,grow");

    JTextArea textArea = new JTextArea();
    textArea.setMargin(new Insets(5, 5, 5, 5));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11)));

    try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) {
        textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8));
    } catch (IOException ex) {
        OpenBST.LOG.warn("Loading about information failed", ex);
    }
    textArea.setEditable(false);
    textArea.setCaretPosition(0);
    scrollPane.setViewportView(textArea);

    JLabel lblTranslatedBy = new JLabel(Lang.get("author"));
    pan.add(lblTranslatedBy, "cell 0 1");

    setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400));
    setLocationRelativeTo(parent);
}

From source file:org.onesun.sdi.swing.app.views.dialogs.ChartDialog.java

public ChartDialog(Frame parent, JFreeChart moodChart, JFreeChart sentimentChart) {
    super(parent, true);

    this.parent = parent;

    this.setLayout(new BorderLayout(5, 5));

    setTitle("Chart");
    setSize(350, 225);// w ww  . j ava 2 s. com
    setResizable(false);
    setVisible(false);

    JPanel chartPanel = new JPanel(new GridLayout(1, 2));

    chartPanel.add(new ChartPanel(moodChart));
    chartPanel.add(new ChartPanel(sentimentChart));

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 15));
    panel.add(okButton);

    this.add(chartPanel, BorderLayout.CENTER);
    this.add(panel, BorderLayout.SOUTH);

    UserActionListener userActionListener = new UserActionListener();
    okButton.addActionListener(userActionListener);
}

From source file:com.emental.mindraider.ui.dialogs.DownloadModelJDialog.java

/**
 * Constructor.//w  w  w .j av  a  2  s.com
 * 
 * @param union
 *            made union of models.
 */
public DownloadModelJDialog(boolean union) {
    super(Messages.getString("DownloadModelJDialog.title"));

    JPanel p = new JPanel();
    p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 5));

    p.add(new JLabel(Messages.getString("DownloadModelJDialog.url")));

    String[] knowUris = new String[] { "http://", "http://wymiwyg.org/", "http://www.osar.ch",
            "http://wymiwyg.org/.rdf?appendLang=en&till=50", "http://www.osar.ch/.rdf?appendLang=de&till=50" };
    modelUrlCombo = new JComboBox(knowUris);
    modelUrlCombo.setEditable(true);
    modelUrlCombo.addKeyListener(new KeyListener() {

        public void keyPressed(KeyEvent keyEvent) {
            if (keyEvent.getKeyCode() == KeyEvent.VK_ENTER) {
                upload();
            }
        }

        public void keyReleased(KeyEvent keyEvent) {
        }

        public void keyTyped(KeyEvent keyEvent) {
        }
    });
    p.add(modelUrlCombo);

    JButton uploadButton = new JButton(Messages.getString("DownloadModelJDialog.download"));
    uploadButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            upload();
        }
    });
    p.add(uploadButton);

    JButton cancelButton = new JButton(Messages.getString("DownloadModelJDialog.cancel"));
    cancelButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });
    p.add(cancelButton);

    getContentPane().add(p, BorderLayout.CENTER);

    // show
    pack();
    Gfx.centerAndShowWindow(this);
}

From source file:de.huxhorn.lilith.swing.LicenseAgreementDialog.java

private void initUI() {
    JPanel content = new JPanel();
    content.setLayout(new BorderLayout());
    JPanel buttonPanel = new JPanel();
    buttonPanel.setLayout(new FlowLayout(FlowLayout.CENTER));

    JTextPane licenseTextPane = new JTextPane();
    HTMLEditorKit htmlEditorKit = new HTMLEditorKit();

    String licenseText = null;/*w w  w  . ja  va 2 s . c  o  m*/
    InputStream licenseStream = LicenseAgreementDialog.class.getResourceAsStream("/licenses/license.html");
    if (licenseStream != null) {
        try {
            licenseText = IOUtils.toString(licenseStream, StandardCharsets.UTF_8);
        } catch (IOException ex) {
            if (logger.isErrorEnabled())
                logger.error("Exception while loading license!", ex);
            IOUtilities.interruptIfNecessary(ex);
        } finally {
            IOUtilities.closeQuietly(licenseStream);
        }
    }
    if (licenseText == null) {
        if (logger.isErrorEnabled())
            logger.error("Couldn't find license text! Exiting!");
        System.exit(-1);
    }

    licenseTextPane.setEditorKit(htmlEditorKit);
    licenseTextPane.setEditable(false);
    licenseTextPane.setText(licenseText);
    JScrollPane licenseScrollPane = new JScrollPane(licenseTextPane);
    licenseScrollPane.setPreferredSize(new Dimension(640, 480));

    content.add(licenseScrollPane, BorderLayout.CENTER);
    content.add(buttonPanel, BorderLayout.SOUTH);

    AcceptAction acceptAction = new AcceptAction();
    DeclineAction declineAction = new DeclineAction();

    JButton acceptButton = new JButton(acceptAction);
    JButton declineButton = new JButton(declineAction);

    buttonPanel.add(acceptButton);
    buttonPanel.add(declineButton);
    setContentPane(content);
    licenseTextPane.setCaretPosition(0);
    declineButton.requestFocusInWindow();
}

From source file:org.kuali.test.ui.components.sqlquerypanel.WhereValueCellEditor.java

public WhereValueCellEditor(DatabasePanel dbPanel, JTextField tf) {
    super(new BorderLayout());
    this.dbPanel = dbPanel;
    cellEditor = new DefaultCellEditor(tf);
    add(cellEditor.getComponent(), BorderLayout.CENTER);

    JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 2));

    p.add(lookup = new SearchButton());
    p.add(new JSeparator(JSeparator.VERTICAL));

    if (dbPanel.isForCheckpoint()) {
        p.add(executionParameter = new SearchButton(Constants.ADD_PARAM_ICON));
        executionParameter.addActionListener(this);
    }/*w w  w. java 2 s  . c  o  m*/

    add(p, BorderLayout.EAST);

    lookup.setEnabled(false);
    lookup.addActionListener(this);
}

From source file:org.kuali.test.ui.base.SimpleInputDlg.java

/**
 *
 *///from  ww  w .j  av  a2  s  . c  o  m
protected void addStandardButtons() {
    JPanel p = new JPanel(new FlowLayout(FlowLayout.CENTER));

    JButton b;
    p.add(b = new JButton(Constants.OK_ACTION));
    b.addActionListener(this);

    p.add(b = new JButton(Constants.CANCEL_ACTION));
    b.addActionListener(this);

    JPanel p2 = new JPanel(new BorderLayout());
    p2.add(new JSeparator(), BorderLayout.NORTH);
    p2.add(p, BorderLayout.CENTER);
    getContentPane().add(p2, BorderLayout.SOUTH);
}

From source file:com.antelink.sourcesquare.gui.view.CopyrightPanel.java

public CopyrightPanel() {
    super();/*from  w  w  w.  j  a  v  a  2  s .  co m*/

    ArrayList<JLabel> sentence = new ArrayList<JLabel>();
    sentence.add(new JLabel("Powered by"));
    sentence.add(createJLabelWithHyperlink("Antepedia", "http://www.antepedia.com"));
    sentence.add(new JLabel(", an "));
    sentence.add(createJLabelWithHyperlink("Antelink", "http://www.antelink.com"));
    sentence.add(new JLabel(" product - "));
    sentence.add(
            createJLabelWithHyperlink("About SourceSquare", "https://sourcesquare.antepedia.com/about.html"));

    setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    for (JLabel jLabel : sentence) {
        jLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 11));
        this.add(jLabel);
    }
    this.setSize(360, 25);
}