Example usage for java.awt FlowLayout LEADING

List of usage examples for java.awt FlowLayout LEADING

Introduction

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

Prototype

int LEADING

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

Click Source Link

Document

This value indicates that each row of components should be justified to the leading edge of the container's orientation, for example, to the left in left-to-right orientations.

Usage

From source file:Main.java

public static void main(String[] args) {
    FlowLayout layout = new FlowLayout(FlowLayout.LEADING, horizontalGap, verticalGap);
    JButton button = new JButton("Discard");
    JLabel[] panels = new JLabel[5];

    JFrame frame = new JFrame("Poker");
    frame.setSize(width, height);/* w w  w. j a va2s.  c o m*/
    frame.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);

    JPanel deckPanel = new JPanel(layout);
    for (int i = 0; i < 5; i++) {
        panels[i] = new JLabel("" + i);
        deckPanel.add(panels[i]);
    }
    frame.getContentPane().add(deckPanel);
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    buttonPanel.add(button);
    frame.getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.pack();

    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JFrame frame = new JFrame("Layout");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    int horizontalGap = 20;
    int verticalGap = 10;
    Container contentPane = frame.getContentPane();
    FlowLayout flowLayout = new FlowLayout(FlowLayout.LEADING, horizontalGap, verticalGap);
    contentPane.setLayout(flowLayout);/*from w  ww . java2s  . c o m*/
    frame.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

    for (int i = 1; i <= 5; i++) {
        contentPane.add(new JButton("Button  " + i));
    }
    frame.pack();
    frame.setVisible(true);
}

From source file:Main.java

public static void main(String[] args) {
    JPanel ui = new JPanel(new BorderLayout(4, 4));
    ui.setBorder(new EmptyBorder(6, 6, 6, 6));

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.LEADING));
    ui.add(controls, BorderLayout.PAGE_START);
    int s = 100;//w ww  . j a va2  s .c  o  m
    Dimension[] sizes = { new Dimension(s * 4, s * 2), new Dimension(s * 6, s * 3),
            new Dimension(s * 8, s * 4) };
    final JComboBox cb = new JComboBox(sizes);
    controls.add(cb);
    final JPanel[] panels = new JPanel[sizes.length];
    for (int ii = 0; ii < sizes.length; ii++) {
        Dimension d = sizes[ii];
        BufferedImage bi = new BufferedImage(d.width, d.height, BufferedImage.TYPE_INT_RGB);
        JPanel p = new JPanel(new GridLayout());
        JLabel l = new JLabel(new ImageIcon(bi));
        p.add(l);
        panels[ii] = p;
    }
    ItemListener sizeListener = new ItemListener() {

        JPanel current = panels[0];

        @Override
        public void itemStateChanged(ItemEvent e) {
            JPanel next = panels[cb.getSelectedIndex()];
            swapComponentsAndResizeUI(ui, current, next);
            current = next;
        }
    };
    cb.addItemListener(sizeListener);

    ui.add(panels[0], BorderLayout.CENTER);

    JFrame f = new JFrame("Three Sized Panels");
    f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    f.setContentPane(ui);
    f.pack();
    f.setLocationByPlatform(true);
    f.setVisible(true);
}

From source file:Main.java

public Main() {
    super(new FlowLayout(FlowLayout.LEADING, 10, 3));
    add(new JButton("w w w.j a v a 2 s . c o m"));
    add(new JButton("w w w.j a v a 2 s . com"));
    add(new JButton("w w w.java2s.com"));
    add(new JButton("www.j ava 2 s . c o m"));
}

From source file:Main.java

public Main() {
    tabbedPane.add(new JScrollPane(createTabbedPanel()), "Tab " + i);
    add.addActionListener(e -> {//  ww  w.  j  a v a  2s . c o m
        i++;
        tabbedPane.add(new JScrollPane(createTabbedPanel()), "Tab " + i);
    });

    JFrame frame = new JFrame();
    JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    buttonPanel.add(add);
    frame.add(buttonPanel, BorderLayout.PAGE_START);
    frame.add(tabbedPane);
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setLocationRelativeTo(null);
    frame.setVisible(true);
}

From source file:de.dakror.virtualhub.client.dialog.ChooseCatalogDialog.java

