List of usage examples for java.awt GridBagConstraints REMAINDER
int REMAINDER
To view the source code for java.awt GridBagConstraints REMAINDER.
Click Source Link
From source file:org.intermine.install.swing.source.SourcePanel.java
/** * Common initialisation: lays out the child components and wires up the necessary * event listeners. /*from ww w . jav a2s. c om*/ */ private void init() { typeField.setEditable(false); nameField.setEnabled(false); typeField.setEnabled(false); dumpCheck.setEnabled(false); GridBagConstraints cons = GridBagHelper.setup(this); add(new JLabel(Messages.getMessage("source.name")), cons); cons.gridy++; add(new JLabel(Messages.getMessage("source.type")), cons); cons.gridy++; add(new JLabel(Messages.getMessage("source.dump")), cons); cons.gridx++; cons.gridy = 0; cons.gridwidth = GridBagConstraints.REMAINDER; cons.weightx = 1.0; add(nameField, cons); cons.gridy++; add(typeField, cons); cons.gridy++; add(dumpCheck, cons); cons.gridy++; cons.gridx = 0; cons.weighty = 1.0; cons.fill = GridBagConstraints.BOTH; add(new JScrollPane(propertiesPanel), cons); nameField.setEnabled(false); typeField.setEnabled(false); dumpCheck.setEnabled(false); }
From source file:org.executequery.gui.browser.SSHTunnelConnectionPanel.java
private void init() throws IOException { hostField = new DisabledField(); userNameField = WidgetFactory.createTextField(); passwordField = WidgetFactory.createPasswordField(); portField = WidgetFactory.createNumberTextField(); mainPanel = new TextFieldPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(10, 10, 10, 10); gbc.gridy = 0;/*w ww. j a v a 2 s . co m*/ gbc.gridx = 0; gbc.insets.bottom = 5; gbc.gridwidth = GridBagConstraints.REMAINDER; mainPanel.add(new DefaultFieldLabel( FileUtils.loadResource("org/executequery/gui/browser/resource/ssh-tunnel.html")), gbc); addLabelFieldPair(mainPanel, "SSH Host:", hostField, "The SSH host server for the tunnel", gbc); addLabelFieldPair(mainPanel, "SSH Port:", portField, "The SSH server port", gbc); addLabelFieldPair(mainPanel, "SSH User Name:", userNameField, "The SSH user name for the tunnel", gbc); addLabelFieldPair(mainPanel, "SSH Password:", passwordField, "The SSH user password for the tunnel", gbc); savePwdCheck = ActionUtilities.createCheckBox("Store Password", "setStorePassword"); JButton showPassword = new LinkButton("Show Password"); showPassword.setActionCommand("showPassword"); showPassword.addActionListener(this); JPanel passwordOptionsPanel = new JPanel(new GridBagLayout()); addComponents(passwordOptionsPanel, new ComponentToolTipPair[] { new ComponentToolTipPair(savePwdCheck, "Store the password with the connection information"), new ComponentToolTipPair(showPassword, "Show the password in plain text") }); gbc.gridy++; gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; mainPanel.add(passwordOptionsPanel, gbc); JScrollPane scrollPane = new JScrollPane(mainPanel); scrollPane.setBorder(null); useSshCheckbox = ActionUtilities.createCheckBox(this, "Connect Using an SSH Tunnel", "useSshSelected"); ComponentTitledPanel titledPanel = new ComponentTitledPanel(useSshCheckbox); JPanel panel = titledPanel.getContentPane(); panel.setLayout(new BorderLayout()); panel.add(scrollPane, BorderLayout.CENTER); setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(titledPanel, BorderLayout.NORTH); }
From source file:width.java
public void init() { GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); setLayout(gridBag);/* w w w .j av a2 s . c o m*/ Label receiverLabel = new Label("Receiver name:", Label.RIGHT); gridBag.setConstraints(receiverLabel, c); add(receiverLabel); nameField = new TextField(getParameter("RECEIVERNAME"), 10); c.fill = GridBagConstraints.HORIZONTAL; gridBag.setConstraints(nameField, c); add(nameField); nameField.addActionListener(this); Button button = new Button("Send message"); c.gridwidth = GridBagConstraints.REMAINDER; //end row c.anchor = GridBagConstraints.WEST; //stick to the //text field c.fill = GridBagConstraints.NONE; //keep the button //small gridBag.setConstraints(button, c); add(button); button.addActionListener(this); status = new TextArea(5, 60); status.setEditable(false); c.anchor = GridBagConstraints.CENTER; //reset to the default c.fill = GridBagConstraints.BOTH; //make this big c.weightx = 1.0; c.weighty = 1.0; gridBag.setConstraints(status, c); add(status); myName = getParameter("NAME"); Label senderLabel = new Label("(My name is " + myName + ".)", Label.CENTER); c.weightx = 0.0; c.weighty = 0.0; gridBag.setConstraints(senderLabel, c); add(senderLabel); newline = System.getProperty("line.separator"); }
From source file:events.FocusEventDemo.java
public void addComponentsToPane(final Container pane) { GridBagLayout gridbag = new GridBagLayout(); pane.setLayout(gridbag);/*w w w .j a va2 s .c om*/ GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; //Make column as wide as possible. JTextField textField = new JTextField("A TextField"); textField.setMargin(new Insets(0, 2, 0, 2)); textField.addFocusListener(this); gridbag.setConstraints(textField, c); add(textField); c.weightx = 0.1; //Widen every other column a bit, when possible. c.fill = GridBagConstraints.NONE; JLabel label = new JLabel("A Label"); label.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); label.addFocusListener(this); gridbag.setConstraints(label, c); add(label); String comboPrefix = "ComboBox Item #"; final int numItems = 15; Vector<String> vector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { vector.addElement(comboPrefix + i); } JComboBox comboBox = new JComboBox(vector); comboBox.addFocusListener(this); gridbag.setConstraints(comboBox, c); add(comboBox); c.gridwidth = GridBagConstraints.REMAINDER; JButton button = new JButton("A Button"); button.addFocusListener(this); gridbag.setConstraints(button, c); add(button); c.weightx = 0.0; c.weighty = 0.1; c.fill = GridBagConstraints.BOTH; String listPrefix = "List Item #"; Vector<String> listVector = new Vector<String>(numItems); for (int i = 0; i < numItems; i++) { listVector.addElement(listPrefix + i); } JList list = new JList(listVector); list.setSelectedIndex(1); //It's easier to see the focus change //if an item is selected. list.addFocusListener(this); JScrollPane listScrollPane = new JScrollPane(list); gridbag.setConstraints(listScrollPane, c); add(listScrollPane); c.weighty = 1.0; //Make this row as tall as possible. c.gridheight = GridBagConstraints.REMAINDER; //Set up the area that reports focus-gained and focus-lost events. display = new JTextArea(); display.setEditable(false); //The setRequestFocusEnabled method prevents a //component from being clickable, but it can still //get the focus through the keyboard - this ensures //user accessibility. display.setRequestFocusEnabled(false); display.addFocusListener(this); JScrollPane displayScrollPane = new JScrollPane(display); gridbag.setConstraints(displayScrollPane, c); add(displayScrollPane); setPreferredSize(new Dimension(450, 450)); ((JPanel) pane).setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:pipeline.parameter_cell_views.FloatSlider.java
public FloatSlider() { super();/*from w ww . ja v a 2s . co m*/ addMouseWheelListener(e -> { int rotation = e.getWheelRotation(); float change = (maximum - minimum) * 0.001f * rotation * Utils.getMouseWheelClickFactor(); currentValue += change; if (!((e.getModifiers() & java.awt.event.InputEvent.ALT_MASK) > 0)) { if (currentValue > maximum) currentValue = maximum; if (currentValue < minimum) currentValue = minimum; } currentParameter.setValue(new float[] { currentValue, minimum, maximum }); updateParameterValues(); currentParameter.fireValueChanged(false, false, true); }); nf.setMaximumFractionDigits(5); nf.setMaximumIntegerDigits(8); nf.setGroupingUsed(false); setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; c.gridheight = 1; c.ipady = 10; parameterName = new JLabel(""); slider = new JSlider(0, 50, 10); slider.addChangeListener(new sliderListener()); c.gridx = 0; c.gridy = 0; c.weighty = 1.0; c.weightx = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; add(slider, c); c.gridwidth = 1; c.ipady = 0; currentTextValue = new JTextField(slider.getValue()); currentTextValue.addActionListener(new valueListener()); Font smallerFont = new Font(currentTextValue.getFont().getName(), currentTextValue.getFont().getStyle(), currentTextValue.getFont().getSize() - 2); textMinimum = new JTextField("0"); textMinimum.setFont(smallerFont); textMinimum.addActionListener(new minimumListener()); textMaximum = new JTextField("50"); textMaximum.setFont(smallerFont); textMaximum.addActionListener(new maximumListener()); c.gridx = 0; c.gridy = 1; c.weighty = 1.0; c.weightx = 0.25; add(textMinimum, c); c.gridx = 2; c.gridy = 1; c.weighty = 1.0; c.weightx = 0.25; add(textMaximum, c); c.gridx = 1; c.gridy = 1; c.weighty = 1.0; c.weightx = 0.5; add(currentTextValue, c); parameterName = new JLabel("parameter"); c.gridx = 0; c.gridy = 2; c.weighty = 1.0; c.weightx = 0.0; c.gridwidth = 3; add(parameterName, c); }
From source file:Composite.java
public void init() { GridBagLayout layOut = new GridBagLayout(); getContentPane().setLayout(layOut);/* ww w. j a v a 2s . c o m*/ GridBagConstraints l = new GridBagConstraints(); l.weightx = 1.0; l.fill = GridBagConstraints.BOTH; l.gridwidth = GridBagConstraints.RELATIVE; alphaLabel = new JLabel(); alphaLabel.setText("Alphas"); Font newFont = getFont().deriveFont(1); alphaLabel.setFont(newFont); alphaLabel.setHorizontalAlignment(JLabel.CENTER); layOut.setConstraints(alphaLabel, l); getContentPane().add(alphaLabel); GridBagConstraints c = new GridBagConstraints(); getContentPane().setLayout(layOut); l.gridwidth = GridBagConstraints.REMAINDER; rulesLabel = new JLabel(); rulesLabel.setText("Rules"); newFont = getFont().deriveFont(1); rulesLabel.setFont(newFont); rulesLabel.setHorizontalAlignment(JLabel.CENTER); layOut.setConstraints(rulesLabel, l); getContentPane().add(rulesLabel); GridBagConstraints a = new GridBagConstraints(); a.gridwidth = GridBagConstraints.RELATIVE; a.weightx = 1.0; a.fill = GridBagConstraints.BOTH; alphas = new JComboBox(); layOut.setConstraints(alphas, a); alphas.addItem("1.0"); alphas.addItem("0.75"); alphas.addItem("0.50"); alphas.addItem("0.25"); alphas.addItem("0.0"); alphas.addItemListener(this); getContentPane().add(alphas); a.gridwidth = GridBagConstraints.REMAINDER; rules = new JComboBox(); layOut.setConstraints(rules, a); rules.addItem("SRC"); rules.addItem("DST_IN"); rules.addItem("DST_OUT"); rules.addItem("DST_OVER"); rules.addItem("SRC_IN"); rules.addItem("SRC_OVER"); rules.addItem("SRC_OUT"); rules.addItem("CLEAR"); rules.addItemListener(this); getContentPane().add(rules); GridBagConstraints fC = new GridBagConstraints(); fC.fill = GridBagConstraints.BOTH; fC.weightx = 1.0; fC.weighty = 1.0; fC.gridwidth = GridBagConstraints.REMAINDER; comp = new CompPanel(); layOut.setConstraints(comp, fC); getContentPane().add(comp); validate(); }
From source file:MessageViewer.java
/** * sets the current message to be displayed in the viewer *//*from w w w . j a va2 s . co m*/ public void setMessage(Message what) { displayed = what; if (mainbody != null) remove(mainbody); if (what != null) { loadHeaders(); mainbody = getBodyComponent(); } else { headers.setText(""); TextArea dummy = new TextArea("", 24, 80, TextArea.SCROLLBARS_NONE); dummy.setEditable(false); mainbody = dummy; } // add the main body GridBagConstraints gb = new GridBagConstraints(); gb.gridwidth = GridBagConstraints.REMAINDER; gb.fill = GridBagConstraints.BOTH; gb.weightx = 1.0; gb.weighty = 1.0; add(mainbody, gb); invalidate(); validate(); }
From source file:SimpleAuthenticator.java
protected PasswordAuthentication getPasswordAuthentication() { // given a prompt? String prompt = getRequestingPrompt(); if (prompt == null) prompt = "Please login..."; // protocol/*from w w w . j a v a2 s . co m*/ String protocol = getRequestingProtocol(); if (protocol == null) protocol = "Unknown protocol"; // get the host String host = null; InetAddress inet = getRequestingSite(); if (inet != null) host = inet.getHostName(); if (host == null) host = "Unknown host"; // port String port = ""; int portnum = getRequestingPort(); if (portnum != -1) port = ", port " + portnum + " "; // Build the info string String info = "Connecting to " + protocol + " mail service on host " + host + port; //JPanel d = new JPanel(); // XXX - for some reason using a JPanel here causes JOptionPane // to display incorrectly, so we workaround the problem using // an anonymous JComponent. JComponent d = new JComponent() { }; GridBagLayout gb = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); d.setLayout(gb); c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.WEST; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 0.0; d.add(constrain(new JLabel(info), gb, c)); d.add(constrain(new JLabel(prompt), gb, c)); c.gridwidth = 1; c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.NONE; c.weightx = 0.0; d.add(constrain(new JLabel("Username:"), gb, c)); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; String user = getDefaultUserName(); JTextField username = new JTextField(user, 20); d.add(constrain(username, gb, c)); c.gridwidth = 1; c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; c.weightx = 0.0; d.add(constrain(new JLabel("Password:"), gb, c)); c.anchor = GridBagConstraints.EAST; c.fill = GridBagConstraints.HORIZONTAL; c.gridwidth = GridBagConstraints.REMAINDER; c.weightx = 1.0; JPasswordField password = new JPasswordField("", 20); d.add(constrain(password, gb, c)); // XXX - following doesn't work if (user != null && user.length() > 0) password.requestFocus(); else username.requestFocus(); int result = JOptionPane.showConfirmDialog(frame, d, "Login", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.OK_OPTION) return new PasswordAuthentication(username.getText(), password.getText()); else return null; }
From source file:com.sshtools.sshterm.SshTermCommandTab.java
/** * Creates a new SshToolsConnectionCommandTab object. *//*from w w w . j a va2s . c o m*/ public SshTermCommandTab() { super(); JPanel main = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTH; gbc.insets = new Insets(0, 2, 2, 2); Insets ins2 = new Insets(2, 24, 2, 2); gbc.weightx = 1.0; requestPseudoTerminal.getModel().setSelected(false); disconnectOnSessionClose.getModel().setSelected(true); UIUtil.jGridBagAdd(main, requestPseudoTerminal, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, disconnectOnSessionClose, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, new JSeparator(JSeparator.HORIZONTAL), gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, onceAuthenticated, gbc, GridBagConstraints.REMAINDER); group.add(doNothing); group.add(startShell); group.add(executeCommands); startShell.setSelected(true); UIUtil.jGridBagAdd(main, doNothing, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, startShell, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, executeCommands, gbc, GridBagConstraints.REMAINDER); gbc.fill = GridBagConstraints.BOTH; gbc.insets = ins2; gbc.weighty = 1.0; //commands.setLineWrap(true); commands.setBorder(BorderFactory.createEtchedBorder()); JScrollPane scroll = new JScrollPane(commands); scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); scroll.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); UIUtil.jGridBagAdd(main, scroll, gbc, GridBagConstraints.REMAINDER); IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(COMMANDS_ICON), main); commands.setRows(8); // This panel setLayout(new BorderLayout()); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTH; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 1.0; add(iconProxyDetailsPanel, BorderLayout.NORTH); }
From source file:com.sshtools.common.ui.SshToolsConnectionKerberosTab.java
/** * Creates a new SshToolsConnectionKerberosTab object. *///from w w w . ja v a 2 s. c om public SshToolsConnectionKerberosTab() { super(); // Create the main connection details panel JPanel mainConnectionDetailsPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTHWEST; gbc.insets = new Insets(0, 2, 2, 2); // enabled option //gbc.fill = GridBagConstraints.NONE; useKerberos = new JCheckBox("Use MyProxy Kerberos support"); UIUtil.jGridBagAdd(mainConnectionDetailsPanel, useKerberos, gbc, GridBagConstraints.REMAINDER); // Host name UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Hostname"), gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextHostname, gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.NONE; // Username UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextUsername, gbc, GridBagConstraints.REMAINDER); JPanel settingsPanel = new JPanel(new GridBagLayout()); settingsPanel .setBorder(BorderFactory.createTitledBorder("Settings if krb5.conf or krb5.ini file not found: ")); GridBagConstraints gbc2 = new GridBagConstraints(); gbc2.fill = GridBagConstraints.HORIZONTAL; gbc2.anchor = GridBagConstraints.NORTHWEST; gbc2.insets = new Insets(0, 2, 2, 2); gbc2.weightx = 1.0; // realm UIUtil.jGridBagAdd(settingsPanel, new JLabel("Realm"), gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(settingsPanel, jTextRealm, gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.NONE; // kdc UIUtil.jGridBagAdd(settingsPanel, new JLabel("KDC"), gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.HORIZONTAL; gbc2.weighty = 1.0; UIUtil.jGridBagAdd(settingsPanel, jTextKDC, gbc2, GridBagConstraints.REMAINDER); gbc2.fill = GridBagConstraints.NONE; // gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.insets = new Insets(4, 2, 2, 2); UIUtil.jGridBagAdd(mainConnectionDetailsPanel, settingsPanel, gbc, GridBagConstraints.REMAINDER); IconWrapperPanel iconMainConnectionDetailsPanel = new IconWrapperPanel( new ResourceIcon(SshToolsConnectionHostTab.class, AUTH_ICON), mainConnectionDetailsPanel); setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 1.0; gbc.weighty = 1.0; UIUtil.jGridBagAdd(this, iconMainConnectionDetailsPanel, gbc, GridBagConstraints.REMAINDER); }