Search in sources :

Example 91 with FlowLayout

use of java.awt.FlowLayout in project jdk8u_jdk by JetBrains.

the class SampleTree method constructOptionsPanel.

/** Constructs a JPanel containing check boxes for the different
     * options that tree supports. */
@SuppressWarnings("serial")
private JPanel constructOptionsPanel() {
    JCheckBox aCheckbox;
    JPanel retPanel = new JPanel(false);
    JPanel borderPane = new JPanel(false);
    borderPane.setLayout(new BorderLayout());
    retPanel.setLayout(new FlowLayout());
    aCheckbox = new JCheckBox("show top level handles");
    aCheckbox.setSelected(tree.getShowsRootHandles());
    aCheckbox.addChangeListener(new ShowHandlesChangeListener());
    retPanel.add(aCheckbox);
    aCheckbox = new JCheckBox("show root");
    aCheckbox.setSelected(tree.isRootVisible());
    aCheckbox.addChangeListener(new ShowRootChangeListener());
    retPanel.add(aCheckbox);
    aCheckbox = new JCheckBox("editable");
    aCheckbox.setSelected(tree.isEditable());
    aCheckbox.addChangeListener(new TreeEditableChangeListener());
    aCheckbox.setToolTipText("Triple click to edit");
    retPanel.add(aCheckbox);
    borderPane.add(retPanel, BorderLayout.CENTER);
    /* Create a set of radio buttons that dictate what selection should
        be allowed in the tree. */
    ButtonGroup group = new ButtonGroup();
    JPanel buttonPane = new JPanel(false);
    JRadioButton button;
    buttonPane.setLayout(new FlowLayout());
    buttonPane.setBorder(new TitledBorder("Selection Mode"));
    button = new JRadioButton("Single");
    button.addActionListener(new AbstractAction() {

        @Override
        public boolean isEnabled() {
            return true;
        }

        public void actionPerformed(ActionEvent e) {
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        }
    });
    group.add(button);
    buttonPane.add(button);
    button = new JRadioButton("Contiguous");
    button.addActionListener(new AbstractAction() {

        @Override
        public boolean isEnabled() {
            return true;
        }

        public void actionPerformed(ActionEvent e) {
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
        }
    });
    group.add(button);
    buttonPane.add(button);
    button = new JRadioButton("Discontiguous");
    button.addActionListener(new AbstractAction() {

        @Override
        public boolean isEnabled() {
            return true;
        }

        public void actionPerformed(ActionEvent e) {
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
        }
    });
    button.setSelected(true);
    group.add(button);
    buttonPane.add(button);
    borderPane.add(buttonPane, BorderLayout.SOUTH);
    /*
        JPanel               clickPanel = new JPanel();
        Object[]             values = { "Never", new Integer(1),
        new Integer(2), new Integer(3) };
        final JComboBox      clickCBox = new JComboBox(values);

        clickPanel.setLayout(new FlowLayout());
        clickPanel.add(new JLabel("Click count to expand:"));
        clickCBox.setSelectedIndex(2);
        clickCBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
        Object       selItem = clickCBox.getSelectedItem();

        if(selItem instanceof Integer)
        tree.setToggleClickCount(((Integer)selItem).intValue());
        else // Don't toggle
        tree.setToggleClickCount(0);
        }
        });
        clickPanel.add(clickCBox);
        borderPane.add(clickPanel, BorderLayout.NORTH);
         */
    return borderPane;
}
Also used : FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BorderLayout(java.awt.BorderLayout)

Example 92 with FlowLayout

use of java.awt.FlowLayout in project jdk8u_jdk by JetBrains.

the class SwingApplet method initUI.

private void initUI() {
    // Trying to set Nimbus look and feel
    try {
        UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
    } catch (Exception ex) {
        Logger.getLogger(SwingApplet.class.getName()).log(Level.SEVERE, "Failed to apply Nimbus look and feel", ex);
    }
    getContentPane().setLayout(new FlowLayout());
    button = new JButton("Hello, I'm a Swing Button!");
    getContentPane().add(button);
    getContentPane().doLayout();
}
Also used : FlowLayout(java.awt.FlowLayout) JButton(javax.swing.JButton) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 93 with FlowLayout

use of java.awt.FlowLayout in project jdk8u_jdk by JetBrains.

the class ServiceDialog method initPageDialog.

/**
     * Initialize "page setup" dialog
     */
void initPageDialog(int x, int y, PrintService ps, DocFlavor flavor, PrintRequestAttributeSet attributes) {
    this.psCurrent = ps;
    this.docFlavor = flavor;
    this.asOriginal = attributes;
    this.asCurrent = new HashPrintRequestAttributeSet(attributes);
    if (attributes.get(DialogOnTop.class) != null) {
        setAlwaysOnTop(true);
    }
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    pnlPageSetup = new PageSetupPanel();
    c.add(pnlPageSetup, BorderLayout.CENTER);
    pnlPageSetup.updateInfo();
    JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    btnApprove = createExitButton("button.ok", this);
    pnlSouth.add(btnApprove);
    getRootPane().setDefaultButton(btnApprove);
    btnCancel = createExitButton("button.cancel", this);
    handleEscKey(btnCancel);
    pnlSouth.add(btnCancel);
    c.add(pnlSouth, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent event) {
            dispose(CANCEL);
        }
    });
    getAccessibleContext().setAccessibleDescription(getMsg("dialog.pstitle"));
    setResizable(false);
    setLocation(x, y);
    pack();
}
Also used : Container(java.awt.Container) FlowLayout(java.awt.FlowLayout) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) WindowAdapter(java.awt.event.WindowAdapter)

