Search in sources :

Example 51 with GridLayout

use of java.awt.GridLayout in project jgnash by ccavanaugh.

the class NetworkAuthenticator method getPasswordAuthentication.

@Override
protected PasswordAuthentication getPasswordAuthentication() {
    Preferences auth = Preferences.userRoot().node(NODEHTTP);
    char[] pass = null;
    String user;
    // get the password
    String _pass = auth.get(HTTPPASS, null);
    if (_pass != null) {
        if (!_pass.isEmpty()) {
            pass = _pass.toCharArray();
        }
    }
    // get the user
    user = auth.get(HTTPUSER, null);
    if (user != null) {
        if (user.length() <= 0) {
            user = null;
        }
    }
    // if either returns null, pop a dialog
    if (user == null || pass == null) {
        JTextField username = new JTextField();
        JPasswordField password = new JPasswordField();
        JPanel panel = new JPanel(new GridLayout(2, 2));
        panel.add(new JLabel(ResourceUtils.getString("Label.UserName")));
        panel.add(username);
        panel.add(new JLabel(ResourceUtils.getString("Label.Password")));
        panel.add(password);
        int option = JOptionPane.showConfirmDialog(null, new Object[] { "Site: " + getRequestingHost(), "Realm: " + getRequestingPrompt(), panel }, "Enter Network Password", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
        if (option == JOptionPane.OK_OPTION) {
            user = username.getText();
            pass = password.getPassword();
        } else {
            return null;
        }
    }
    return new PasswordAuthentication(user, pass);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) JPasswordField(javax.swing.JPasswordField) JLabel(javax.swing.JLabel) Preferences(java.util.prefs.Preferences) JTextField(javax.swing.JTextField) PasswordAuthentication(java.net.PasswordAuthentication)

Example 52 with GridLayout

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

the class TableExample method createConnectionDialog.

/**
     * Creates the connectionPanel, which will contain all the fields for
     * the connection information.
     */
public void createConnectionDialog() {
    // Create the labels and text fields.
    userNameLabel = new JLabel("User name: ", JLabel.RIGHT);
    userNameField = new JTextField("app");
    passwordLabel = new JLabel("Password: ", JLabel.RIGHT);
    passwordField = new JTextField("app");
    serverLabel = new JLabel("Database URL: ", JLabel.RIGHT);
    serverField = new JTextField("jdbc:derby://localhost:1527/sample");
    driverLabel = new JLabel("Driver: ", JLabel.RIGHT);
    driverField = new JTextField("org.apache.derby.jdbc.ClientDriver");
    connectionPanel = new JPanel(false);
    connectionPanel.setLayout(new BoxLayout(connectionPanel, BoxLayout.X_AXIS));
    JPanel namePanel = new JPanel(false);
    namePanel.setLayout(new GridLayout(0, 1));
    namePanel.add(userNameLabel);
    namePanel.add(passwordLabel);
    namePanel.add(serverLabel);
    namePanel.add(driverLabel);
    JPanel fieldPanel = new JPanel(false);
    fieldPanel.setLayout(new GridLayout(0, 1));
    fieldPanel.add(userNameField);
    fieldPanel.add(passwordField);
    fieldPanel.add(serverField);
    fieldPanel.add(driverField);
    connectionPanel.add(namePanel);
    connectionPanel.add(fieldPanel);
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) BoxLayout(javax.swing.BoxLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField)

Example 53 with GridLayout

use of java.awt.GridLayout in project jabref by JabRef.

the class BasicAction method setUpFieldListPanel.

private JPanel setUpFieldListPanel() {
    JPanel inputPanel = new JPanel();
    // Panel Layout
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints con = new GridBagConstraints();
    con.weightx = 0;
    con.insets = new Insets(5, 5, 0, 5);
    con.fill = GridBagConstraints.HORIZONTAL;
    inputPanel.setLayout(gbl);
    // Border
    TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createLineBorder(new Color(153, 153, 153), 2), Localization.lang("Work options"));
    inputPanel.setBorder(titledBorder1);
    inputPanel.setMinimumSize(new Dimension(10, 10));
    JScrollPane fieldScroller = new JScrollPane(fieldList);
    fieldScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
    // insert buttons
    insertButton.addActionListener(event -> insertTextForTag(override.isSelected()));
    // Radio buttons
    append.setToolTipText(Localization.lang("Append the selected text to BibTeX field"));
    append.setMnemonic(KeyEvent.VK_A);
    append.setSelected(true);
    override.setToolTipText(Localization.lang("Override the BibTeX field by the selected text"));
    override.setMnemonic(KeyEvent.VK_O);
    override.setSelected(false);
    //Group the radio buttons.
    ButtonGroup group = new ButtonGroup();
    group.add(append);
    group.add(override);
    JPanel radioPanel = new JPanel(new GridLayout(0, 1));
    radioPanel.add(append);
    radioPanel.add(override);
    // insert sub components
    JLabel label1 = new JLabel(Localization.lang("Available BibTeX fields"));
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(label1, con);
    inputPanel.add(label1);
    con.gridwidth = GridBagConstraints.REMAINDER;
    con.gridheight = 8;
    con.weighty = 1;
    con.fill = GridBagConstraints.BOTH;
    gbl.setConstraints(fieldScroller, con);
    inputPanel.add(fieldScroller);
    con.fill = GridBagConstraints.HORIZONTAL;
    con.weighty = 0;
    con.gridwidth = 2;
    gbl.setConstraints(radioPanel, con);
    inputPanel.add(radioPanel);
    con.gridwidth = GridBagConstraints.REMAINDER;
    gbl.setConstraints(insertButton, con);
    inputPanel.add(insertButton);
    return inputPanel;
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) GridLayout(java.awt.GridLayout) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) ButtonGroup(javax.swing.ButtonGroup) Color(java.awt.Color) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) TitledBorder(javax.swing.border.TitledBorder)

