List of usage examples for java.awt GridBagLayout GridBagLayout
public GridBagLayout()
From source file:com.sshtools.common.ui.SshToolsConnectionKerberosTab.java
/** * Creates a new SshToolsConnectionKerberosTab object. *//*from w ww . j av 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); }
From source file:SimpleAuthenticator.java
protected PasswordAuthentication getPasswordAuthentication() { // given a prompt? String prompt = getRequestingPrompt(); if (prompt == null) prompt = "Please login..."; // protocol/*w w w . ja v a 2s . c om*/ 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:ModalMessage.java
/** * This method initializes jPanel /*from www . j a va2 s . com*/ * * @return javax.swing.JPanel */ private JPanel getJPanel() { if (jPanel == null) { GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.gridx = 0; // Generated gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; // Generated gridBagConstraints1.gridy = 1; // Generated GridBagConstraints gridBagConstraints = new GridBagConstraints(); gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; // Generated gridBagConstraints.gridy = 0; // Generated gridBagConstraints.weightx = 1.0; // Generated gridBagConstraints.weighty = 1.0; // Generated gridBagConstraints.insets = new java.awt.Insets(4, 4, 4, 4); // Generated gridBagConstraints.gridx = 0; // Generated jPanel = new JPanel(); jPanel.setLayout(new GridBagLayout()); // Generated jPanel.add(getJScrollPane(), gridBagConstraints); // Generated jPanel.add(getButtonPanel(), gridBagConstraints1); } return jPanel; }
From source file:com.sshtools.common.ui.OptionsPanel.java
/** * * * @param parent/* ww w.jav a 2s . c om*/ * @param tabs tabs * * @return */ public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) { final OptionsPanel opts = new OptionsPanel(tabs); opts.reset(); JDialog d = null; Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent); if (w instanceof JDialog) { d = new JDialog((JDialog) w, "Options", true); } else if (w instanceof JFrame) { d = new JDialog((JFrame) w, "Options", true); } else { d = new JDialog((JFrame) null, "Options", true); } final JDialog dialog = d; // Create the bottom button panel final JButton cancel = new JButton("Cancel"); cancel.setMnemonic('c'); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { opts.cancelled = true; dialog.setVisible(false); } }); final JButton ok = new JButton("Ok"); ok.setMnemonic('o'); ok.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (opts.validateTabs()) { dialog.setVisible(false); } } }); dialog.getRootPane().setDefaultButton(ok); JPanel buttonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(6, 6, 0, 0); gbc.weighty = 1.0; UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE); UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER); JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); southPanel.add(buttonPanel); // JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPanel.add(opts, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); // Show the dialog dialog.getContentPane().setLayout(new GridLayout(1, 1)); dialog.getContentPane().add(mainPanel); dialog.pack(); dialog.setResizable(true); UIUtil.positionComponent(SwingConstants.CENTER, dialog); dialog.setVisible(true); if (!opts.cancelled) { opts.applyTabs(); } return !opts.cancelled; }
From source file:de.codesourcery.jasm16.ide.ui.views.EmulationOptionsView.java
public EmulationOptionsView() { emulatorPanel.setLayout(new GridBagLayout()); GridBagConstraints cnstrs = constraints(0, 0, false, false, GridBagConstraints.NONE); emulatorPanel.add(new JLabel("Emulation speed"), cnstrs); cnstrs = constraints(1, 0, true, true, GridBagConstraints.NONE); cnstrs.anchor = GridBagConstraints.WEST; emulatorPanel.setBorder(BorderFactory.createTitledBorder("General options")); speedBox.setRenderer(new DefaultListCellRenderer() { public Component getListCellRendererComponent(javax.swing.JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) { final java.awt.Component result = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);//from ww w. j ava2s . c o m if (value != null) { switch ((EmulationSpeed) value) { case MAX_SPEED: setText("Max."); break; case REAL_SPEED: setText("100 kHz"); break; default: setText(value.toString()); break; } } return result; }; }); emulatorPanel.add(speedBox, cnstrs); // disk drive panel selectedFileField.setColumns(25); diskDrivePanel.setLayout(new GridBagLayout()); cnstrs = constraints(0, 0, false, true, GridBagConstraints.NONE); cnstrs.anchor = GridBagConstraints.CENTER; diskDrivePanel.setBorder(BorderFactory.createTitledBorder("Disk drive")); diskDrivePanel.add(selectedFileField, cnstrs); cnstrs = constraints(1, 0, false, true, GridBagConstraints.NONE); cnstrs.anchor = GridBagConstraints.CENTER; diskDrivePanel.add(fileChooserButton, cnstrs); fileChooserButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { final JFileChooser chooser; if (getSelectedFile() != null) { chooser = new JFileChooser(getSelectedFile().getParentFile()); } else { chooser = new JFileChooser(); } final int result = chooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION && chooser.getSelectedFile().isFile()) { selectedFileField.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); cnstrs = constraints(2, 0, false, true, GridBagConstraints.NONE); cnstrs.anchor = GridBagConstraints.CENTER; diskDrivePanel.add(writeProtected, cnstrs); }
From source file:org.fhcrc.cpl.viewer.quant.gui.PanelWithLogRatioHistAndFields.java
/** * Lay out GUI components, but NOT the histogram *///w ww. j av a 2s . c o m protected void initGUI() { setLayout(new GridBagLayout()); maxLowRatioLabel = new JLabel("Max Low Ratio: "); minHighRatioLabel = new JLabel("Min High Ratio: "); numPassingRatiosLabel = new JLabel("Retained: "); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.PAGE_START; gbc.insets = new Insets(0, 0, 0, 0); gbc.weighty = 0; gbc.weightx = 1; gbc.gridwidth = 1; add(maxLowRatioLabel, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; add(minHighRatioLabel, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(numPassingRatiosLabel, gbc); }
From source file:org.bench4Q.console.ui.section.R_RealSessionShowSection.java
/** * @param resources// w ww . j a va 2s. co m * @param processControl * @param agentsCollection * @throws ConsoleException */ public R_RealSessionShowSection(Resources resources, ProcessControl processControl, AgentsCollection agentsCollection) throws ConsoleException { m_resources = resources; m_processControl = processControl; m_agentsCollection = agentsCollection; m_agentsCollection.registerObserver(this); this.setLayout(new GridBagLayout()); this.setPreferredSize(new Dimension(683, 475)); this.setMinimumSize(new Dimension(683, 475)); testduring = -1; resultNumber = 0; picPanel = new PicPanel(); this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1)); }
From source file:Demo.ScatterGraph.java
public ScatterGraph(int sampleNb, List<String> paraType_list) { this.sampleNb = sampleNb; this.paraType_list = paraType_list; // widgets: charts(JFreeChart), parameter selectors (JList) DefaultListModel xModel = new DefaultListModel(); xSelector = new JList(xModel); JScrollPane xSelPane = new JScrollPane(); xSelPane.setViewportView(xSelector); DefaultListModel yModel = new DefaultListModel(); ySelector = new JList(yModel); JScrollPane ySelPane = new JScrollPane(); ySelPane.setViewportView(ySelector); charts = new JFreeChart[paraType_list.size()][paraType_list.size()]; for (int i = 0; i < paraType_list.size(); i++) { String para = paraType_list.get(i); xModel.addElement(para);//from w w w . j a va 2 s .c o m yModel.addElement(para); for (int j = 0; j < paraType_list.size(); j++) { charts[i][j] = null; } } charts[0][0] = CreateChart(0, 0); chartPane = new ChartPanel(charts[0][0]); xSelector.setSelectedIndex(0); ySelector.setSelectedIndex(0); xSelector.addMouseListener(this); ySelector.addMouseListener(this); // layout GridBagLayout layout = new GridBagLayout(); setLayout(layout); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.BOTH; gbc.insets = new Insets(5, 20, 5, 5); gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 20; gbc.weighty = 12; gbc.gridheight = 4; add(chartPane, gbc); gbc.insets = new Insets(5, 5, 5, 20); gbc.gridx = 1; gbc.weightx = 1; gbc.gridheight = 1; gbc.gridy = 0; gbc.weighty = 1; add(new JLabel("X :"), gbc); gbc.gridy = 2; add(new JLabel("Y :"), gbc); gbc.gridy = 1; gbc.weighty = 5; add(xSelPane, gbc); gbc.gridy = 3; add(ySelPane, gbc); }
From source file:org.bench4Q.console.ui.section.R_RealTransactionShowSection.java
/** * @param resources// ww w. j a v a 2 s . com * @param processControl * @param agentsCollection * @throws ConsoleException */ public R_RealTransactionShowSection(Resources resources, ProcessControl processControl, AgentsCollection agentsCollection) throws ConsoleException { m_resources = resources; m_processControl = processControl; m_agentsCollection = agentsCollection; m_agentsCollection.registerObserver(this); this.setLayout(new GridBagLayout()); this.setPreferredSize(new Dimension(683, 475)); this.setMinimumSize(new Dimension(683, 475)); testduring = -1; resultNumber = 0; picPanel = new PicPanel(); this.add(picPanel, new GridBagConstraints(0, 0, 1, 4, 99.0, 99.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 1, 1)); }
From source file:interpolation.InteractiveRegression.java
public void Card() { CardLayout cl = new CardLayout(); panelCont.setLayout(cl);/*from www. j a v a2 s. c om*/ panelCont.add(panelFirst, "1"); panelCont.add(panelSecond, "2"); panelFirst.setName("Regression Polynomial Fits"); /* Instantiation */ final GridBagLayout layout = new GridBagLayout(); final GridBagConstraints c = new GridBagConstraints(); final Scrollbar degreeSB = new Scrollbar(Scrollbar.HORIZONTAL, this.degreeInt, 1, MIN_SLIDER, MAX_SLIDER + 1); final Label degreeLabel = new Label("Degree of polynomial = " + this.degree, Label.CENTER); // Location panelFirst.setLayout(layout); c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 0; c.gridy = 0; c.weightx = 1; ++c.gridy; c.insets = new Insets(30, 150, 0, 150); panelFirst.add(degreeSB, c); ++c.gridy; c.insets = new Insets(30, 150, 0, 150); panelFirst.add(degreeLabel, c); degreeSB.addAdjustmentListener(new DegreeListener(this, degreeLabel, degreeSB)); panelFirst.setVisible(true); cl.show(panelCont, "1"); Cardframe.add(panelCont, BorderLayout.CENTER); Cardframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Cardframe.pack(); Cardframe.setVisible(true); updateRegression(); }