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(int align) 

Source Link

Document

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

Usage

From source file:net.sf.keystore_explorer.gui.dialogs.DCheckUpdate.java

private void initComponents() {
    jlCheckUpdate = new JLabel(res.getString("DCheckUpdate.jlCheckUpdate.text"));
    ImageIcon icon = new ImageIcon(getClass().getResource(res.getString("DCheckUpdate.jlCheckUpdate.image")));
    jlCheckUpdate.setIcon(icon);/*from  w  ww .j  av  a  2s .  c  o m*/
    jlCheckUpdate.setHorizontalTextPosition(SwingConstants.LEADING);
    jlCheckUpdate.setIconTextGap(15);

    jpCheckUpdate = new JPanel(new FlowLayout(FlowLayout.CENTER));
    jpCheckUpdate.add(jlCheckUpdate);
    jpCheckUpdate.setBorder(new EmptyBorder(5, 5, 5, 5));

    jpbCheckUpdate = new JProgressBar();
    jpbCheckUpdate.setIndeterminate(true);
    jpbCheckUpdate.setString("DCheckUpdate.jlCheckUpdate.text");

    jpProgress = new JPanel(new FlowLayout(FlowLayout.CENTER));
    jpProgress.add(jpbCheckUpdate);
    jpProgress.setBorder(new EmptyBorder(5, 5, 5, 5));

    jbCancel = new JButton(res.getString("DCheckUpdate.jbCancel.text"));
    jbCancel.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });
    jbCancel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0),
            CANCEL_KEY);
    jbCancel.getActionMap().put(CANCEL_KEY, new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent evt) {
            cancelPressed();
        }
    });

    jpCancel = PlatformUtil.createDialogButtonPanel(jbCancel, false);

    getContentPane().add(jpCheckUpdate, BorderLayout.NORTH);
    getContentPane().add(jpProgress, BorderLayout.CENTER);
    getContentPane().add(jpCancel, BorderLayout.SOUTH);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent evt) {
            if ((checker != null) && (checker.isAlive())) {
                checker.interrupt();
            }
            closeDialog();
        }
    });

    setTitle(res.getString("DCheckUpdate.Title"));
    setResizable(false);

    pack();
}

From source file:com.orthancserver.OrthancConfigurationDialog.java

public OrthancConfigurationDialog() {
    final JPanel contentPanel = new JPanel();
    contentPanel.setBorder(new EmptyBorder(20, 5, 5, 5));
    contentPanel.setLayout(new GridLayout2(0, 2, 20, 5));

    JLabel label = new JLabel("Name:");
    label.setHorizontalAlignment(JLabel.RIGHT);
    contentPanel.add(label);// w  ww  .j  a  va  2 s. com
    contentPanel.add(name_);

    label = new JLabel("URL:");
    label.setHorizontalAlignment(JLabel.RIGHT);
    contentPanel.add(label);
    contentPanel.add(url_);

    label = new JLabel("Username:");
    label.setHorizontalAlignment(JLabel.RIGHT);
    contentPanel.add(label);
    contentPanel.add(username_);

    label = new JLabel("Password:");
    label.setHorizontalAlignment(JLabel.RIGHT);
    contentPanel.add(label);
    contentPanel.add(password_);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(contentPanel, BorderLayout.NORTH);

    JPanel buttonPane = new JPanel();
    buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    getContentPane().add(buttonPane, BorderLayout.SOUTH);
    {
        {
            JButton test = new JButton("Test connection");
            test.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    OrthancConnection orthanc = CreateConnection();
                    try {
                        JSONObject system = (JSONObject) orthanc.ReadJson("system");
                        JOptionPane.showMessageDialog(null,
                                "Successfully connected to this Orthanc server " + "(version: "
                                        + (String) system.get("Version") + ")!",
                                "Success", JOptionPane.INFORMATION_MESSAGE);
                    } catch (IOException e) {
                        JOptionPane.showMessageDialog(null, "Cannot connect to this Orthanc server!", "Error",
                                JOptionPane.ERROR_MESSAGE);
                    }
                }
            });
            buttonPane.add(test);
        }
        {
            JButton okButton = new JButton("Add");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    isSuccess_ = true;
                    setVisible(false);
                }
            });
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent arg) {
                    setVisible(false);
                }
            });
            buttonPane.add(cancelButton);
        }
    }

    setUndecorated(false);
    setSize(500, 500);
    setTitle("Add new server");
    setModal(true);
}

