List of usage examples for java.awt GridBagConstraints RELATIVE
int RELATIVE
To view the source code for java.awt GridBagConstraints RELATIVE.
Click Source Link
From source file:org.ut.biolab.medsavant.client.view.list.MasterView.java
public MasterView(String page, DetailedListModel model, DetailedView view, DetailedListEditor editor) { pageName = page;//from ww w .java2 s . c om detailedModel = model; detailedView = view; detailedEditor = editor; setLayout(new CardLayout()); WaitPanel wp = new WaitPanel("Getting list"); wp.setBackground(ViewUtil.getTertiaryMenuColor()); add(wp, CARD_WAIT); showCard = new JPanel(); add(showCard, CARD_SHOW); JPanel errorPanel = new JPanel(); errorPanel.setLayout(new BorderLayout()); errorMessage = new JLabel("An error occurred:"); errorPanel.add(errorMessage, BorderLayout.NORTH); add(errorPanel, CARD_ERROR); buttonPanel = ViewUtil.getClearPanel(); buttonPanel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = GridBagConstraints.RELATIVE; gbc.gridy = 0; gbc.insets = new Insets(3, 3, 3, 3); if (detailedEditor.doesImplementAdding()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.ADD_ON_TOOLBAR)); butt.setToolTipText("Add"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.addItems(); // In some cases, such as uploading/publishing variants, the addItems() method may have logged us out. if (LoginController.getInstance().isLoggedIn()) { refreshList(); } } }); buttonPanel.add(butt, gbc); } if (detailedEditor.doesImplementImporting()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.IMPORT)); butt.setToolTipText("Import"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.importItems(); refreshList(); } }); buttonPanel.add(butt, gbc); } if (detailedEditor.doesImplementExporting()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EXPORT)); butt.setToolTipText("Export"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.exportItems(); refreshList(); } }); buttonPanel.add(butt, gbc); } if (detailedEditor.doesImplementDeleting()) { JLabel butt = ViewUtil.createIconButton( IconFactory.getInstance().getIcon(IconFactory.StandardIcon.REMOVE_ON_TOOLBAR)); butt.setToolTipText("Remove selected"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.deleteItems(selectionGrabber.getSelectedItems()); // In some cases, such as removing/publishing variants, the deleteItems() method may have logged us out. if (LoginController.getInstance().isLoggedIn()) { refreshList(); } } }); buttonPanel.add(butt, gbc); } if (detailedEditor.doesImplementEditing()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.EDIT)); butt.setToolTipText("Edit selected"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (selectionGrabber.getSelectedItems().size() > 0) { detailedEditor.editItem(selectionGrabber.getSelectedItems().get(0)); refreshList(); } else { DialogUtils.displayMessage("Please choose one item to edit."); } } }); buttonPanel.add(butt, gbc); } // Only for SavedFiltersPanel if (detailedEditor.doesImplementLoading()) { JLabel butt = ViewUtil .createIconButton(IconFactory.getInstance().getIcon(IconFactory.StandardIcon.LOAD_ON_TOOLBAR)); butt.setToolTipText("Load selected"); butt.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { detailedEditor.loadItems(selectionGrabber.getSelectedItems()); } }); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.anchor = GridBagConstraints.EAST; buttonPanel.add(butt, gbc); } showWaitCard(); fetchList(); }
From source file:org.fhcrc.cpl.viewer.quant.gui.PanelWithLogRatioHistAndFields.java
/** * Lay out GUI components, but NOT the histogram *///from w w w . j a v a2 s. 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.pentaho.ui.xul.swing.tags.SwingWindow.java
public void resetContainer() { container.removeAll();/*from ww w .j a v a 2 s . c o m*/ gc = new GridBagConstraints(); gc.gridy = GridBagConstraints.RELATIVE; gc.gridx = 0; gc.gridheight = 1; gc.gridwidth = GridBagConstraints.REMAINDER; gc.insets = new Insets(0, 0, 0, 0); gc.fill = GridBagConstraints.HORIZONTAL; gc.anchor = GridBagConstraints.NORTHWEST; gc.weightx = 1; }
From source file:com.adito.upgrade.GUIUpgrader.java
public GUIUpgrader() { super(new BorderLayout()); JPanel info = new JPanel(new BorderLayout(2, 2)); // info.setBackground(Color.white); // info.setForeground(Color.black); // info.setOpaque(true); info.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); JLabel l = new JLabel("<html><p>This utility upgrades configuration from " + "one version 0.1.16 installation to another " + "0.2.5+ installation. You may choose which resources you " + "wish to be copied. If resources with the same name already " + "exist they will be left as is."); l.setIcon(new ImageIcon(GUIUpgrader.class.getResource("upgrader-48x48.png"))); info.add(l, BorderLayout.CENTER); info.add(new JSeparator(JSeparator.HORIZONTAL), BorderLayout.SOUTH); mainPanel = new JPanel(new BorderLayout()); add(info, BorderLayout.NORTH); add(mainPanel, BorderLayout.CENTER); // Installations panel JPanel installations = new JPanel(new GridBagLayout()); installations.setBorder(BorderFactory.createTitledBorder("Installations")); GridBagConstraints gbc = new GridBagConstraints(); gbc.anchor = GridBagConstraints.WEST; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets = new Insets(2, 2, 2, 2); gbc.weightx = 2.0;//from w ww . ja va2s .c o m UIUtil.jGridBagAdd(installations, new JLabel("Source"), gbc, GridBagConstraints.REMAINDER); gbc.weightx = 1.0; source = new JTextField(); source.getDocument().addDocumentListener(this); UIUtil.jGridBagAdd(installations, source, gbc, GridBagConstraints.RELATIVE); browseSource = new JButton("Browse"); browseSource.setMnemonic('b'); browseSource.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(source.getText()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select source installation directory (0.16.1)"); if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) { source.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); gbc.weightx = 0.0; UIUtil.jGridBagAdd(installations, browseSource, gbc, GridBagConstraints.REMAINDER); gbc.weightx = 2.0; UIUtil.jGridBagAdd(installations, new JLabel("Target"), gbc, GridBagConstraints.REMAINDER); gbc.weightx = 1.0; target = new JTextField(System.getProperty("user.dir")); target.getDocument().addDocumentListener(this); UIUtil.jGridBagAdd(installations, target, gbc, GridBagConstraints.RELATIVE); browseTarget = new JButton("Browse"); browseTarget.setMnemonic('r'); browseTarget.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser = new JFileChooser(target.getText()); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setDialogTitle("Select target installation directory (0.2.5+)"); if (chooser.showOpenDialog(GUIUpgrader.this) == JFileChooser.APPROVE_OPTION) { target.setText(chooser.getSelectedFile().getAbsolutePath()); } } }); gbc.weightx = 0.0; UIUtil.jGridBagAdd(installations, browseTarget, gbc, GridBagConstraints.REMAINDER); mainPanel.add(installations, BorderLayout.NORTH); // Upgrade selection upgradeSelectionPanel = new JPanel(); upgradeSelectionPanel.setBorder(BorderFactory.createTitledBorder("Upgrades")); upgradeSelectionPanel.setLayout(new BoxLayout(upgradeSelectionPanel, BoxLayout.Y_AXIS)); mainPanel.add(upgradeSelectionPanel, BorderLayout.CENTER); }
From source file:pcgen.gui2.tools.Utility.java
/** * Set up GridBag Constraints in a relative pattern. Components must be * added in order row by row./*from ww w . jav a 2 s . co m*/ * * @param gbc The gridbagconstraints to set up * @param gw cols wide * @param gh rows high * @param wx weight of x, I typically put in percentile, only need to specify this once for each column, other values in same column are 0.0 * @param wy weight of y, same as weight for cols, just specify a non-zero value for one cell in each row. * @param fill How should the component be resized if smaller than the space. * @param anchor Where should the component be placed if smaller than the space. */ public static void buildRelativeConstraints(GridBagConstraints gbc, int gw, int gh, double wx, double wy, int fill, int anchor) { buildConstraints(gbc, GridBagConstraints.RELATIVE, GridBagConstraints.RELATIVE, gw, gh, wx, wy); gbc.fill = fill; gbc.anchor = anchor; }
From source file:com.sshtools.common.ui.SshToolsConnectionProxyTab.java
/** * Creates a new SshToolsConnectionProxyTab object. */// www.j a v a 2 s . com 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:com.limegroup.gnutella.gui.CurrentAudioStatusComponent.java
private void initComponents() { Dimension dimension = new Dimension(220, 22); setPreferredSize(dimension);// w w w. j av a 2 s . com setMinimumSize(dimension); speakerIcon = GUIMediator.getThemeImage("speaker"); text = new JLabel(); Font f = new Font("DIALOG", Font.BOLD, 10); text.setFont(f); text.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { if (MediaPlayer.instance().getCurrentSong().getFile() != null || MediaPlayer.instance().getCurrentSong().getPlaylistItem() != null || MediaPlayer.instance().getCurrentSong() instanceof InternetRadioAudioSource || MediaPlayer.instance().getCurrentSong() instanceof DeviceAudioSource) { showCurrentSong(); } else if (MediaPlayer.instance().getCurrentSong() instanceof StreamAudioSource) { StreamAudioSource audioSource = (StreamAudioSource) MediaPlayer.instance().getCurrentSong(); if (audioSource.getDetailsUrl() != null) { GUIMediator.openURL(audioSource.getDetailsUrl()); } } else if (MediaPlayer.instance().getCurrentSong().getURL() != null) { GUIMediator.instance().setWindow(GUIMediator.Tabs.LIBRARY); } } }); shareButton = new MediaButton(I18n.tr("Send this file to a friend"), "share", "share"); shareButton.addActionListener(new SendToFriendActionListener()); shareButton.setVisible(false); //Share Button setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = GridBagConstraints.RELATIVE; c.insets = new Insets(0, 0, 0, 3); add(shareButton, c);//, BorderLayout.LINE_END); //Go to Current Audio Control c.gridx = 0; c.gridx = 1; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.EAST; c.insets = new Insets(0, 0, 0, 0); add(text, c);//, BorderLayout.LINE_END); }
From source file:DiningPhilosophers.java
public void init() { imgs[HUNGRYDUKE] = new ImageIcon(getURL("images/hungryduke.gif")); imgs[RIGHTSPOONDUKE] = new ImageIcon(getURL("images/rightspoonduke.gif")); imgs[BOTHSPOONSDUKE] = new ImageIcon(getURL("images/bothspoonsduke.gif")); width = imgs[HUNGRYDUKE].getIconWidth() + (int) (MARGIN * 2.0); height = imgs[HUNGRYDUKE].getIconHeight() + (int) (MARGIN * 2.0); spacing = width + MARGIN;//from w w w .j ava 2 s.com GridBagLayout gridBag = new GridBagLayout(); GridBagConstraints c = new GridBagConstraints(); JPanel contentPane = new JPanel(); contentPane.setLayout(gridBag); philosopherArea = new JPanel(null); philosopherArea.setBackground(Color.white); Dimension preferredSize = createPhilosophersAndChopsticks(); philosopherArea.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createLoweredBevelBorder(), BorderFactory.createEmptyBorder(5, 5, 5, 5))); philosopherArea.setPreferredSize(preferredSize); c.fill = GridBagConstraints.BOTH; c.weighty = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; //end row gridBag.setConstraints(philosopherArea, c); contentPane.add(philosopherArea); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.weighty = 0.0; gridBag.setConstraints(stopStartButton, c); contentPane.add(stopStartButton); c.gridwidth = GridBagConstraints.RELATIVE; //don't end row c.weightx = 1.0; c.weighty = 0.0; gridBag.setConstraints(grabDelaySlider, c); contentPane.add(grabDelaySlider); c.weightx = 0.0; c.gridwidth = GridBagConstraints.REMAINDER; //end row gridBag.setConstraints(label, c); contentPane.add(label); contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); stopStartButton.addActionListener(this); grabDelaySlider.addChangeListener(this); }
From source file:org.pentaho.ui.xul.swing.tags.SwingDialog.java
public void resetContainer() { container.removeAll();// w w w . j a va 2 s .c om gc = new GridBagConstraints(); gc.gridy = GridBagConstraints.RELATIVE; gc.gridx = 0; gc.gridheight = 1; gc.gridwidth = GridBagConstraints.REMAINDER; int pad = getPadding(); gc.insets = new Insets(pad, pad, pad, pad); gc.fill = GridBagConstraints.HORIZONTAL; gc.anchor = GridBagConstraints.NORTHWEST; gc.weightx = 1; }
From source file:pcgen.gui2.dialog.OptionsPathDialog.java
private void initComponents() { setResizable(false);/*from ww w . jav a 2 s .c o m*/ setTitle("Directory for options.ini location"); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); getContentPane().setLayout(new GridBagLayout()); GridBagConstraints gridBagConstraints = new GridBagConstraints(); JLabel label = new JLabel("Select a directory to store PCGen options in:"); gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagConstraints.fill = GridBagConstraints.BOTH; gridBagConstraints.insets = new Insets(4, 4, 0, 4); getContentPane().add(label, gridBagConstraints); gridBagConstraints.insets = new Insets(2, 0, 2, 0); getContentPane().add(new JSeparator(), gridBagConstraints); label = new JLabel( "If you have an existing options.ini file," + "then select the directory containing that file"); gridBagConstraints.insets = new Insets(4, 4, 4, 4); getContentPane().add(label, gridBagConstraints); ActionListener handler = new ActionHandler(); ButtonGroup group = new ButtonGroup(); gridBagConstraints.insets = new Insets(0, 4, 0, 4); addRadioButton("<html><b>PCGen Dir</b>: This is the directory that PCGen is installed into", SettingsFilesPath.pcgen.name(), group, handler, gridBagConstraints); // Remark: do mac user really need to be able to put the file either in a specific mac dir or home? if (SystemUtils.IS_OS_MAC_OSX) { addRadioButton("<html><b>Mac User Dir</b>", SettingsFilesPath.mac_user.name(), group, handler, gridBagConstraints); } else if (SystemUtils.IS_OS_UNIX) { // putting it the same way as mac. merging all and using a system config dir instead would be better IMHO. addRadioButton("<html><b>Freedesktop configuration sub-directory</b> Use for most Linux/BSD", SettingsFilesPath.FD_USER.name(), group, handler, gridBagConstraints); } addRadioButton("<html><b>Home Dir</b>: This is your home directory", SettingsFilesPath.user.name(), group, handler, gridBagConstraints); addRadioButton("Select a directory to use", "select", group, handler, gridBagConstraints); dirField.setText(ConfigurationSettings.getSettingsDirFromFilePath(selectedDir)); dirField.setEditable(false); gridBagConstraints.gridwidth = GridBagConstraints.RELATIVE; gridBagConstraints.weightx = 1; gridBagConstraints.insets = new Insets(0, 4, 0, 0); getContentPane().add(dirField, gridBagConstraints); dirButton.setText("..."); dirButton.setEnabled(false); dirButton.addActionListener(handler); dirButton.setActionCommand("custom"); dirButton.setMargin(new Insets(2, 2, 2, 2)); GridBagConstraints bagConstraints = new GridBagConstraints(); bagConstraints.gridwidth = GridBagConstraints.REMAINDER; bagConstraints.insets = new Insets(0, 0, 0, 4); getContentPane().add(dirButton, bagConstraints); JButton okButton = new JButton("OK"); okButton.setPreferredSize(new Dimension(75, 23)); okButton.setActionCommand("ok"); okButton.addActionListener(handler); bagConstraints.insets = new Insets(4, 0, 4, 0); getContentPane().add(okButton, bagConstraints); getRootPane().setDefaultButton(okButton); pack(); setLocationRelativeTo(null); }