List of usage examples for javax.swing JLabel setDisplayedMnemonic
public void setDisplayedMnemonic(char aChar)
From source file:TextForm.java
public TextForm(String[] labels, char[] mnemonics, int[] widths, String[] tips) { super(new BorderLayout()); JPanel labelPanel = new JPanel(new GridLayout(labels.length, 1)); JPanel fieldPanel = new JPanel(new GridLayout(labels.length, 1)); add(labelPanel, BorderLayout.WEST); add(fieldPanel, BorderLayout.CENTER); fields = new JTextField[labels.length]; for (int i = 0; i < labels.length; i += 1) { fields[i] = new JTextField(); if (i < tips.length) fields[i].setToolTipText(tips[i]); if (i < widths.length) fields[i].setColumns(widths[i]); JLabel lab = new JLabel(labels[i], JLabel.RIGHT); lab.setLabelFor(fields[i]);/*from w w w .j av a 2 s . com*/ if (i < mnemonics.length) lab.setDisplayedMnemonic(mnemonics[i]); labelPanel.add(lab); JPanel p = new JPanel(new FlowLayout(FlowLayout.LEFT)); p.add(fields[i]); fieldPanel.add(p); } }
From source file:Main.java
public Main() throws HeadlessException { setSize(400, 200);//from w w w.j a v a2 s . co m setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLayout(new FlowLayout(FlowLayout.LEFT)); JLabel usernameLabel = new JLabel("Username: "); JLabel passwordLabel = new JLabel("Password: "); JTextField usernameField = new JTextField(20); JPasswordField passwordField = new JPasswordField(20); usernameLabel.setDisplayedMnemonic(KeyEvent.VK_U); usernameLabel.setLabelFor(usernameField); passwordLabel.setDisplayedMnemonic(KeyEvent.VK_P); passwordLabel.setLabelFor(passwordField); getContentPane().add(usernameLabel); getContentPane().add(usernameField); getContentPane().add(passwordLabel); getContentPane().add(passwordField); }
From source file:bazaar4idea.ui.BzrPushDialog.java
/** Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * @noinspection ALL//www . j a v a 2s. c om */ private void $$$setupUI$$$() { contentPanel = new JPanel(); contentPanel.setLayout(new GridLayoutManager(1, 1, new Insets(0, 0, 0, 0), -1, -1)); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(5, 1, new Insets(0, 0, 0, 0), -1, -1)); contentPanel.add(panel1, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); panel1.add(spacer1, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("Destination Repository URL:"); label1.setDisplayedMnemonic('D'); label1.setDisplayedMnemonicIndex(0); panel1.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); repositoryTxt = new JTextField(); panel1.add(repositoryTxt, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel panel2 = new JPanel(); panel2.setLayout(new GridLayoutManager(2, 2, new Insets(0, 0, 0, 0), -1, -1)); panel1.add(panel2, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, new Dimension(-1, 100), null, null, 0, false)); panel2.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Options")); revisionCbx = new JCheckBox(); revisionCbx.setText("Revision"); revisionCbx.setMnemonic('R'); revisionCbx.setDisplayedMnemonicIndex(0); panel2.add(revisionCbx, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); revisionTxt = new JTextField(); revisionTxt.setEnabled(false); revisionTxt.setText("tip"); panel2.add(revisionTxt, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); final Spacer spacer2 = new Spacer(); panel2.add(spacer2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_VERTICAL, 1, GridConstraints.SIZEPOLICY_WANT_GROW, null, null, null, 0, false)); final Spacer spacer3 = new Spacer(); panel2.add(spacer3, new GridConstraints(1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); hgRepositorySelectorComponent = new BzrRepositorySelectorComponent(); panel1.add(hgRepositorySelectorComponent.$$$getRootComponent$$$(), new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); label1.setLabelFor(repositoryTxt); }
From source file:net.vanosten.dings.swing.SummaryView.java
private void initializeChartPropertiesPanel() { chartPropertiesP = new JPanel(); GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); chartPropertiesP.setLayout(gbl);/*from w ww . jav a2s.co m*/ TitledBorder title; title = BorderFactory.createTitledBorder("Chart Properties"); chartPropertiesP.setBorder(title); JLabel typeL = new JLabel("Chart Type:"); typeL.setDisplayedMnemonic("C".charAt(0)); typeL.setLabelFor(chartTypeCB); JLabel emptyL = new JLabel(); Insets vghg = new Insets(DingsSwingConstants.SP_V_G, DingsSwingConstants.SP_H_G, 0, 0); //----type gbc.gridwidth = 1; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.LINE_END; gbc.insets = vghg; gbl.setConstraints(typeL, gbc); chartPropertiesP.add(typeL); //---- gbc.gridx = 1; gbc.anchor = GridBagConstraints.LINE_START; gbl.setConstraints(chartTypeCB, gbc); chartPropertiesP.add(chartTypeCB); //---- gbc.gridx = 2; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; gbl.setConstraints(emptyL, gbc); chartPropertiesP.add(emptyL); //----chosen gbc.gridx = 1; gbc.gridy = 1; gbc.weightx = 0.0; gbc.fill = GridBagConstraints.NONE; gbl.setConstraints(chosenCB, gbc); chartPropertiesP.add(chosenCB); }
From source file:com.atlassian.theplugin.idea.config.serverconfig.GenericServerConfigForm.java
/** * Method generated by IntelliJ IDEA GUI Designer * >>> IMPORTANT!! <<< * DO NOT edit this method OR call it in your code! * * @noinspection ALL// w w w . ja va 2 s . c o m */ private void $$$setupUI$$$() { rootComponent = new JPanel(); rootComponent.setLayout(new GridBagLayout()); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(7, 3, new Insets(0, 0, 0, 0), -1, -1)); GridBagConstraints gbc; gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.BOTH; rootComponent.add(panel1, gbc); serverName = new JTextField(); serverName.setText(""); panel1.add(serverName, new GridConstraints(1, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); final JLabel label1 = new JLabel(); label1.setHorizontalAlignment(4); label1.setHorizontalTextPosition(4); label1.setText("Server Name:"); label1.setDisplayedMnemonic('S'); label1.setDisplayedMnemonicIndex(0); panel1.add(label1, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(80, -1), new Dimension(92, 16), null, 0, false)); serverUrl = new JTextField(); panel1.add(serverUrl, new GridConstraints(2, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); username = new JTextField(); panel1.add(username, new GridConstraints(3, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); password = new JPasswordField(); panel1.add(password, new GridConstraints(4, 1, 1, 2, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(150, -1), null, 0, false)); final JLabel label2 = new JLabel(); label2.setHorizontalAlignment(4); label2.setText("Server URL:"); label2.setDisplayedMnemonic('U'); label2.setDisplayedMnemonicIndex(7); panel1.add(label2, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, new Dimension(80, -1), new Dimension(92, 16), null, 0, false)); final JLabel label3 = new JLabel(); label3.setHorizontalAlignment(4); label3.setText("Username:"); label3.setDisplayedMnemonic('N'); label3.setDisplayedMnemonicIndex(4); panel1.add(label3, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(92, 16), null, 0, false)); final JLabel label4 = new JLabel(); label4.setHorizontalAlignment(4); label4.setText("Password:"); label4.setDisplayedMnemonic('P'); label4.setDisplayedMnemonicIndex(0); panel1.add(label4, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(92, 16), null, 0, false)); testConnection = new JButton(); testConnection.setText("Test Connection"); testConnection.setMnemonic('T'); testConnection.setDisplayedMnemonicIndex(0); panel1.add(testConnection, new GridConstraints(5, 2, 1, 1, GridConstraints.ANCHOR_NORTHEAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); // chkPasswordRemember = new JCheckBox(); // chkPasswordRemember.setSelected(true); // chkPasswordRemember.setText("Remember Password"); // chkPasswordRemember.setMnemonic('R'); // chkPasswordRemember.setDisplayedMnemonicIndex(0); // panel1.add(chkPasswordRemember, new GridConstraints(5, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, // GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, // null, null, null, 0, false)); cbEnabled = new JCheckBox(); cbEnabled.setEnabled(false); cbEnabled.setHorizontalTextPosition(11); cbEnabled.setText("Server Enabled"); cbEnabled.setMnemonic('E'); cbEnabled.setDisplayedMnemonicIndex(7); panel1.add(cbEnabled, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(115, 25), null, 0, false)); useDefault = new JCheckBox(); useDefault.setText("Use Default Credentials"); panel1.add(useDefault, new GridConstraints(6, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JPanel spacer1 = new JPanel(); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.VERTICAL; rootComponent.add(spacer1, gbc); label1.setLabelFor(serverName); label2.setLabelFor(serverUrl); label3.setLabelFor(username); label4.setLabelFor(password); }
From source file:adams.gui.tools.TelnetPanel.java
/** * For initializing the GUI./*from w w w . j ava 2 s.c o m*/ */ @Override protected void initGUI() { JPanel topPanel; JPanel bottomPanel; JLabel label; super.initGUI(); setLayout(new BorderLayout()); // connection topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); add(topPanel, BorderLayout.NORTH); m_TextRemote = new BaseTextField(20); label = new JLabel("Remote"); label.setDisplayedMnemonic('R'); label.setLabelFor(m_TextRemote); topPanel.add(label); topPanel.add(m_TextRemote); m_PortModel = new SpinnerNumberModel(); m_PortModel.setMinimum(1); m_PortModel.setMaximum(65536); m_PortModel.setStepSize(1); m_PortModel.setValue(23); m_SpinnerPort = new JSpinner(m_PortModel); label = new JLabel("Port"); label.setDisplayedMnemonic('P'); label.setLabelFor(m_SpinnerPort); topPanel.add(label); topPanel.add(m_SpinnerPort); m_ButtonConnection = new BaseButton(); m_ButtonConnection.setMnemonic('n'); m_ButtonConnection.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { handleConnectionEvent(); } }); topPanel.add(m_ButtonConnection); // output m_ButtonClear = new BaseButton("Clear", GUIHelper.getIcon("new.gif")); m_ButtonClear.setMnemonic('l'); m_ButtonClear.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { m_TextOutput.setText(""); } }); m_ButtonCopy = new BaseButton("Copy", GUIHelper.getIcon("copy.gif")); m_ButtonCopy.setMnemonic('C'); m_ButtonCopy.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (m_TextOutput.getSelectedText().length() > 0) ClipboardHelper.copyToClipboard(m_TextOutput.getSelectedText()); else if (m_TextOutput.getText().length() > 0) ClipboardHelper.copyToClipboard(m_TextOutput.getText()); } }); m_TextOutput = new BaseTextAreaWithButtons(10, 40); m_TextOutput.setTextFont(Fonts.getMonospacedFont()); m_TextOutput.addToButtonsPanel(m_ButtonClear); m_TextOutput.addToButtonsPanel(m_ButtonCopy); add(m_TextOutput, BorderLayout.CENTER); // commands bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); add(bottomPanel, BorderLayout.SOUTH); m_TextCommand = new BaseTextField(40); m_TextCommand.setFont(Fonts.getMonospacedFont()); m_TextCommand.addKeyListener(new KeyListener() { @Override public void keyTyped(KeyEvent e) { } @Override public void keyReleased(KeyEvent e) { } @Override public void keyPressed(KeyEvent e) { switch (e.getKeyCode()) { case KeyEvent.VK_ENTER: e.consume(); execCommand(); break; case KeyEvent.VK_UP: e.consume(); previousCommand(); break; case KeyEvent.VK_DOWN: e.consume(); nextCommand(); break; } } }); label = new JLabel("Command"); label.setDisplayedMnemonic('m'); label.setLabelFor(m_TextCommand); bottomPanel.add(label); bottomPanel.add(m_TextCommand); m_ButtonCommand = new BaseButton(GUIHelper.getIcon("run.gif")); m_ButtonCommand.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { execCommand(); } }); bottomPanel.add(m_ButtonCommand); }
From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java
/** * This method initializes jPanelUserInfo * /*from w ww .j av a 2 s. c om*/ * @return javax.swing.JPanel */ private JPanel getJPanelUserInfo() { if (jPanelUserInfo == null) { jPanelUserInfo = new JPanel(); jPanelUserInfo.setLayout(new GridBagLayout()); // User ID JLabel jLabelUser = new JLabel("User ID:"); jLabelUser.setHorizontalAlignment(SwingConstants.RIGHT); jLabelUser.setText("User ID :"); jLabelUser.setEnabled(true); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridy = 0; gridBagConstraints.gridx = 0; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new Insets(0, 10, 0, 0); jPanelUserInfo.add(jLabelUser, gridBagConstraints); GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.fill = GridBagConstraints.BOTH; gridBagConstraints1.gridy = 0; gridBagConstraints1.gridx = 1; gridBagConstraints1.weightx = 1.0; gridBagConstraints1.insets = new Insets(5, 5, 5, 5); jPanelUserInfo.add(getJTextFieldUser(), gridBagConstraints1); // Password JLabel jLabelPwd = new JLabel(); jLabelPwd.setText("Password :"); jLabelPwd.setHorizontalAlignment(SwingConstants.RIGHT); GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.gridy = 1; gridBagConstraints2.gridx = 0; gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints2.insets = new Insets(0, 10, 0, 0); jPanelUserInfo.add(jLabelPwd, gridBagConstraints2); GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.fill = GridBagConstraints.BOTH; gridBagConstraints3.gridy = 1; gridBagConstraints3.gridx = 1; gridBagConstraints3.weightx = 1.0; gridBagConstraints3.insets = new Insets(5, 5, 5, 5); jPanelUserInfo.add(getJPasswordField(), gridBagConstraints3); // Protex Server IP JLabel jLabelServer = new JLabel(); jLabelServer.setText("Protex Server IP :"); jLabelServer.setHorizontalAlignment(SwingConstants.RIGHT); jLabelServer.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED); GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.gridy = 2; gridBagConstraints11.gridx = 0; gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints11.insets = new Insets(0, 10, 5, 0); jPanelUserInfo.add(jLabelServer, gridBagConstraints11); GridBagConstraints gridBagConstraints21 = new GridBagConstraints(); gridBagConstraints21.gridy = 2; gridBagConstraints21.gridx = 1; gridBagConstraints21.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints21.insets = new Insets(5, 5, 10, 5); jPanelUserInfo.add(getJTextFieldServerIP(), gridBagConstraints21); } return jPanelUserInfo; }
From source file:com.sec.ose.osi.ui.frm.login.JPanLogin.java
private JPanel getJPanelProxyInfo() { if (jPanelProxyInfo == null) { jPanelProxyInfo = new JPanel(); jPanelProxyInfo.setLayout(new GridBagLayout()); // Proxy Host JLabel jLabelProxyHost = new JLabel("Proxy Host :"); jLabelProxyHost.setHorizontalAlignment(SwingConstants.RIGHT); GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.gridy = 0;//from ww w . ja v a2 s. co m gridBagConstraints.gridx = 0; gridBagConstraints.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints.insets = new Insets(0, 10, 0, 0); jPanelProxyInfo.add(jLabelProxyHost, gridBagConstraints); GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.fill = GridBagConstraints.BOTH; gridBagConstraints1.gridy = 0; gridBagConstraints1.gridx = 1; gridBagConstraints1.weightx = 0.5; gridBagConstraints1.insets = new Insets(5, 5, 5, 5); jPanelProxyInfo.add(getJTextProxyHost(), gridBagConstraints1); // Proxy Port JLabel jLabelProxyPort = new JLabel("Port :"); jLabelProxyPort.setHorizontalAlignment(SwingConstants.RIGHT); GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.gridy = 0; gridBagConstraints2.gridx = 2; gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints2.insets = new Insets(0, 10, 0, 0); jPanelProxyInfo.add(jLabelProxyPort, gridBagConstraints2); GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.fill = GridBagConstraints.BOTH; gridBagConstraints3.gridy = 0; gridBagConstraints3.gridx = 3; gridBagConstraints3.weightx = 0.5; gridBagConstraints3.insets = new Insets(5, 5, 5, 5); jPanelProxyInfo.add(getJTextProxyPort(), gridBagConstraints3); // Proxy Bypass JLabel jLabelProxyBypass = new JLabel(); jLabelProxyBypass.setText(" Proxy Bypass :"); jLabelProxyBypass.setHorizontalAlignment(SwingConstants.RIGHT); jLabelProxyBypass.setDisplayedMnemonic(KeyEvent.VK_UNDEFINED); GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); gridBagConstraints11.gridy = 1; gridBagConstraints11.gridx = 0; gridBagConstraints11.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints11.insets = new Insets(0, 10, 5, 0); jPanelProxyInfo.add(jLabelProxyBypass, gridBagConstraints11); GridBagConstraints gridBagConstraints21 = new GridBagConstraints(); gridBagConstraints21.gridy = 1; gridBagConstraints21.gridx = 1; gridBagConstraints21.gridwidth = 3; //gridBagConstraints21.weightx = 1.0; gridBagConstraints21.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints21.insets = new Insets(5, 5, 10, 5); jPanelProxyInfo.add(getJTextProxyBypass(), gridBagConstraints21); } return jPanelProxyInfo; }
From source file:net.java.sip.communicator.gui.AuthenticationSplash.java
/** * * We use dynamic layout managers, so that layout is dynamic and will * adapt properly to user-customized fonts and localized text. The * GridBagLayout makes it easy to line up components of varying * sizes along invisible vertical and horizontal grid lines. It * is important to sketch the layout of the interface and decide * on the grid before writing the layout code. * * Here we actually use/*w w w . j a va 2s . c o m*/ * our own subclass of GridBagLayout called StringGridBagLayout, * which allows us to use strings to specify constraints, rather * than having to create GridBagConstraints objects manually. * * * We use the JLabel.setLabelFor() method to connect * labels to what they are labeling. This allows mnemonics to work * and assistive to technologies used by persons with disabilities * to provide much more useful information to the user. */ private void initComponents(final Frame parent) { Container contents = getContentPane(); contents.setLayout(new BorderLayout()); String title = Utils.getProperty("net.java.sip.communicator.gui.AUTH_WIN_TITLE"); if (title == null) title = "Login Manager"; setTitle(title); setResizable(false); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent event) { dialogDone(CMD_CANCEL, parent); } }); // Accessibility -- all frames, dialogs, and applets should // have a description getAccessibleContext().setAccessibleDescription("Authentication Splash"); String authPromptLabelValue = Utils.getProperty("net.java.sip.communicator.gui.AUTHENTICATION_PROMPT"); if (authPromptLabelValue == null) authPromptLabelValue = "Please register to the service or enter your credentials to log in:"; JLabel splashLabel = new JLabel(authPromptLabelValue); splashLabel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); splashLabel.setHorizontalAlignment(SwingConstants.CENTER); splashLabel.setHorizontalTextPosition(SwingConstants.CENTER); contents.add(splashLabel, BorderLayout.NORTH); JPanel centerPane = new JPanel(); centerPane.setLayout(new GridBagLayout()); userNameTextField = new JTextField(); // needed below // user name label JLabel userNameLabel = new JLabel(); userNameLabel.setDisplayedMnemonic('U'); // setLabelFor() allows the mnemonic to work userNameLabel.setLabelFor(userNameTextField); String userNameLabelValue = Utils.getProperty("net.java.sip.communicator.gui.USER_NAME_LABEL"); if (userNameLabelValue == null) userNameLabelValue = "Username"; int gridy = 0; userNameLabel.setText(userNameLabelValue); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(12, 12, 0, 0); centerPane.add(userNameLabel, c); // user name text c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(12, 7, 0, 11); centerPane.add(userNameTextField, c); passwordTextField = new JPasswordField(); //needed below // password label JLabel passwordLabel = new JLabel(); passwordLabel.setDisplayedMnemonic('P'); passwordLabel.setLabelFor(passwordTextField); String pLabelStr = PropertiesDepot.getProperty("net.java.sip.communicator.gui.PASSWORD_LABEL"); if (pLabelStr == null) pLabelStr = "Password"; passwordLabel.setText(pLabelStr); c = new GridBagConstraints(); c.gridx = 0; c.gridy = gridy; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(11, 12, 0, 0); centerPane.add(passwordLabel, c); // password text passwordTextField.setEchoChar('\u2022'); c = new GridBagConstraints(); c.gridx = 1; c.gridy = gridy++; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(11, 7, 0, 11); centerPane.add(passwordTextField, c); //Set a relevant realm value //Bug report by Steven Lass (sltemp at comcast.net) //JLabel realmValueLabel = new JLabel("SipPhone.com"); // needed below // realm label JLabel realmLabel = new JLabel(); realmLabel.setDisplayedMnemonic('R'); realmLabel.setLabelFor(realmValueLabel); realmLabel.setText("Realm"); realmValueLabel = new JLabel(); // Buttons along bottom of window JPanel buttonPanel = new JPanel(); buttonPanel.setLayout(new BoxLayout(buttonPanel, 0)); loginButton = new JButton(); loginButton.setText("Login"); loginButton.setActionCommand(CMD_LOGIN); loginButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dialogDone(event, parent); } }); buttonPanel.add(loginButton); // space buttonPanel.add(Box.createRigidArea(new Dimension(5, 0))); registerButton = new JButton(); registerButton.setMnemonic('G'); registerButton.setText("Register"); registerButton.setActionCommand(CMD_REGISTER); registerButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dialogDone(event, parent); } }); buttonPanel.add(registerButton); buttonPanel.add(Box.createRigidArea(new Dimension(5, 0))); cancelButton = new JButton(); cancelButton.setText("Cancel"); cancelButton.setActionCommand(CMD_CANCEL); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { dialogDone(event, parent); } }); buttonPanel.add(cancelButton); c = new GridBagConstraints(); c.gridx = 0; c.gridy = 3; c.gridwidth = 2; c.insets = new Insets(11, 12, 11, 11); centerPane.add(buttonPanel, c); contents.add(centerPane, BorderLayout.CENTER); getRootPane().setDefaultButton(loginButton); equalizeButtonSizes(); setFocusTraversalPolicy(new FocusTraversalPol()); }
From source file:com.eviware.soapui.support.components.SimpleForm.java
private <T extends JComponent> T append(String name, JComponent label, T component, String alignments, int column, int columnSpan) { int spaceRowIndex = -1; if (rowSpacing > 0 && appended) { addSpace(rowSpacing);// ww w. j a v a2s .c o m spaceRowIndex = layout.getRowCount(); } layout.appendRow(rowSpec); int row = layout.getRowCount(); if (label != null) { panel.add(label, cc.xy(DEFAULT_LABEL_COLUMN, row)); component.addComponentListener(new LabelHider(label, spaceRowIndex)); component.addPropertyChangeListener(ENABLED_PROPERTY_NAME, new LabelEnabler(label)); if (label instanceof JLabel) { JLabel jl = ((JLabel) label); jl.setLabelFor(component); String text = jl.getText(); int ix = text.indexOf('&'); if (ix >= 0) { jl.setText(text.substring(0, ix) + text.substring(ix + 1)); jl.setDisplayedMnemonicIndex(ix); jl.setDisplayedMnemonic(text.charAt(ix + 1)); } if (component.getAccessibleContext() != null) { component.getAccessibleContext().setAccessibleName(text); } } } else { component.addComponentListener(new LabelHider(null, spaceRowIndex)); } addComponentToRow(name, component, alignments, column, row, columnSpan); return component; }