From source file:com.samebug.clients.idea.ui.component.WriteTip.java

public WriteTip(final Actions actions) {
    tipTitle = new TipTitle();
    tipDescription = new DescriptionLabel(SamebugBundle.message("samebug.tip.write.tip.description"));
    tipBody = new TipBody();
    lengthCounter = new LengthCounter();
    sourceTitle = new SourceTitle();
    sourceDescription = new DescriptionLabel(SamebugBundle.message("samebug.tip.write.source.description"));
    sourceLink = new SourceLink();
    errorPanel = new ErrorPanel();
    cancel = new CancelButton();
    submit = new SubmitButton();
    this.actions = actions;

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

    add(new TransparentPanel() {
        {/* w ww . j ava  2s.  c o m*/
            add(tipTitle);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(tipDescription);
        }
    });
    add(new JScrollPane(tipBody));
    add(new TransparentPanel() {
        {
            setLayout(new FlowLayout(FlowLayout.RIGHT));
            add(lengthCounter);
        }
    });
    add(new TransparentPanel() {
        {
            add(sourceTitle);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(sourceDescription);
        }
    });
    add(new TransparentPanel() {
        {
            add(sourceLink);
        }
    });
    add(new TransparentPanel() {
        {
            setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0));
            add(errorPanel);
        }
    });
    add(new TransparentPanel() {
        {
            setLayout(new FlowLayout(FlowLayout.RIGHT, 20, 0));
            add(cancel);
            add(submit);
        }
    });

    PromptSupport.setPrompt(SamebugBundle.message("samebug.tip.write.tip.placeholder"), tipBody);
    PromptSupport.setPrompt(SamebugBundle.message("samebug.tip.write.source.placeholder"), sourceLink);
    updateSubmitButton(true);

    ((AbstractDocument) tipBody.getDocument()).setDocumentFilter(new TipConstraints());
    tipBody.getDocument().addDocumentListener(new TipEditorListener());

    submit.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (submit.isEnabled()) {
                final String tip = tipBody.getText();
                final String rawSourceUrl = sourceLink.getText();
                beginPostTip();
                actions.onClickSubmitTip(tip, rawSourceUrl);
            }
        }
    });
}

From source file:org.apache.shiro.samples.spring.ui.WebStartView.java

public void afterPropertiesSet() throws Exception {
    ClassPathResource resource = new ClassPathResource("logo.png");
    ImageIcon icon = new ImageIcon(resource.getURL());
    JLabel logo = new JLabel(icon);

    valueField = new JTextField(20);
    updateValueLabel();//from  ww w. j  a v a  2 s.  c  o m

    saveButton = new JButton("Save Value");
    saveButton.addActionListener(this);

    refreshButton = new JButton("Refresh Value");
    refreshButton.addActionListener(this);

    JPanel valuePanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    valuePanel.add(valueField);
    valuePanel.add(saveButton);
    valuePanel.add(refreshButton);

    secureMethod1Button = new JButton("Method #1");
    secureMethod1Button.addActionListener(this);

    secureMethod2Button = new JButton("Method #2");
    secureMethod2Button.addActionListener(this);

    secureMethod3Button = new JButton("Method #3");
    secureMethod3Button.addActionListener(this);

    JPanel methodPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    methodPanel.add(secureMethod1Button);
    methodPanel.add(secureMethod2Button);
    methodPanel.add(secureMethod3Button);

    frame = new JFrame("Apache Shiro Sample Application");
    frame.setSize(500, 200);

    Container panel = frame.getContentPane();
    panel.setLayout(new BorderLayout());
    panel.add(logo, BorderLayout.NORTH);
    panel.add(valuePanel, BorderLayout.CENTER);
    panel.add(methodPanel, BorderLayout.SOUTH);

    frame.setVisible(true);
    frame.addWindowListener(new WindowAdapter() {
        public void windowClosing(WindowEvent e) {
            System.exit(0);
        }
    });
}