Example 94 with FlowLayout

use of java.awt.FlowLayout in project jdk8u_jdk by JetBrains.

the class ServiceDialog method initPrintDialog.

/**
     * Initialize print dialog.
     */
void initPrintDialog(int x, int y, PrintService[] services, int defaultServiceIndex, DocFlavor flavor, PrintRequestAttributeSet attributes) {
    this.services = services;
    this.defaultServiceIndex = defaultServiceIndex;
    this.asOriginal = attributes;
    this.asCurrent = new HashPrintRequestAttributeSet(attributes);
    this.psCurrent = services[defaultServiceIndex];
    this.docFlavor = flavor;
    SunPageSelection pages = (SunPageSelection) attributes.get(SunPageSelection.class);
    if (pages != null) {
        isAWT = true;
    }
    if (attributes.get(DialogOnTop.class) != null) {
        setAlwaysOnTop(true);
    }
    Container c = getContentPane();
    c.setLayout(new BorderLayout());
    tpTabs = new JTabbedPane();
    tpTabs.setBorder(new EmptyBorder(5, 5, 5, 5));
    String gkey = getMsg("tab.general");
    int gmnemonic = getVKMnemonic("tab.general");
    pnlGeneral = new GeneralPanel();
    tpTabs.add(gkey, pnlGeneral);
    tpTabs.setMnemonicAt(0, gmnemonic);
    String pkey = getMsg("tab.pagesetup");
    int pmnemonic = getVKMnemonic("tab.pagesetup");
    pnlPageSetup = new PageSetupPanel();
    tpTabs.add(pkey, pnlPageSetup);
    tpTabs.setMnemonicAt(1, pmnemonic);
    String akey = getMsg("tab.appearance");
    int amnemonic = getVKMnemonic("tab.appearance");
    pnlAppearance = new AppearancePanel();
    tpTabs.add(akey, pnlAppearance);
    tpTabs.setMnemonicAt(2, amnemonic);
    c.add(tpTabs, BorderLayout.CENTER);
    updatePanels();
    JPanel pnlSouth = new JPanel(new FlowLayout(FlowLayout.TRAILING));
    btnApprove = createExitButton("button.print", this);
    pnlSouth.add(btnApprove);
    getRootPane().setDefaultButton(btnApprove);
    btnCancel = createExitButton("button.cancel", this);
    handleEscKey(btnCancel);
    pnlSouth.add(btnCancel);
    c.add(pnlSouth, BorderLayout.SOUTH);
    addWindowListener(new WindowAdapter() {

        public void windowClosing(WindowEvent event) {
            dispose(CANCEL);
        }
    });
    getAccessibleContext().setAccessibleDescription(getMsg("dialog.printtitle"));
    setResizable(false);
    setLocation(x, y);
    pack();
}
Also used : FlowLayout(java.awt.FlowLayout) WindowAdapter(java.awt.event.WindowAdapter) javax.print(javax.print) Container(java.awt.Container) BorderLayout(java.awt.BorderLayout) WindowEvent(java.awt.event.WindowEvent) SunPageSelection(sun.print.SunPageSelection) EmptyBorder(javax.swing.border.EmptyBorder)

Example 95 with FlowLayout

use of java.awt.FlowLayout in project JMRI by JMRI.

the class LocoDataPane method initComponents.

@Override
public void initComponents(jmri.jmrix.tams.TamsSystemConnectionMemo memo) {
    super.initComponents(memo);
    locoModel = new LocoDataModel(128, 16, memo);
    locoTable = new JTable(locoModel);
    locoTable.setRowSorter(new TableRowSorter<>(locoModel));
    locoScroll = new JScrollPane(locoTable);
    locoModel.configureTable(locoTable);
    // general GUI config
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    // install items in GUI
    JPanel pane1 = new JPanel();
    pane1.setLayout(new FlowLayout());
    pane1.add(new JLabel(rb.getString("Address")));
    pane1.add(addr);
    pane1.add(new JLabel(rb.getString("Name")));
    pane1.add(name);
    pane1.add(new JLabel(rb.getString("Steps")));
    pane1.add(speedBox);
    pane1.add(new JLabel(rb.getString("Format")));
    pane1.add(formatBox);
    pane1.add(addButton);
    // add listener object so checkboxes function
    addButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            addLoco();
        }
    });
    add(pane1);
    add(locoScroll);
    if (pane1.getMaximumSize().height > 0 && pane1.getMaximumSize().width > 0) {
        pane1.setMaximumSize(pane1.getPreferredSize());
    }
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) JTable(javax.swing.JTable) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel)

Aggregations

FlowLayout (java.awt.FlowLayout)400 JPanel (javax.swing.JPanel)338 JLabel (javax.swing.JLabel)189 JButton (javax.swing.JButton)161 ActionEvent (java.awt.event.ActionEvent)134 BoxLayout (javax.swing.BoxLayout)129 BorderLayout (java.awt.BorderLayout)118 ActionListener (java.awt.event.ActionListener)113 Dimension (java.awt.Dimension)95 JScrollPane (javax.swing.JScrollPane)94 Container (java.awt.Container)49 GridBagLayout (java.awt.GridBagLayout)42 JTextField (javax.swing.JTextField)41 Insets (java.awt.Insets)39 GridBagConstraints (java.awt.GridBagConstraints)38 ButtonGroup (javax.swing.ButtonGroup)38 JCheckBox (javax.swing.JCheckBox)35 JTable (javax.swing.JTable)32 JmriJFrame (jmri.util.JmriJFrame)30 JSeparator (javax.swing.JSeparator)24