Example 54 with GridLayout

use of java.awt.GridLayout in project jabref by JabRef.

the class ACMPortalFetcher method getOptionsPanel.

@Override
public JPanel getOptionsPanel() {
    JPanel pan = new JPanel();
    pan.setLayout(new GridLayout(0, 1));
    guideButton.setSelected(true);
    ButtonGroup group = new ButtonGroup();
    group.add(acmButton);
    group.add(guideButton);
    pan.add(absCheckBox);
    pan.add(acmButton);
    pan.add(guideButton);
    return pan;
}
Also used : JPanel(javax.swing.JPanel) GridLayout(java.awt.GridLayout) ButtonGroup(javax.swing.ButtonGroup)

Example 55 with GridLayout

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

the class SwitchboardEditor method init.

/**
     * Initialize the newly created SwitchBoard.
     *
     * @param name name of the switchboard frame
     */
@Override
protected void init(String name) {
    //setVisible(false);
    // Editor
    Container contentPane = getContentPane();
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
    // make menus
    setGlobalSetsLocalFlag(false);
    setUseGlobalFlag(false);
    _menuBar = new JMenuBar();
    makeOptionMenu();
    //makeEditMenu();
    makeFileMenu();
    setJMenuBar(_menuBar);
    addHelpMenu("package.jmri.jmrit.display.SwitchboardEditor", true);
    //super.setTargetPanel(null, makeFrame(name)); // original CPE version
    //extends JLayeredPane();
    switchboardLayeredPane = new TargetPane();
    switchboardLayeredPane.setPreferredSize(new Dimension(300, 310));
    switchboardLayeredPane.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(defaultTextColor), Bundle.getMessage("SwitchboardBanner"), TitledBorder.LEADING, TitledBorder.ABOVE_BOTTOM, getFont(), defaultTextColor));
    // create contrast with background, should also specify border style
    // specify title for turnout, sensor, light, mixed? (wait for the Editor to be created)
    switchboardLayeredPane.addMouseMotionListener(this);
    //Add control pane and layered pane to this JPanel
    JPanel beanSetupPane = new JPanel();
    beanSetupPane.setLayout(new FlowLayout(FlowLayout.TRAILING));
    JLabel beanTypeTitle = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("BeanTypeLabel")));
    beanSetupPane.add(beanTypeTitle);
    beanTypeList = new JComboBox(beanTypeStrings);
    // select Turnout in comboBox
    beanTypeList.setSelectedIndex(0);
    beanTypeList.setActionCommand(LAYER_COMMAND);
    beanTypeList.addActionListener(this);
    beanSetupPane.add(beanTypeList);
    //Add connection selection comboBox
    // translate from selectedIndex to char
    beanTypeChar = getSwitchType().charAt(0);
    log.debug("beanTypeChar set to [{}]", beanTypeChar);
    JLabel beanManuTitle = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("ConnectionLabel")));
    beanSetupPane.add(beanManuTitle);
    beanManuNames = new JComboBox();
    if (getManager(beanTypeChar) instanceof jmri.managers.AbstractProxyManager) {
        // from abstractTableTabAction
        jmri.managers.AbstractProxyManager proxy = (jmri.managers.AbstractProxyManager) getManager(beanTypeChar);
        List<jmri.Manager> managerList = proxy.getManagerList();
        for (int x = 0; x < managerList.size(); x++) {
            String manuPrefix = managerList.get(x).getSystemPrefix();
            log.debug("Prefix = [{}]", manuPrefix);
            String manuName = ConnectionNameFromSystemName.getConnectionName(manuPrefix);
            log.debug("Connection name = [{}]", manuName);
            // add to comboBox
            beanManuNames.addItem(manuName);
            // add to list
            beanManuPrefixes.add(manuPrefix);
        }
    } else {
        String manuPrefix = getManager(beanTypeChar).getSystemPrefix();
        String manuName = ConnectionNameFromSystemName.getConnectionName(manuPrefix);
        beanManuNames.addItem(manuName);
        // add to list (as only item)
        beanManuPrefixes.add(manuPrefix);
    }
    beanManuNames.setSelectedIndex(0);
    beanManuNames.setActionCommand(MANU_COMMAND);
    beanManuNames.addActionListener(this);
    beanSetupPane.add(beanManuNames);
    add(beanSetupPane);
    // add shape combobox
    JPanel switchShapePane = new JPanel();
    switchShapePane.setLayout(new FlowLayout(FlowLayout.TRAILING));
    JLabel switchShapeTitle = new JLabel(Bundle.getMessage("MakeLabel", Bundle.getMessage("SwitchShape")));
    switchShapePane.add(switchShapeTitle);
    switchShapeList = new JComboBox(switchShapeStrings);
    // select Button in comboBox
    switchShapeList.setSelectedIndex(0);
    switchShapeList.setActionCommand(SWITCHTYPE_COMMAND);
    switchShapeList.addActionListener(this);
    switchShapePane.add(switchShapeList);
    // add column spinner
    JLabel columnLabel = new JLabel(Bundle.getMessage("NumberOfColumns"));
    switchShapePane.add(columnLabel);
    switchShapePane.add(Columns);
    add(switchShapePane);
    JCheckBox hideUnconnected = new JCheckBox(Bundle.getMessage("CheckBoxHideUnconnected"));
    hideUnconnected.setSelected(hideUnconnected());
    hideUnconnected.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            setHideUnconnected(hideUnconnected.isSelected());
        }
    });
    add(hideUnconnected);
    // Next, add the buttons to the layered pane.
    switchboardLayeredPane.setLayout(new GridLayout(java.lang.Math.max(2, _range % ((Integer) Columns.getValue())), (Integer) Columns.getValue()));
    // vertical (at least 2 rows), horizontal
    // TODO do some calculation from JPanel size, icon size and determine optimal cols/rows
    addSwitchRange((Integer) minSpinner.getValue(), (Integer) maxSpinner.getValue(), beanTypeList.getSelectedIndex(), beanManuPrefixes.get(beanManuNames.getSelectedIndex()), switchShapeList.getSelectedIndex());
    // provide a JLayeredPane to place the switches on
    super.setTargetPanel(switchboardLayeredPane, makeFrame(name));
    // width x height
    super.getTargetFrame().setSize(550, 330);
    // To do: Add component listener to handle frame resizing event
    // set scrollbar initial state
    setScroll(SCROLL_NONE);
    scrollNone.setSelected(true);
    super.setDefaultToolTip(new ToolTip(null, 0, 0, new Font("Serif", Font.PLAIN, 12), Color.black, new Color(255, 250, 210), Color.black));
    // register the resulting panel for later configuration
    ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
    if (cm != null) {
        cm.registerUser(this);
    }
    add(createControlPanel());
    JPanel updatePanel = new JPanel();
    JButton updateButton = new JButton(Bundle.getMessage("ButtonUpdate"));
    updateButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            log.debug("Update clicked");
            updatePressed();
        }
    });
    updatePanel.add(updateButton);
    contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
    contentPane.add(updatePanel);
    //re-layout all the toolbar items
    setupToolBar();
    // refresh default Switchboard
    updatePressed();
    pack();
    setVisible(true);