From source file:edu.harvard.mcz.imagecapture.SpecimenPartAttribEditDialog.java

private void init() {
    setTitle("Edit Part Attribute");
    setBounds(100, 100, 420, 200);/*from w w  w. j a  v  a  2 s  . c om*/
    getContentPane().setLayout(new BorderLayout());
    contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));

    {
        JPanel buttonPane = new JPanel();
        buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
        getContentPane().add(buttonPane, BorderLayout.SOUTH);
        {
            okButton = new JButton("OK");
            okButton.setActionCommand("OK");
            okButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    okButton.grabFocus();
                    if (comboBoxType.getSelectedIndex() > -1) {
                        targetAttribute.setAttributeType(comboBoxType.getSelectedItem().toString());
                    }
                    targetAttribute.setAttributeValue(comboBoxValue.getSelectedItem().toString());

                    targetAttribute.setAttributeUnits(textFieldUnits.getText());
                    targetAttribute.setAttributeRemark(textFieldRemarks.getText());

                    thisDialog.setVisible(false);
                }
            });
            buttonPane.add(okButton);
            getRootPane().setDefaultButton(okButton);
        }
        {
            JButton cancelButton = new JButton("Cancel");
            cancelButton.setActionCommand("Cancel");
            cancelButton.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    thisDialog.setVisible(false);
                }
            });
            buttonPane.add(cancelButton);
        }
    }
    {
        JPanel panel = new JPanel();
        getContentPane().add(panel, BorderLayout.CENTER);
        panel.setLayout(new FormLayout(
                new ColumnSpec[] { FormSpecs.RELATED_GAP_COLSPEC, FormSpecs.DEFAULT_COLSPEC,
                        FormSpecs.RELATED_GAP_COLSPEC, ColumnSpec.decode("default:grow"), },
                new RowSpec[] { FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC,
                        FormSpecs.DEFAULT_ROWSPEC, FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC,
                        FormSpecs.RELATED_GAP_ROWSPEC, FormSpecs.DEFAULT_ROWSPEC, }));
        {
            JLabel lblAttributeType = new JLabel("Attribute Type");
            panel.add(lblAttributeType, "2, 2, right, default");
        }
        {
            comboBoxType = new JComboBox();
            comboBoxType.setModel(
                    new DefaultComboBoxModel(new String[] { "caste", "scientific name", "sex", "life stage" }));
            comboBoxType.addActionListener(new ActionListener() {

                @Override
                public void actionPerformed(ActionEvent e) {
                    String item = comboBoxType.getSelectedItem().toString();
                    if (item != null) {
                        configureComboBoxValue(item);
                    }
                }

            });
            panel.add(comboBoxType, "4, 2, fill, default");
        }
        {
            JLabel lblValue = new JLabel("Value");
            panel.add(lblValue, "2, 4, right, default");
        }
        {
            comboBoxValue = new JComboBox();
            comboBoxValue.setModel(new DefaultComboBoxModel(Caste.getCasteValues()));

            panel.add(comboBoxValue, "4, 4, fill, default");
        }
        {
            JLabel lblUnits = new JLabel("Units");
            panel.add(lblUnits, "2, 6, right, default");
        }
        {
            textFieldUnits = new JTextField();
            panel.add(textFieldUnits, "4, 6, fill, default");
            textFieldUnits.setColumns(10);
        }
        {
            JLabel lblRemarks = new JLabel("Remarks");
            panel.add(lblRemarks, "2, 8, right, default");
        }
        {
            textFieldRemarks = new JTextField();
            panel.add(textFieldRemarks, "4, 8, fill, default");
            textFieldRemarks.setColumns(10);
        }
    }
}

From source file:com.hp.alm.ali.idea.content.settings.SettingsPanel.java