public static void show(ClientFrame frame, final JSONArray data) {
    final JDialog dialog = new JDialog(frame, "Katalog whlen", true);
    dialog.setSize(400, 300);/*from   w  w  w.  j  av  a  2s. com*/
    dialog.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    dialog.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            Client.currentClient.disconnect();
            System.exit(0);
        }
    });

    JPanel contentPane = new JPanel(new FlowLayout(FlowLayout.LEADING, 0, 0));
    dialog.setContentPane(contentPane);
    DefaultListModel dlm = new DefaultListModel();
    for (int i = 0; i < data.length(); i++) {
        try {
            dlm.addElement(data.getJSONObject(i).getString("name"));
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    final JList catalogs = new JList(dlm);
    catalogs.setDragEnabled(false);
    catalogs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    JScrollPane jsp = new JScrollPane(catalogs, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    jsp.setPreferredSize(new Dimension(396, 200));
    contentPane.add(jsp);

    JPanel mods = new JPanel(new GridLayout(1, 2));
    mods.setPreferredSize(new Dimension(50, 22));
    mods.add(new JButton(new AbstractAction("+") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            String name = JOptionPane.showInputDialog(dialog,
                    "Bitte geben Sie den Namen des neuen Katalogs ein.", "Katalog hinzufgen",
                    JOptionPane.PLAIN_MESSAGE);
            if (name != null && name.length() > 0) {
                DefaultListModel dlm = (DefaultListModel) catalogs.getModel();
                for (int i = 0; i < dlm.getSize(); i++) {
                    if (dlm.get(i).toString().equals(name)) {
                        JOptionPane.showMessageDialog(dialog,
                                "Es existert bereits ein Katalog mit diesem Namen!",
                                "Katalog bereits vorhanden!", JOptionPane.ERROR_MESSAGE);
                        actionPerformed(e);
                        return;
                    }
                }

                try {
                    dlm.addElement(name);
                    JSONObject o = new JSONObject();
                    o.put("name", name);
                    o.put("sources", new JSONArray());
                    o.put("tags", new JSONArray());
                    data.put(o);
                    Client.currentClient.sendPacket(new Packet0Catalogs(data));
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }));
    mods.add(new JButton(new AbstractAction("-") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (catalogs.getSelectedIndex() != -1) {
                if (JOptionPane.showConfirmDialog(dialog,
                        "Sind Sie sicher, dass Sie diesen\r\nKatalog unwiderruflich lschen wollen?",
                        "Katalog lschen", JOptionPane.YES_NO_CANCEL_OPTION,
                        JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_OPTION) {
                    DefaultListModel dlm = (DefaultListModel) catalogs.getModel();
                    data.remove(catalogs.getSelectedIndex());
                    dlm.remove(catalogs.getSelectedIndex());
                    try {
                        Client.currentClient.sendPacket(new Packet0Catalogs(data));
                    } catch (IOException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        }
    }));

    contentPane.add(mods);

    JLabel l = new JLabel("");
    l.setPreferredSize(new Dimension(396, 14));
    contentPane.add(l);

    JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
    sep.setPreferredSize(new Dimension(396, 10));
    contentPane.add(sep);

    JPanel buttons = new JPanel(new GridLayout(1, 2));
    buttons.setPreferredSize(new Dimension(396, 22));
    buttons.add(new JButton(new AbstractAction("Abbrechen") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            Client.currentClient.disconnect();
            System.exit(0);
        }
    }));
    buttons.add(new JButton(new AbstractAction("Katalog whlen") {
        private static final long serialVersionUID = 1L;

        @Override
        public void actionPerformed(ActionEvent e) {
            if (catalogs.getSelectedIndex() != -1) {
                try {
                    Client.currentClient
                            .setCatalog(new Catalog(data.getJSONObject(catalogs.getSelectedIndex())));
                    Client.currentClient.frame.setTitle("- " + Client.currentClient.getCatalog().getName());
                    dialog.dispose();
                } catch (JSONException e1) {
                    e1.printStackTrace();
                }
            }
        }
    }));

    dialog.add(buttons);

    dialog.setLocationRelativeTo(frame);
    dialog.setResizable(false);
    dialog.setVisible(true);
}

From source file:SourceInDemo.java

public SourceInDemo() {
    super("Source In");

    add(new ImageViewer(), BorderLayout.CENTER);
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING));
    panel.add(shadow = new JCheckBox("Drop Shadow"));
    shadow.addChangeListener(new ChangeListener() {
        public void stateChanged(ChangeEvent changeEvent) {
            repaint();//w  w  w.j av  a 2 s.c o m
        }
    });
    add(panel, BorderLayout.SOUTH);

    setSize(350, 250);
    setLocationRelativeTo(null);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}

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

/**
 * Creates a new instance of About <br>
 * //from  w w  w. j av  a2  s  .  c o m
 * @param parent
 */
public About(JFrame parent) {
    super(LanguageManager.getString("wiz_about.title"), LanguageManager.getString("wiz_about.description"),
            "mp64.gif", LanguageManager.getString("close"), 420, 620);
    JPanel thanksPanel = new JPanel();

    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setMaximumSize(new Dimension(32767, 26));
    thanksPanel.setOpaque(false);
    JLabel jLabel5 = new JLabel(LanguageManager.getString("version") + " : ");
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel5.setMaximumSize(new Dimension(100, 16));
    jLabel5.setMinimumSize(new Dimension(100, 16));
    jLabel5.setPreferredSize(new Dimension(100, 16));
    thanksPanel.add(jLabel5);
    jLabel5 = new JLabel(IdConst.VERSION);
    thanksPanel.add(jLabel5);
    gameParamPanel.add(thanksPanel);

    thanksPanel = new JPanel();
    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setOpaque(false);
    JPanel thanksPanelLeft = new JPanel(new FlowLayout(FlowLayout.LEADING));
    thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS));
    thanksPanelLeft.setMaximumSize(new Dimension(100, 2000));
    thanksPanelLeft.setMinimumSize(new Dimension(100, 16));
    jLabel5 = new JLabel(LanguageManager.getString("thanks") + " : ");
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel5.setMaximumSize(new Dimension(100, 16));
    jLabel5.setMinimumSize(new Dimension(100, 16));
    jLabel5.setPreferredSize(new Dimension(100, 16));
    thanksPanelLeft.add(jLabel5);
    thanksPanel.add(thanksPanelLeft);
    thanksPanelLeft = new JPanel();
    thanksPanelLeft.setLayout(new BoxLayout(thanksPanelLeft, BoxLayout.Y_AXIS));
    StringBuilder contributors = new StringBuilder();
    addContributor(contributors, "Fabrice Daugan", "developper", "france");
    addContributor(contributors, "Hoani Cross", "developper", "frenchpolynesia");
    addContributor(contributors, "nico100", "graphist", "france");
    addContributor(contributors, "seingalt_tm", "graphist", "france");
    addContributor(contributors, "surtur2", "tester", null);
    addContributor(contributors, "Jan Blaha", "developper", "cz");
    addContributor(contributors, "Tureba", "developper", "brazil");
    addContributor(contributors, "hakvf", "tester", "france");
    addContributor(contributors, "Stefano \"Kismet\" Lenzi", "developper", "italian");
    jLabel5 = new JLabel(contributors.toString());
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.LEFT);
    thanksPanelLeft.add(jLabel5);
    jLabel5 = new JLink("http://obsidiurne.free.fr", "morgil has designed the splash screen");
    jLabel5.setFont(MToolKit.defaultFont);
    thanksPanelLeft.add(jLabel5);
    thanksPanel.add(thanksPanelLeft);

    gameParamPanel.add(thanksPanel);

    thanksPanel = new JPanel();
    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setMaximumSize(new Dimension(32767, 26));
    thanksPanel.setOpaque(false);
    JLabel blanklbl = new JLabel();
    blanklbl.setHorizontalAlignment(SwingConstants.RIGHT);
    blanklbl.setMaximumSize(new Dimension(100, 16));
    blanklbl.setMinimumSize(new Dimension(100, 16));
    blanklbl.setPreferredSize(new Dimension(100, 16));
    thanksPanel.add(blanklbl);

    jLabel5 = new JLink(
            "http://sourceforge.net/tracker/?func=add&group_id=" + IdConst.PROJECT_ID + "&atid=601043",
            LanguageManager.getString("joindev"));
    jLabel5.setFont(MToolKit.defaultFont);
    thanksPanel.add(jLabel5);
    gameParamPanel.add(thanksPanel);

    thanksPanel = new JPanel();
    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setOpaque(false);
    jLabel5 = new JLabel(LanguageManager.getString("projecthome") + " : ");
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel5.setMaximumSize(new Dimension(100, 16));
    jLabel5.setMinimumSize(new Dimension(100, 16));
    jLabel5.setPreferredSize(new Dimension(100, 16));
    thanksPanel.add(jLabel5);
    jLabel5 = new JLink(IdConst.MAIN_PAGE, IdConst.MAIN_PAGE);
    jLabel5.setFont(MToolKit.defaultFont);
    thanksPanel.add(jLabel5);
    gameParamPanel.add(thanksPanel);

    // forum francais
    thanksPanel = new JPanel();
    thanksPanel.setLayout(new BoxLayout(thanksPanel, BoxLayout.X_AXIS));
    thanksPanel.setOpaque(false);
    jLabel5 = new JLabel(LanguageManager.getString("othersites") + " : ");
    jLabel5.setFont(MToolKit.defaultFont);
    jLabel5.setHorizontalAlignment(SwingConstants.RIGHT);
    jLabel5.setMaximumSize(new Dimension(100, 16));
    jLabel5.setMinimumSize(new Dimension(100, 16));
    jLabel5.setPreferredSize(new Dimension(100, 16));
    thanksPanel.add(jLabel5);
    jLabel5 = new JLink("http://www.Firemox.fr.st", UIHelper.getIcon("mpfrsml.gif"), SwingConstants.LEFT);
    jLabel5.setToolTipText(LanguageManager.getString("frenchforum.tooltip"));
    thanksPanel.add(jLabel5);
    jLabel5 = new JLabel();
    jLabel5.setMaximumSize(new Dimension(1000, 16));
    thanksPanel.add(jLabel5);
    gameParamPanel.add(thanksPanel);

    JTextArea disclaimer = new JTextArea();
    disclaimer.setEditable(false);
    disclaimer.setLineWrap(true);
    disclaimer.setWrapStyleWord(true);
    disclaimer.setAutoscrolls(true);
    disclaimer.setTabSize(2);
    disclaimer.setFont(new Font("Arial", 0, 10));
    // Then try and read it locally
    BufferedReader inGPL = null;
    try {
        inGPL = new BufferedReader(new InputStreamReader(MToolKit.getResourceAsStream(IdConst.FILE_LICENSE)));
        disclaimer.read(inGPL, "");
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        IOUtils.closeQuietly(inGPL);
    }
    JScrollPane disclaimerSPanel = new JScrollPane();
    disclaimerSPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    MToolKit.addOverlay(disclaimerSPanel);
    disclaimerSPanel.setViewportView(disclaimer);
    gameParamPanel.add(disclaimerSPanel);
}

