Example usage for java.awt FlowLayout RIGHT

List of usage examples for java.awt FlowLayout RIGHT

Introduction

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

Prototype

int RIGHT

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

Click Source Link

Document

This value indicates that each row of components should be right-justified.

Usage

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() {
        {//from  w w  w . ja  va  2 s . co 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:edu.harvard.mcz.imagecapture.SpecimenPartAttribEditDialog.java

private void init() {
    setTitle("Edit Part Attribute");
    setBounds(100, 100, 420, 200);/*w  w w .  j  av  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:eu.delving.sip.actions.ImportAction.java

private void prepareDialog() {
    JButton cancel = new JButton("Cancel");
    cancel.addActionListener(new ActionListener() {
        @Override// w ww .ja va2s.com
        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:View.ReadView.java

public ReadView(ReadController controller, Email obj) throws IOException {
    this.frame = new JFrame();
    this.topPane = new JPanel();
    this.topLeftPane = new JPanel();
    this.topRightPane = new JPanel();
    this.topBottomPane = new JPanel();
    this.container = frame.getContentPane();
    this.controller = controller;
    this.bottomPane = new JPanel();

    frame.setTitle("Ler Email");

    container.setLayout(new BorderLayout(20, 20));

    JButton btnSave = new JButton("Salvar no Banco");
    btnSave.addActionListener((ActionEvent e) -> {
        try {//from   ww  w  .  ja va2s  .co  m
            if (controller.save()) {
                JOptionPane.showMessageDialog(null, "Mensagem salva com sucesso");
            } else {
                JOptionPane.showMessageDialog(null, "Erro ao salvar mensagem");
            }
        } catch (ClassNotFoundException | SQLException | ParseException ex) {
            Logger.getLogger(ReadView.class.getName()).log(Level.SEVERE, null, ex);
        }
    });

    JLabel labelAddress = new JLabel();
    labelAddress.setText("Email: " + obj.getAddress());

    JLabel labelDate = new JLabel();
    labelDate.setText("Data: " + obj.getDate());

    JLabel labelSubject = new JLabel();
    labelSubject.setText("Assunto: " + obj.getSubject());

    JTextArea message = new JTextArea();
    message.append("Mensagem aqui..." + obj.getMessage());

    messagePane = new JScrollPane(message);

    topPane.setLayout(new BorderLayout(20, 20));
    topPane.add(BorderLayout.WEST, topLeftPane);
    topPane.add(BorderLayout.EAST, topRightPane);
    topPane.add(BorderLayout.SOUTH, topBottomPane);

    topLeftPane.setLayout(new FlowLayout(FlowLayout.LEFT));
    topRightPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    topBottomPane.setLayout(new FlowLayout(FlowLayout.LEFT));

    topLeftPane.add(labelAddress);
    topRightPane.add(labelDate);
    topBottomPane.add(labelSubject);

    bottomPane.add(btnSave);

    container.add(BorderLayout.NORTH, topPane);
    container.add(BorderLayout.CENTER, messagePane);
    container.add(BorderLayout.SOUTH, bottomPane);

    frame.pack();

    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.setSize(600, 600);

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);

    frame.setVisible(true);
}

From source file:View.MainView.java

public MainView(MainController controller) throws IOException {
    this.frame = new JFrame();
    this.topPane = new JPanel();
    this.container = frame.getContentPane();
    this.controller = controller;

    frame.setTitle("Lista de Emails");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    container.setLayout(new BorderLayout(20, 20));

    tabela = new TableView();

    listPane = new JScrollPane(tabela.getTable());

    JButton btnSeeSaved = new JButton("Ver salvos Salvar");
    btnSeeSaved.addActionListener((ActionEvent e) -> {

        try {//from  w w w.ja v  a 2  s  .c o m
            SavedController savedController = new SavedController();
        } catch (IOException | ClassNotFoundException | SQLException ex) {
            Logger.getLogger(MainView.class.getName()).log(Level.SEVERE, null, ex);
        }

    });

    JButton btnOpen = new JButton("Abrir");
    btnOpen.addActionListener((ActionEvent e) -> {
        int row = tabela.getSelectedRow();
        String gmail_id = tabela.getModel().getValueAt(row, 0).toString();

        try {
            ReadController readController = new ReadController(gmail_id);
        } catch (IOException | MessagingException ex) {
            Logger.getLogger(MainView.class.getName()).log(Level.SEVERE, null, ex);
        }

    });

    topPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
    topPane.add(btnOpen);
    topPane.add(btnSeeSaved);

    container.add(BorderLayout.NORTH, topPane);
    container.add(BorderLayout.CENTER, listPane);

    frame.pack();

    frame.setResizable(false);
    frame.setLocationRelativeTo(null);
    frame.setSize(600, 600);

    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);

    frame.setVisible(true);
}

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/*from  w w w. j a va  2s  .com*/
        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;
}

From source file:cn.edu.tsinghua.gui.HistogramDemo.java

/**
 * Initialize display.//  www.j  a  v  a2 s  . c  o m
 * @author Sun Microsystems
 * @param filename is the image filename
 */
public HistogramDemo(String filename) {
    File f = new File(filename);

    if (f.exists() && f.canRead()) {
        source = JAI.create("fileload", filename);
    } else {
        return;
    }

    canvas = new ImageDisplay(source);
    canvas.setLayout(new FlowLayout(FlowLayout.RIGHT, 2, 2));

    panner = new Panner(canvas, source, 128);
    panner.setBackground(Color.red);
    panner.setBorder(new EtchedBorder());
    canvas.add(panner);

    Font font = new Font("SansSerif", Font.BOLD, 12);
    JLabel title = new JLabel(" Histogram");
    title.setFont(font);
    title.setLocation(0, 32);

    setOpaque(true);
    setLayout(new BorderLayout());
    setBackground(Color.white);

    graph = new XYPlot();
    graph.setBackground(Color.black);
    graph.setBorder(new LineBorder(new Color(0, 0, 255), 1));

    Colorbar cbar = new Colorbar();
    cbar.setBackground(Color.black);
    cbar.setPreferredSize(new Dimension(256, 25));
    cbar.setBorder(new LineBorder(new Color(255, 0, 255), 2));

    JPanel hist_panel = new JPanel();
    hist_panel.setLayout(new BorderLayout());
    hist_panel.setBackground(Color.white);
    hist_panel.add(graph, BorderLayout.CENTER);
    hist_panel.add(cbar, BorderLayout.SOUTH);

    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 1, 5, 5));
    panel.setBackground(Color.white);
    panel.add(canvas);
    panel.add(hist_panel);

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

    reset = new JButton("Reset");
    equal = new JButton("Uniform");
    norm = new JButton("Gaussian");
    piece = new JButton("Piecewise");

    reset.addActionListener(this);
    equal.addActionListener(this);
    norm.addActionListener(this);
    piece.addActionListener(this);

    controlPanel.add(reset);
    controlPanel.add(equal);
    controlPanel.add(norm);
    controlPanel.add(piece);

    add(title, BorderLayout.NORTH);
    add(panel, BorderLayout.CENTER);
    add(controlPanel, BorderLayout.SOUTH);

    // original histogram (remains unmodified)
    // graph.plot( getHistogram(source) );
    graph.plot(getMultiHistogram(source));
}