// TODO choose your own icons
//        class makeCatalog extends SwingWorker<CatalogPanel, Object> {
//
//            @Override
//            public CatalogPanel doInBackground() {
//                return CatalogPanel.makeDefaultCatalog();
//            }
//        }
//        (new makeCatalog()).execute();
//        log.debug("Init SwingWorker launched");
}
Also used : ToolTip(jmri.jmrit.display.ToolTip) JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) ActionEvent(java.awt.event.ActionEvent) BoxLayout(javax.swing.BoxLayout) JButton(javax.swing.JButton) InstanceManager(jmri.InstanceManager) ConfigureManager(jmri.ConfigureManager) Manager(jmri.Manager) Font(java.awt.Font) Container(java.awt.Container) GridLayout(java.awt.GridLayout) ConfigureManager(jmri.ConfigureManager) JComboBox(javax.swing.JComboBox) Color(java.awt.Color) JLabel(javax.swing.JLabel) Dimension(java.awt.Dimension) JCheckBox(javax.swing.JCheckBox) ActionListener(java.awt.event.ActionListener) JMenuBar(javax.swing.JMenuBar)

Aggregations

GridLayout (java.awt.GridLayout)189 JPanel (javax.swing.JPanel)149 JLabel (javax.swing.JLabel)79 BorderLayout (java.awt.BorderLayout)67 Dimension (java.awt.Dimension)51 JButton (javax.swing.JButton)41 ActionEvent (java.awt.event.ActionEvent)36 JScrollPane (javax.swing.JScrollPane)34 ActionListener (java.awt.event.ActionListener)32 Insets (java.awt.Insets)28 JCheckBox (javax.swing.JCheckBox)28 JTextField (javax.swing.JTextField)28 GridBagConstraints (java.awt.GridBagConstraints)24 GridBagLayout (java.awt.GridBagLayout)23 ButtonGroup (javax.swing.ButtonGroup)22 FlowLayout (java.awt.FlowLayout)21 BoxLayout (javax.swing.BoxLayout)21 TitledBorder (javax.swing.border.TitledBorder)19 PlotCanvas (smile.plot.PlotCanvas)16 EmptyBorder (javax.swing.border.EmptyBorder)15