List of usage examples for java.awt GridBagConstraints WEST
int WEST
To view the source code for java.awt GridBagConstraints WEST.
Click Source Link
From source file:savant.chromatogram.ChromatogramPlugin.java
@Override public void init(JPanel panel) { NavigationUtils.addLocationChangedListener(new Listener<LocationChangedEvent>() { @Override//from w w w . jav a 2 s .c om public void handleEvent(LocationChangedEvent event) { updateChromatogram(); } }); GenomeUtils.addGenomeChangedListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { updateChromatogram(); } }); panel.setLayout(new GridBagLayout()); panel.setBorder(BorderFactory.createEtchedBorder()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0; gbc.anchor = GridBagConstraints.EAST; panel.add(new JLabel("File:"), gbc); pathField = new JTextField(); gbc.gridwidth = 3; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(pathField, gbc); JButton browseButton = new JButton("Browse\u2026"); browseButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { File f = DialogUtils.chooseFileForOpen("Chromatogram File", null, null); if (f != null) { try { pathField.setText(f.getAbsolutePath()); if (canvas != null) { canvas.getParent().remove(canvas); canvas = null; } chromatogram = ChromatogramFactory.create(f); updateEndField(); updateChromatogram(); } catch (UnsupportedChromatogramFormatException x) { DialogUtils.displayMessage("Unable to Open Chromatogram", String.format( "<html><i>%s</i> does not appear to be a valid chromatogram file.<br><br><small>Supported formats are ABI and SCF.</small></html>", f.getName())); } catch (Exception x) { DialogUtils.displayException("Unable to Open Chromatogram", String.format("<html>There was an error opening <i>%s</i>.</html>", f.getName()), x); } } } }); gbc.weightx = 0.0; gbc.fill = GridBagConstraints.NONE; panel.add(browseButton, gbc); JLabel startLabel = new JLabel("Start Base:"); gbc.gridy++; gbc.gridwidth = 1; gbc.anchor = GridBagConstraints.EAST; panel.add(startLabel, gbc); startField = new JTextField("0"); startField.setColumns(12); startField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { updateEndField(); } }); gbc.weightx = 0.5; gbc.anchor = GridBagConstraints.WEST; panel.add(startField, gbc); JLabel endLabel = new JLabel("End Base:"); gbc.weightx = 0.0; gbc.anchor = GridBagConstraints.EAST; panel.add(endLabel, gbc); endField = new JTextField(); endField.setColumns(12); endField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { NumberFormat numberParser = NumberFormat.getIntegerInstance(); int endBase = numberParser.parse(endField.getText()).intValue(); if (chromatogram != null) { int startBase = endBase - chromatogram.getSequenceLength(); startField.setText(String.valueOf(startBase)); if (canvas != null) { canvas.updatePos(startBase); } } } catch (ParseException x) { Toolkit.getDefaultToolkit().beep(); } } }); gbc.weightx = 0.5; gbc.anchor = GridBagConstraints.WEST; panel.add(endField, gbc); JCheckBox fillCheck = new JCheckBox("Fill Background"); fillCheck.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { canvas.updateFillbackground(((JCheckBox) ae.getSource()).isSelected()); } }); gbc.gridy++; gbc.gridx = 1; gbc.weightx = 0.0; panel.add(fillCheck, gbc); // Add a filler panel at the bottom to force our components to the top. gbc.gridy++; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 1.0; panel.add(new JPanel(), gbc); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.LoginLocalFolderPanel.java
private void initGui() { // Textual information. String descriptionText = "<html><center>" + "Your AWS Credentials are stored in encrypted files in a folder on " + "your computer. Each stored login has a nickname." + "<br><font size=\"-2\">You need to store your AWS credentials before you can use this login method.</font>" + "</center></html>"; String folderTooltipText = "The folder containing your AWS Credentials"; String browseButtonText = "Change Folder"; String accountNicknameText = "Stored logins"; String accountNicknameTooltipText = "Nicknames of the login credentials you have stored"; String passwordLabelText = "Password"; String passwordTooltipText = "The password that protects your encrypted file. " + "This password may be left empty if you are sure your computer cannot be compromised"; // Components. JHtmlLabel descriptionLabel = new JHtmlLabel(descriptionText, hyperlinkListener); descriptionLabel.setHorizontalAlignment(JLabel.CENTER); folderPathTextField = new JTextField(this.cockpitHomeFolder.getAbsolutePath()); folderPathTextField.setEnabled(false); folderPathTextField.setToolTipText(folderTooltipText); JButton browseButton = new JButton(browseButtonText); browseButton.addActionListener(this); JHtmlLabel accountNicknamesLabel = new JHtmlLabel(accountNicknameText, hyperlinkListener); nicknamesTableModel = new AWSCredentialsFileTableModel(); accountNicknameTable = new JTable(nicknamesTableModel); accountNicknameTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); accountNicknameTable.setShowHorizontalLines(true); accountNicknameTable.getTableHeader().setVisible(false); JScrollPane accountNicknamesScrollPane = new JScrollPane(accountNicknameTable); accountNicknamesScrollPane.setToolTipText(accountNicknameTooltipText); JHtmlLabel passwordLabel = new JHtmlLabel(passwordLabelText, hyperlinkListener); passwordPasswordField = new JPasswordField(); passwordPasswordField.setToolTipText(passwordTooltipText); int row = 0;// w w w . j a va 2 s . c o m add(descriptionLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); add(folderPathTextField, new GridBagConstraints(0, row, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); add(browseButton, new GridBagConstraints(1, row++, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsDefault, 0, 0)); add(accountNicknamesLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); add(accountNicknamesScrollPane, new GridBagConstraints(0, row++, 2, 1, 0, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsDefault, 0, 0)); add(passwordLabel, new GridBagConstraints(0, row++, 2, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); add(passwordPasswordField, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); }
From source file:org.pentaho.reporting.engine.classic.core.modules.gui.commonswing.ExceptionDialog.java
private void init() { messages = new Messages(getLocale(), SwingCommonModule.BUNDLE_NAME, ObjectUtilities.getClassLoader(SwingCommonModule.class)); setModal(true);//from w w w. ja v a2 s.co m detailsAction = new DetailsAction(); messageLabel = new JLabel(); backtraceArea = new JTextArea(); scroller = new JScrollPane(backtraceArea); scroller.setVisible(false); final JPanel detailPane = new JPanel(); detailPane.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.CENTER; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0; gbc.weighty = 0; gbc.gridx = 0; gbc.gridy = 0; final JLabel icon = new JLabel(UIManager.getDefaults().getIcon("OptionPane.errorIcon")); //$NON-NLS-1$ icon.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); detailPane.add(icon, gbc); gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 1; gbc.weighty = 1; gbc.gridx = 1; gbc.gridy = 0; detailPane.add(messageLabel); gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.SOUTH; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 0; gbc.weighty = 0; gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 2; detailPane.add(createButtonPane(), gbc); filler = new JPanel(); filler.setPreferredSize(new Dimension(0, 0)); filler.setBackground(Color.green); gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.NORTH; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.weightx = 1; gbc.weighty = 5; gbc.gridx = 0; gbc.gridy = 3; gbc.gridwidth = 2; detailPane.add(filler, gbc); gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.SOUTHWEST; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1; gbc.weighty = 5; gbc.gridx = 0; gbc.gridy = 4; gbc.gridwidth = 2; detailPane.add(scroller, gbc); setContentPane(detailPane); }
From source file:com.sshtools.common.ui.SshToolsConnectionProxyTab.java
/** * Creates a new SshToolsConnectionProxyTab object. *///from ww w . j a va 2 s . c o m public SshToolsConnectionProxyTab() { super(); group.add(noProxy); group.add(httpProxy); group.add(socks4Proxy); group.add(socks5Proxy); ChangeListener listener = new ChangeListener() { public void stateChanged(ChangeEvent e) { if (noProxy.isSelected()) { username.setEnabled(false); password.setEnabled(false); proxy.setEnabled(false); //port.setEnabled(false); port.setForeground(Color.white); } else { username.setEnabled(true); password.setEnabled(true); proxy.setEnabled(true); //port.setEnabled(true); port.setForeground(Color.black); if (httpProxy.isSelected()) { port.setText("80"); } else { port.setText("1080"); } } } }; noProxy.getModel().addChangeListener(listener); httpProxy.getModel().addChangeListener(listener); socks4Proxy.getModel().addChangeListener(listener); socks5Proxy.getModel().addChangeListener(listener); // Create the main connection details panel GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.NORTH; gbc.insets = new Insets(0, 2, 2, 2); gbc.weightx = 1.0; proxyframe.setBorder(BorderFactory.createTitledBorder("Connect using the following proxy")); // No proxy label gbc.insets = new Insets(2, 10, 2, 2); UIUtil.jGridBagAdd(proxyframe, noProxy, gbc, GridBagConstraints.RELATIVE); // Socks 4 label gbc.insets = new Insets(2, 15, 2, 2); UIUtil.jGridBagAdd(proxyframe, socks4Proxy, gbc, GridBagConstraints.REMAINDER); //gbc.fill = GridBagConstraints.HORIZONTAL; // Http Proxy gbc.insets = new Insets(2, 10, 2, 2); UIUtil.jGridBagAdd(proxyframe, httpProxy, gbc, GridBagConstraints.RELATIVE); // Socks 5 label gbc.insets = new Insets(2, 15, 2, 2); UIUtil.jGridBagAdd(proxyframe, socks5Proxy, gbc, GridBagConstraints.REMAINDER); gbc.insets = new Insets(2, 10, 2, 10); JPanel connect = new JPanel(new GridBagLayout()); connect.setBorder(BorderFactory.createTitledBorder("Proxy Details")); UIUtil.jGridBagAdd(connect, new JLabel("Host"), gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(connect, proxy, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(connect, new JLabel("Port"), gbc, GridBagConstraints.REMAINDER); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.NONE; UIUtil.jGridBagAdd(connect, port, gbc, GridBagConstraints.REMAINDER); gbc.fill = GridBagConstraints.HORIZONTAL; UIUtil.jGridBagAdd(connect, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(connect, username, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(connect, new JLabel("Password"), gbc, GridBagConstraints.REMAINDER); gbc.insets = new Insets(2, 10, 10, 10); UIUtil.jGridBagAdd(connect, password, gbc, GridBagConstraints.REMAINDER); JPanel main = new JPanel(new GridBagLayout()); gbc.insets = new Insets(2, 2, 2, 2); UIUtil.jGridBagAdd(main, proxyframe, gbc, GridBagConstraints.REMAINDER); UIUtil.jGridBagAdd(main, connect, gbc, GridBagConstraints.REMAINDER); IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(PROXY_ICON), main); noProxy.setSelected(true); // 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:gov.loc.repository.bagger.ui.NewBagInPlaceFrame.java
private void layoutSelectDataContent(JPanel contentPanel, int row) { GridBagConstraints glbc = new GridBagConstraints(); JLabel location = new JLabel("Select Data:"); saveAsButton = new JButton(bagView.getPropertyMessage("bag.button.browse")); saveAsButton.addActionListener(new BrowseFileHandler()); saveAsButton.setEnabled(true);/* w w w . j a va 2 s . com*/ saveAsButton.setToolTipText(bagView.getPropertyMessage("bag.button.browse.help")); String fileName = ""; if (bag != null) fileName = bag.getName(); bagNameField = new JTextField(fileName); bagNameField.setCaretPosition(fileName.length()); bagNameField.setEditable(false); bagNameField.setEnabled(false); glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.WEST); contentPanel.add(location, glbc); glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 1, 50, GridBagConstraints.NONE, GridBagConstraints.EAST); glbc.ipadx = 5; glbc.ipadx = 0; contentPanel.add(saveAsButton, glbc); glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST); glbc.ipadx = 5; glbc.ipadx = 0; contentPanel.add(bagNameField, glbc); }
From source file:com.sshtools.common.ui.SshToolsConnectionKerberosTab.java
/** * Creates a new SshToolsConnectionKerberosTab object. *//* www. j a v a2 s.co m*/ 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:gdt.jgui.entity.webset.JWeblinkEditor.java
/** * The default constructor./*from w ww .ja v a 2 s.c om*/ */ public JWeblinkEditor() { GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0 }; gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0 }; setLayout(gridBagLayout); String icon$ = Support.readHandlerIcon(null, JEntitiesPanel.class, "globe.png"); byte[] ba = Base64.decodeBase64(icon$); ImageIcon icon = new ImageIcon(ba); Image image = icon.getImage().getScaledInstance(24, 24, 0); icon.setImage(image); JLabel iconLabel = new JLabel("Icon"); c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.FIRST_LINE_START; c.weighty = 0; c.gridx = 0; c.gridy = 0; add(iconLabel, c); iconLabel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showIconMenu(e); } }); iconIcon = new JLabel(); iconIcon.setIcon(icon); c_0 = new GridBagConstraints(); c_0.anchor = GridBagConstraints.WEST; c_0.insets = new Insets(0, 5, 5, 0); c.anchor = GridBagConstraints.WEST; c_0.gridx = 1; c_0.gridy = 0; add(iconIcon, c_0); iconIcon.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showIconMenu(e); } }); JLabel lblName = new JLabel("Name"); c_1 = new GridBagConstraints(); c_1.insets = new Insets(5, 5, 5, 5); c_1.fill = GridBagConstraints.HORIZONTAL; c_1.gridx = 0; c_1.gridy = 1; add(lblName, c_1); nameField = new JTextField(); c_2 = new GridBagConstraints(); c_2.insets = new Insets(0, 5, 5, 0); c_2.fill = GridBagConstraints.HORIZONTAL; c_2.gridx = 1; c_2.gridy = 1; add(nameField, c_2); JLabel lblUrl = new JLabel("Address"); c_3 = new GridBagConstraints(); c_3.insets = new Insets(5, 5, 5, 5); c_3.fill = GridBagConstraints.HORIZONTAL; c_3.gridx = 0; c_3.gridy = 2; add(lblUrl, c_3); addressField = new JTextField(); c_4 = new GridBagConstraints(); c_4.insets = new Insets(0, 5, 5, 0); c_4.fill = GridBagConstraints.HORIZONTAL; c_4.gridx = 1; c_4.gridy = 2; add(addressField, c_4); JLabel lblLogin = new JLabel("Login"); c_5 = new GridBagConstraints(); c_5.insets = new Insets(5, 5, 5, 5); c_5.fill = GridBagConstraints.HORIZONTAL; c_5.gridx = 0; c_5.gridy = 3; add(lblLogin, c_5); lblLogin.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showLoginMenu(e); } }); loginField = new JTextField(); c_6 = new GridBagConstraints(); c_6.insets = new Insets(0, 5, 5, 0); c_6.fill = GridBagConstraints.HORIZONTAL; c_6.gridx = 1; c_6.gridy = 3; add(loginField, c_6); JLabel lblPassword = new JLabel("Password"); c_7 = new GridBagConstraints(); c_7.insets = new Insets(5, 5, 5, 5); c_7.fill = GridBagConstraints.HORIZONTAL; c_7.gridx = 0; c_7.gridy = 4; add(lblPassword, c_7); lblPassword.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { showPasswordMenu(e); } }); passwordField = new JTextField(); c_8 = new GridBagConstraints(); c_8.insets = new Insets(0, 5, 5, 0); c_8.fill = GridBagConstraints.HORIZONTAL; c_8.gridx = 1; c_8.gridy = 4; add(passwordField, c_8); JPanel bottom = new JPanel(); c_9 = new GridBagConstraints(); c_9.weighty = 1; c_9.fill = GridBagConstraints.VERTICAL; c_9.gridx = 0; c_9.gridy = 5; add(bottom, c_9); }
From source file:org.eurocarbdb.application.glycoworkbench.plugin.s3.gui.StartupDialog.java
/** * Initialises all GUI elements.// www . j a v a2 s.c o m */ private void initGui() { this.setResizable(false); this.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); cancelButton = new JButton("Don't log in"); cancelButton.setActionCommand("Cancel"); cancelButton.addActionListener(this); storeCredentialsButton = new JButton("Store Credentials"); storeCredentialsButton.setActionCommand("StoreCredentials"); storeCredentialsButton.addActionListener(this); okButton = new JButton("Log in"); okButton.setActionCommand("LogIn"); okButton.addActionListener(this); // Set default ENTER and ESCAPE buttons. this.getRootPane().setDefaultButton(okButton); this.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "ESCAPE"); this.getRootPane().getActionMap().put("ESCAPE", new AbstractAction() { private static final long serialVersionUID = -1742280851624947873L; public void actionPerformed(ActionEvent actionEvent) { setVisible(false); } }); JPanel buttonsPanel = new JPanel(new GridBagLayout()); buttonsPanel.add(cancelButton, new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(storeCredentialsButton, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); buttonsPanel.add(okButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, insetsZero, 0, 0)); loginPassphrasePanel = new LoginPassphrasePanel(hyperlinkListener); loginLocalFolderPanel = new LoginLocalFolderPanel(ownerFrame, hyperlinkListener); loginCredentialsPanel = new LoginCredentialsPanel(false, hyperlinkListener); // Tabbed Pane. tabbedPane = new JTabbedPane(); tabbedPane.addChangeListener(this); tabbedPane.add(loginPassphrasePanel, "S3 Online"); tabbedPane.add(loginLocalFolderPanel, "Local Folder"); tabbedPane.add(loginCredentialsPanel, "Direct Login"); int row = 0; this.getContentPane().setLayout(new GridBagLayout()); this.getContentPane().add(tabbedPane, new GridBagConstraints(0, row++, 2, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, insetsZero, 0, 0)); this.getContentPane().add(buttonsPanel, new GridBagConstraints(0, row++, 2, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0)); this.pack(); this.setSize(500, 400); this.setLocationRelativeTo(this.getOwner()); }
From source file:org.eevolution.form.VCRPDetail.java
private void jbInit() { dateFrom = new VDate("DateFrom", true, false, true, DisplayType.Date, "DateFrom"); dateTo = new VDate("DateTo", true, false, true, DisplayType.Date, "DateTo"); CPanel northPanel = new CPanel(); northPanel.setLayout(new java.awt.GridBagLayout()); northPanel.add(new CLabel(Msg.translate(Env.getCtx(), "S_Resource_ID")), new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(resource, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(new CLabel(Msg.translate(Env.getCtx(), "DateFrom")), new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(dateFrom, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(new CLabel(Msg.translate(Env.getCtx(), "DateTo")), new GridBagConstraints(4, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(dateTo, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); ConfirmPanel confirmPanel = new ConfirmPanel(true); confirmPanel.addActionListener(new ActionHandler()); contentPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); contentPanel.setPreferredSize(new Dimension(800, 600)); m_form.getWindow().getContentPane().add(northPanel, BorderLayout.NORTH); m_form.getWindow().getContentPane().add(contentPanel, BorderLayout.CENTER); m_form.getWindow().getContentPane().add(confirmPanel, BorderLayout.SOUTH); }
From source file:savant.ucscexplorer.UCSCExplorerPlugin.java
private void buildUI() { topLevelPanel.removeAll();//from w w w . j a v a2s .co m topLevelPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); try { UCSCDataSourcePlugin ucsc = getUCSCPlugin(); ucsc.getConnection(); JLabel cladeLabel = new JLabel("Clade:"); gbc.anchor = GridBagConstraints.EAST; topLevelPanel.add(cladeLabel, gbc); cladeCombo = new JComboBox(); cladeCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { UCSCDataSourcePlugin ucsc = getUCSCPlugin(); String clade = (String) cladeCombo.getSelectedItem(); genomeCombo.setModel(new DefaultComboBoxModel(ucsc.getCladeGenomes(clade))); genomeCombo.setSelectedItem(ucsc.getCurrentGenome(clade)); } }); gbc.anchor = GridBagConstraints.WEST; topLevelPanel.add(cladeCombo, gbc); JLabel genomeLabel = new JLabel("Genome:"); gbc.anchor = GridBagConstraints.EAST; topLevelPanel.add(genomeLabel, gbc); genomeCombo = new JComboBox(); genomeCombo.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { buildProgressUI(); new GroupsFetcher(getUCSCPlugin(), (GenomeDef) genomeCombo.getSelectedItem()) { @Override public void done(List<GroupDef> groups) { if (groups != null) { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1.0; for (GroupDef g : groups) { groupsPanel.add(new GroupPanel(g), gbc); } // Add a filler panel to force everything to the top. gbc.weighty = 1.0; groupsPanel.add(new JPanel(), gbc); loadButton.setEnabled(true); topLevelPanel.validate(); } } @Override public void showProgress(double value) { updateProgress(progressMessage, value); } }.execute(); } }); gbc.anchor = GridBagConstraints.WEST; topLevelPanel.add(genomeCombo, gbc); loadButton = new JButton("Load Selected Tracks"); loadButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { try { loadSelectedTracks(); } catch (Throwable x) { DialogUtils.displayException(getTitle(), "Unable to load selected tracks.", x); } } }); gbc.anchor = GridBagConstraints.EAST; gbc.gridwidth = GridBagConstraints.REMAINDER; topLevelPanel.add(loadButton, gbc); groupsPanel = new GroupsPanel(); groupsPanel.setLayout(new GridBagLayout()); JScrollPane groupsScroller = new JScrollPane(groupsPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); gbc.weightx = 1.0; gbc.weighty = 1.0; gbc.fill = GridBagConstraints.BOTH; topLevelPanel.add(groupsScroller, gbc); buildProgressUI(); GenomeUtils.addGenomeChangedListener(new Listener<GenomeChangedEvent>() { @Override public void handleEvent(GenomeChangedEvent event) { UCSCDataSourcePlugin ucsc = getUCSCPlugin(); ucsc.selectGenomeDB(null); GenomeAdapter newGenome = event.getNewGenome(); GenomeDef g = new GenomeDef(newGenome.getName(), null); String newClade = ucsc.findCladeForGenome(g); // newClade could be null if the user has opened a genome which has no UCSC equivalent. if (newClade != null) { cladeCombo.setSelectedItem(newClade); } } }); ucsc.selectGenomeDB(null); new CladesFetcher(getUCSCPlugin()) { @Override public void done(String selectedClade) { cladeCombo.setModel(new DefaultComboBoxModel(UCSCDataSourcePlugin.STANDARD_CLADES)); if (selectedClade != null) { cladeCombo.setSelectedItem(selectedClade); } else { cladeCombo.setSelectedIndex(0); } } @Override public void showProgress(double value) { updateProgress(progressMessage, value); } }.execute(); } catch (Exception x) { LOG.error("Unable to connect to UCSC database.", x); topLevelPanel.removeAll(); gbc.anchor = GridBagConstraints.CENTER; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.NONE; gbc.weightx = 0.0; gbc.weighty = 0.0; topLevelPanel.add(new JLabel("Unable to connect to UCSC database."), gbc); JLabel error = new JLabel(MiscUtils.getMessage(x)); Font f = topLevelPanel.getFont(); f = f.deriveFont(Font.ITALIC, f.getSize() - 2.0f); error.setFont(f); topLevelPanel.add(error, gbc); } }