From source file:com.sshtools.common.ui.OptionsPanel.java

/**
 *
 *
 * @param parent/* ww  w.  j av a 2  s .com*/
 * @param tabs tabs
 *
 * @return
 */
public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) {
    final OptionsPanel opts = new OptionsPanel(tabs);
    opts.reset();

    JDialog d = null;
    Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent);

    if (w instanceof JDialog) {
        d = new JDialog((JDialog) w, "Options", true);
    } else if (w instanceof JFrame) {
        d = new JDialog((JFrame) w, "Options", true);
    } else {
        d = new JDialog((JFrame) null, "Options", true);
    }

    final JDialog dialog = d;

    //  Create the bottom button panel
    final JButton cancel = new JButton("Cancel");
    cancel.setMnemonic('c');
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            opts.cancelled = true;
            dialog.setVisible(false);
        }
    });

    final JButton ok = new JButton("Ok");
    ok.setMnemonic('o');
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (opts.validateTabs()) {
                dialog.setVisible(false);
            }
        }
    });
    dialog.getRootPane().setDefaultButton(ok);

    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(6, 6, 0, 0);
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE);
    UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER);

    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    southPanel.add(buttonPanel);

    //
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPanel.add(opts, BorderLayout.CENTER);
    mainPanel.add(southPanel, BorderLayout.SOUTH);

    // Show the dialog
    dialog.getContentPane().setLayout(new GridLayout(1, 1));
    dialog.getContentPane().add(mainPanel);
    dialog.pack();
    dialog.setResizable(true);
    UIUtil.positionComponent(SwingConstants.CENTER, dialog);
    dialog.setVisible(true);

    if (!opts.cancelled) {
        opts.applyTabs();
    }

    return !opts.cancelled;
}