From source file:com.intuit.tank.tools.debugger.VariableDialog.java

/**
 * @return/*from  w  w w  .j  a  v  a2  s  .c o  m*/
 */
private Component createButtonPanel() {
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEADING, 10, 5));
    JButton saveBT = new JButton("Save");
    saveBT.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (table.isEditing()) {
                table.getCellEditor().stopCellEditing();
            }
            Map<String, String> ret = new HashMap<String, String>();
            for (int row = 0; row < table.getModel().getRowCount(); row++) {
                String key = (String) table.getModel().getValueAt(row, 0);
                String value = (String) table.getModel().getValueAt(row, 1);
                if (StringUtils.isNotBlank(key) && StringUtils.isNotBlank(value)) {
                    ret.put(key, value);
                }
            }
            f.setProjectVariables(ret);
            setVisible(false);
        }
    });
    panel.add(saveBT);

    JButton cancelBT = new JButton("Close");
    cancelBT.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            setVisible(false);
        }
    });
    panel.add(cancelBT);

    JButton addBt = new JButton("Add Variable");
    addBt.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (table.isEditing()) {
                table.getCellEditor().stopCellEditing();
            }
            try {
                ((DefaultTableModel) table.getModel()).addRow(new Object[] { "Key", "Value" });
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    panel.add(addBt);

    deleteBT = new JButton("Delete Variable");
    deleteBT.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
            if (table.isEditing()) {
                table.getCellEditor().stopCellEditing();
            }
            try {
                int selectedRow = table.getSelectedRow();
                ((DefaultTableModel) table.getModel()).removeRow(table.getSelectedRow());
                if (selectedRow > 0) {
                    table.getSelectionModel().setSelectionInterval(selectedRow - 1, selectedRow - 1);
                } else if (table.getRowCount() > 0) {
                    table.getSelectionModel().setSelectionInterval(0, 0);
                } else {
                    table.getSelectionModel().clearSelection();
                }
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    deleteBT.setEnabled(false);
    panel.add(deleteBT);
    return panel;
}

From source file:com.floreantpos.ui.dialog.DiscountSelectionDialog.java

private void initComponent() {
    setOkButtonText(POSConstants.SAVE_BUTTON_TEXT);
    createCouponSearchPanel();/*from w  w w  .j a v  a2 s . c  o m*/
    getContentPanel().add(itemSearchPanel, BorderLayout.NORTH);

    buttonsPanel = new ScrollableFlowPanel(FlowLayout.LEADING);

    JScrollPane scrollPane = new PosScrollPane(buttonsPanel, PosScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            PosScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.getVerticalScrollBar().setPreferredSize(new Dimension(80, 0));
    scrollPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5),
            scrollPane.getBorder()));

    getContentPanel().add(scrollPane, BorderLayout.CENTER);

    rendererDiscounts();

    setSize(1024, 720);
}