public SettingsPanel(final Project prj, Color bgColor) {
    this.prj = prj;
    this.projectConf = prj.getComponent(AliProjectConfiguration.class);

    previewAndConnection = new JPanel(new GridBagLayout());
    previewAndConnection.setOpaque(false);
    GridBagConstraints c2 = new GridBagConstraints();
    c2.gridx = 0;//ww w . j av  a2 s .c  o m
    c2.gridy = 1;
    c2.gridwidth = 2;
    c2.weighty = 1;
    c2.fill = GridBagConstraints.VERTICAL;
    JPanel filler = new JPanel();
    filler.setOpaque(false);
    previewAndConnection.add(filler, c2);

    passwordPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    passwordPanel.setBackground(bgColor);
    JLabel label = new JLabel("Password");
    label.setFont(label.getFont().deriveFont(Font.BOLD));
    passwordPanel.add(label);
    final JPasswordField password = new JPasswordField(24);
    passwordPanel.add(password);
    JButton connect = new JButton("Login");
    passwordPanel.add(connect);
    final JLabel message = new JLabel();
    passwordPanel.add(message);
    ActionListener connectionAction = new ActionListener() {
        public void actionPerformed(ActionEvent actionEvent) {
            try {
                checkConnection(projectConf.getLocation(), projectConf.getDomain(), projectConf.getProject(),
                        projectConf.getUsername(), password.getText());
            } catch (AuthenticationFailed e) {
                message.setText(e.getMessage());
                return;
            }
            projectConf.ALM_PASSWORD = password.getText();
            projectConf.fireChanged();
        }
    };
    password.addActionListener(connectionAction);
    connect.addActionListener(connectionAction);

    restService = prj.getComponent(RestService.class);
    restService.addServerTypeListener(this);

    location = createTextPane(bgColor);
    domain = createTextPane(bgColor);
    project = createTextPane(bgColor);
    username = createTextPane(bgColor);

    final JPanel panel = new JPanel(new BorderLayout());
    panel.setBackground(bgColor);
    panel.setBorder(new EmptyBorder(10, 10, 10, 10));

    final JTextPane textPane = new JTextPane();
    textPane.setEditorKit(new HTMLEditorKit());
    textPane.setText(
            "<html><body>HP ALM integration can be configured on <a href=\"ide\">IDE</a> and overridden on <a href=\"project\">project</a> level.</body></html>");
    textPane.setEditable(false);
    textPane.addHyperlinkListener(this);
    textPane.setBackground(bgColor);
    textPane.setCaret(new NonAdjustingCaret());
    panel.add(textPane, BorderLayout.CENTER);

    JPanel content = new JPanel(new BorderLayout());
    content.setBackground(bgColor);
    content.add(panel, BorderLayout.NORTH);
    content.add(previewAndConnection, BorderLayout.WEST);

    preview = new JPanel(new GridBagLayout()) {
        public Dimension getPreferredSize() {
            Dimension dim = super.getPreferredSize();
            // make enough room for the connection status message
            dim.width = Math.max(dim.width, 300);
            return dim;
        }

        public Dimension getMinimumSize() {
            return getPreferredSize();
        }
    };
    connectedTo(restService.getServerTypeIfAvailable());
    preview.setBackground(bgColor);

    final GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 2;
    c.anchor = GridBagConstraints.WEST;
    preview.add(location, c);
    c.gridwidth = 1;
    c.gridy++;
    preview.add(domain, c);
    c.gridy++;
    preview.add(project, c);
    c.gridy++;
    preview.add(username, c);
    c.gridx++;
    c.gridy--;
    c.gridheight = 2;
    c.weightx = 0;
    c.anchor = GridBagConstraints.SOUTHEAST;
    final LinkLabel reload = new LinkLabel("Reload", IconLoader.getIcon("/actions/sync.png"));
    reload.setListener(new LinkListener() {
        public void linkSelected(LinkLabel linkLabel, Object o) {
            projectConf.fireChanged();
        }
    }, null);
    preview.add(reload, c);

    JPanel previewNorth = new JPanel(new BorderLayout());
    previewNorth.setBackground(bgColor);
    previewNorth.add(preview, BorderLayout.NORTH);

    addToGridBagPanel(0, 0, previewAndConnection, previewNorth);

    setBackground(bgColor);
    setLayout(new BorderLayout());
    add(content, BorderLayout.CENTER);

    onChanged();
    ApplicationManager.getApplication().getComponent(AliConfiguration.class).addListener(this);
    projectConf.addListener(this);
}