From source file:net.sf.firemox.ui.wizard.Wizard.java

/**
 * Create a new instance of this class.//from  ww  w  .  j  a  v a2 s.  com
 * 
 * @param ability
 *          ability to associate to this ability. If this ability has an
 *          associated picture, it will be used instead of given picture.
 *          Ability's name is also used to fill the title. This ability will
 *          be used to restart this wizard in case of Background button is
 *          used.
 * @param title
 *          the title of this wizard.
 * @param description
 *          the description appended to the title of this wizard. This content
 *          will be displayed as Html.
 * @param iconName
 *          the icon's name to display on the top right place.
 * @param width
 *          the preferred width.
 * @param height
 *          the preferred height.
 */
public Wizard(Ability ability, String title, String description, String iconName, int width, int height) {
    super(MagicUIComponents.magicForm, StringUtils.capitalize(title), true);
    getRootPane().setPreferredSize(new Dimension(width, 300));
    getRootPane().setMinimumSize(new Dimension(width, height));
    setSize(new Dimension(width, height));

    // center
    gameParamPanel = new JPanel(null);
    gameParamPanel.setLayout(new BoxLayout(gameParamPanel, BoxLayout.Y_AXIS));
    if (ability == null)
        getContentPane().add(new WizardTitle(new WizardImageIcon((Image) null, iconName), description),
                BorderLayout.NORTH);
    else
        getContentPane().add(new WizardTitle(new WizardImageIcon(ability.getCard(), iconName), description),
                BorderLayout.NORTH);
    getContentPane().add(gameParamPanel, BorderLayout.CENTER);
    getContentPane().add(new JPanel(), BorderLayout.EAST);

    // bottom
    final JPanel abstractButtonPanel = new JPanel(new BorderLayout());
    this.buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    this.ability = ability;
    abstractButtonPanel.setBorder(null);
    abstractButtonPanel.add(new JSeparator(), BorderLayout.NORTH);
    abstractButtonPanel.add(buttonPanel, BorderLayout.CENTER);
    abstractButtonPanel.add(wizardInfo, BorderLayout.SOUTH);
    getContentPane().add(abstractButtonPanel, BorderLayout.SOUTH);
    setLocationRelativeTo(null);
}

From source file:net.sf.profiler4j.console.ProjectDialog.java

/**
 * This method initializes jPanel/*from w ww . j av  a  2s.co  m*/
 * 
 * @return javax.swing.JPanel
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        FlowLayout flowLayout = new FlowLayout();
        flowLayout.setAlignment(java.awt.FlowLayout.RIGHT);
        jPanel = new JPanel();
        jPanel.setLayout(flowLayout);
        jPanel.add(getOkButton(), null);
        jPanel.add(getJButton(), null);
    }
    return jPanel;
}