From source file:eu.delving.sip.actions.ImportAction.java

private void prepareDialog() {
    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(new ActionListener() {
        @Override//from  www  . j a  v  a 2s  . c o  m
        public void actionPerformed(ActionEvent actionEvent) {
            dialog.setVisible(false);
        }
    });
    JPanel bp = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    bp.add(cancel);
    JPanel p = new JPanel(new GridLayout(1, 0, 15, 15));
    p.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
    p.add(new JButton(chooseFileAction));
    p.add(new JButton(harvestAction));
    dialog.getContentPane().add(p, BorderLayout.CENTER);
    dialog.getContentPane().add(bp, BorderLayout.SOUTH);
    dialog.pack();
}

From source file:ErroresPorTraza.TabbedForm.java

private void setChartAceptadosRechazados() {
    AceptadosRechazadosPie aceptrech = new AceptadosRechazadosPie();
    ChartPanel chartpanel1 = aceptrech.getChartPanel("Estado de Trazas", jTable2, suma);
    jPanelAceptRech.removeAll();//  w ww  .ja  va  2  s . c  o  m
    jPanelAceptRech.setLayout(new FlowLayout(FlowLayout.LEFT));
    jPanelAceptRech.add(chartpanel1);
    this.setLocationRelativeTo(null);
}

From source file:com.employee.scheduler.nurserostering.swingui.NurseRosteringPanel.java

private JPanel createHeaderPanel() {
    JPanel headerPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    headerPanel.add(new JLabel("Planning window start:"));
    planningWindowStartField = new JTextField(10);
    planningWindowStartField.setEditable(false);
    headerPanel.add(planningWindowStartField);
    advancePlanningWindowStartAction = new AbstractAction("Advance 1 day into the future") {
        public void actionPerformed(ActionEvent e) {
            advancePlanningWindowStart();
        }//  www  .  ja  va2s  .co  m
    };
    advancePlanningWindowStartAction.setEnabled(false);
    headerPanel.add(new JButton(advancePlanningWindowStartAction));
    return headerPanel;
}

From source file:com.hp.alm.ali.idea.cfg.AliConfigurable.java

protected Component getSouthernComponent() {
    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final TroubleShootService troubleShootService = ApplicationManager.getApplication()
            .getComponent(TroubleShootService.class);
    final JButton troubleshoot = new JButton(
            troubleShootService.isRunning() ? "Stop Troubleshoot" : "Troubleshoot");
    troubleshoot.addActionListener(new ActionListener() {
        @Override/*  ww  w  .java2s  .c o  m*/
        public void actionPerformed(ActionEvent e) {
            if (troubleshoot.getText().equals("Troubleshoot")) {
                if (!troubleShootService.isRunning()) {
                    if (Messages.showYesNoDialog("Do you want to log complete ALM server communication?",
                            "Confirmation", null) == Messages.YES) {
                        FileSaverDescriptor desc = new FileSaverDescriptor("Log server communication",
                                "Log server communication on the local filesystem.");
                        final VirtualFileWrapper file = FileChooserFactory.getInstance()
                                .createSaveFileDialog(desc, troubleshoot).save(null, "REST_log.txt");
                        if (file == null) {
                            return;
                        }

                        troubleShootService.start(file.getFile());
                        troubleshoot.setText("Stop Troubleshoot");
                    }
                }
            } else {
                troubleShootService.stop();
                troubleshoot.setText("Troubleshoot");
            }
        }
    });
    southPanel.add(troubleshoot);
    return southPanel;
}