public JPanel createPanel() { final JPanel roiMaskPanel = GridBagUtils.createPanel(); GridBagConstraints roiMaskPanelConstraints = GridBagUtils.createConstraints("anchor=SOUTHWEST,fill=HORIZONTAL,insets.top=2"); GridBagUtils.addToPanel(roiMaskPanel, useRoiMaskCheckBox, roiMaskPanelConstraints, ",gridy=0,gridx=0,weightx=1"); GridBagUtils.addToPanel(roiMaskPanel, roiMaskComboBox, roiMaskPanelConstraints, "gridy=1,insets.left=4"); GridBagUtils.addToPanel(roiMaskPanel, showMaskManagerButton, roiMaskPanelConstraints, "gridheight=2,gridy=0,gridx=1,weightx=0,ipadx=5,insets.left=0"); return roiMaskPanel; }
final JPanel fieldsPanel = GridBagUtils.createPanel(); final GridBagConstraints fieldsGBC = GridBagUtils.createDefaultConstraints(); fieldsGBC.anchor = GridBagConstraints.WEST; GridBagUtils.addToPanel(fieldsPanel, northLabel, fieldsGBC, "gridx=3"); GridBagUtils.addToPanel(fieldsPanel, northLatField, fieldsGBC, "gridx=4"); GridBagUtils.addToPanel(fieldsPanel, northDegreeLabel, fieldsGBC, "gridx=5"); GridBagUtils.addToPanel(fieldsPanel, westLabel, fieldsGBC, "gridx=0"); GridBagUtils.addToPanel(fieldsPanel, westLonField, fieldsGBC, "gridx=1"); GridBagUtils.addToPanel(fieldsPanel, westDegreeLabel, fieldsGBC, "gridx=2"); GridBagUtils.addToPanel(fieldsPanel, eastLabel, fieldsGBC, "gridx=6"); GridBagUtils.addToPanel(fieldsPanel, eastLonField, fieldsGBC, "gridx=7"); GridBagUtils.addToPanel(fieldsPanel, eastDegreeLabel, fieldsGBC, "gridx=8"); GridBagUtils.addToPanel(fieldsPanel, southLabel, fieldsGBC, "gridx=3"); GridBagUtils.addToPanel(fieldsPanel, southLatField, fieldsGBC, "gridx=4"); GridBagUtils.addToPanel(fieldsPanel, southDegreeLabel, fieldsGBC, "gridx=5"); ui = GridBagUtils.createPanel(); final GridBagConstraints mainGBC = GridBagUtils.createDefaultConstraints(); mainGBC.fill = GridBagConstraints.HORIZONTAL; GridBagUtils.addToPanel(ui, fieldsPanel, mainGBC); mainGBC.gridy = 1; GridBagUtils.addToPanel(ui, worldMapPaneUI, mainGBC, "insets.top=10");
private JPanel createPixelCoordinatesPane() { GridBagConstraints gbc = GridBagUtils.createConstraints( "insets.left=3,anchor=WEST,fill=HORIZONTAL, weightx=1.0"); JPanel pixelCoordinatesPane = GridBagUtils.createPanel(); setComponentName(pixelCoordinatesPane, "pixelCoordinatesPane"); GridBagUtils.setAttributes(gbc, "insets.top=4"); GridBagUtils.addToPanel(pixelCoordinatesPane, new JLabel("Scene start X:"), gbc, "gridx=0,gridy=0"); GridBagUtils.addToPanel(pixelCoordinatesPane, UIUtils.createSpinner(paramX1, 25, "#0"), gbc, "gridx=1,gridy=0"); GridBagUtils.setAttributes(gbc, "insets.top=1"); GridBagUtils.addToPanel(pixelCoordinatesPane, new JLabel("Scene start Y:"), gbc, "gridx=0,gridy=1"); GridBagUtils.addToPanel(pixelCoordinatesPane, UIUtils.createSpinner(paramY1, 25, "#0"), gbc, "gridx=1,gridy=1"); GridBagUtils.setAttributes(gbc, "insets.top=4"); GridBagUtils.addToPanel(pixelCoordinatesPane, new JLabel("Scene end X:"), gbc, "gridx=0,gridy=2"); GridBagUtils.addToPanel(pixelCoordinatesPane, UIUtils.createSpinner(paramX2, 25, "#0"), gbc, "gridx=1,gridy=2"); GridBagUtils.setAttributes(gbc, "insets.top=1"); GridBagUtils.addToPanel(pixelCoordinatesPane, new JLabel("Scene end Y:"), gbc, "gridx=0,gridy=3"); GridBagUtils.addToPanel(pixelCoordinatesPane, UIUtils.createSpinner(paramY2, 25, "#0"), gbc, "gridx=1,gridy=3"); return pixelCoordinatesPane; }
public static JPanel createPageUIContentPane(JPanel pane) { JPanel contentPane = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils.createConstraints("fill=HORIZONTAL,anchor=NORTHWEST"); gbc.insets.top = _PAGE_INSET_TOP; gbc.weightx = 1; gbc.weighty = 0; contentPane.add(pane, gbc); GridBagUtils.addVerticalFiller(contentPane, gbc); return contentPane; }
/** * Adds a component to a panel with a grid bag layout. <p>For the <code>code</code> parameter, see also {@link * #setAttributes(GridBagConstraints, String)}. * * @param panel the panel to which to add the component * @param comp the component to be added * @param gbc the grid bag constraints to be used, can be <code>null</code> if <code>code</code> is not * <code>null</code> * @param code the code containing the constraints, can be <code>null</code> if <code>gbc</code> is not * <code>null</code> * @see #setAttributes(GridBagConstraints, String) */ public static void addToPanel(JPanel panel, Component comp, GridBagConstraints gbc, String code) { addToPanel(panel, comp, setAttributes(gbc, code)); }
private void createUI() { this.setLayout(new GridBagLayout()); this.setBorder(BorderFactory.createTitledBorder("Digital Elevation Model (DEM)")); /*I18N*/ final GridBagConstraints gbc = GridBagUtils.createDefaultConstraints(); final ButtonGroup buttonGroup = new ButtonGroup(); buttonGroup.add((AbstractButton) _paramProductDem.getEditor().getComponent()); buttonGroup.add((AbstractButton) _paramExternalDem.getEditor().getComponent()); GridBagUtils.setAttributes(gbc, "insets.top=3, fill=HORIZONTAL"); gbc.gridy++; GridBagUtils.addToPanel(this, _paramProductDem.getEditor().getComponent(), gbc); gbc.gridy++; GridBagUtils.addToPanel(this, _paramExternalDem.getEditor().getComponent(), gbc, "weightx=1"); GridBagUtils.addToPanel(this, _paramDem.getEditor().getComponent(), gbc, "weightx=999"); }
private JPanel getNameAndDescPanel() { int line = 0; final JPanel nameAndDescPanel = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils.createDefaultConstraints(); GridBagUtils.setAttributes(gbc, "insets.top=3, fill=HORIZONTAL"); gbc.gridy = ++line; GridBagUtils.addToPanel(nameAndDescPanel, new JLabel("Output Product"), gbc, "weightx=1, gridwidth=2"); gbc.gridy = ++line; GridBagUtils.addToPanel(nameAndDescPanel, _paramNewName.getEditor().getLabelComponent(), gbc, "gridwidth=1"); GridBagUtils.addToPanel(nameAndDescPanel, _paramNewName.getEditor().getComponent(), gbc, "weightx=999"); gbc.gridy = ++line; GridBagUtils.addToPanel(nameAndDescPanel, _paramNewDesc.getEditor().getLabelComponent(), gbc, "weightx=1"); GridBagUtils.addToPanel(nameAndDescPanel, _paramNewDesc.getEditor().getComponent(), gbc, "weightx=999"); JComponent jComponent = _paramNewName.getEditor().getEditorComponent(); if (jComponent instanceof JTextComponent) { JTextComponent tc = (JTextComponent) jComponent; tc.selectAll(); } return nameAndDescPanel; }
private JPanel createInfoPanel() { final JPanel infoPanel = GridBagUtils.createDefaultEmptyBorderPanel(); infoPanel.setBorder(UIUtils.createGroupBorder("Output Product Information")); final GridBagConstraints gbc2 = GridBagUtils.createDefaultConstraints(); GridBagUtils.addToPanel(infoPanel, new JLabel("Scene Width:"), gbc2); GridBagUtils.addToPanel(infoPanel, labelWidthInfo, gbc2); GridBagUtils.addToPanel(infoPanel, new JLabel("pixel"), gbc2, "weightx=1"); GridBagUtils.addToPanel(infoPanel, new JLabel("Scene Height:"), gbc2, "gridy=1, weightx=0"); GridBagUtils.addToPanel(infoPanel, labelHeightInfo, gbc2); GridBagUtils.addToPanel(infoPanel, new JLabel("pixel"), gbc2, "weightx=1"); GridBagUtils.addToPanel(infoPanel, new JLabel("Center Latitude:"), gbc2, "gridy=2, weightx=0"); GridBagUtils.addToPanel(infoPanel, labelCenterLatInfo, gbc2, "weightx=1, gridwidth=2"); GridBagUtils.addToPanel(infoPanel, new JLabel("Center Longitude:"), gbc2, "gridy=3, weightx=0, gridwidth=1"); GridBagUtils.addToPanel(infoPanel, labelCenterLonInfo, gbc2, "weightx=1, gridwidth=2"); return infoPanel; }
_sizeLabel.setHorizontalAlignment(JLabel.RIGHT); JPanel accessoryPane = GridBagUtils.createPanel(); GridBagConstraints gbc = GridBagUtils.createConstraints( "fill=HORIZONTAL,weightx=1,anchor=NORTHWEST,insets.left=7,insets.right=7,insets.bottom=4"); GridBagUtils.addToPanel(accessoryPane, _subsetButton, gbc, "gridy=0"); GridBagUtils.addToPanel(accessoryPane, _sizeLabel, gbc, "gridy=1"); GridBagUtils.addVerticalFiller(accessoryPane, gbc);
private JPanel createCheckersPane() { _checkBoxes = new JCheckBox[_allProducts.length]; final JPanel checkersPane = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils.createConstraints("insets.left=4,anchor=WEST,fill=HORIZONTAL"); final StringBuffer description = new StringBuffer(); addProductCheckers(description, checkersPane, gbc); return checkersPane; }
private void addComponents(JPanel panel) { GridBagConstraints gbc = new GridBagConstraints(); JScrollPane scrollPane = new JScrollPane(checkBoxList); scrollPane.setPreferredSize(new Dimension(250, 100)); GridBagUtils.addToPanel(panel, statusLabel, gbc, "insets.top=5, anchor=WEST"); GridBagUtils.addToPanel(panel, progressBar, gbc, "gridx=1,fill=HORIZONTAL, weightx=1.0"); GridBagUtils.addToPanel(panel, percentageLabel, gbc, "insets.left=5, gridx=2, fill=NONE, weightx=0.0"); GridBagUtils.addToPanel(panel, field, gbc, "insets.left=0, gridx=0, gridy=1, gridwidth=3, fill=HORIZONTAL, weightx=1.0"); GridBagUtils.addToPanel(panel, scrollPane, gbc, "gridy=2"); GridBagUtils.addToPanel(panel, selectAllButton, gbc, "insets.right=5, gridy=3, gridwidth=1, fill=NONE, weightx=0"); GridBagUtils.addToPanel(panel, selectNoneButton, gbc, "gridx=1"); GridBagUtils.addToPanel(panel, applyButton, gbc, "insets.right=0, gridx=2, gridy=4, anchor=EAST"); }
private JPanel createBandAssignmentPanel() { final JPanel bandAssignmentPanel = GridBagUtils.createPanel(); GridBagUtils.addToPanel(bandAssignmentPanel, filterField, gbc, "weightx=1.0, weighty=1.0, gridx=0, gridy=0, fill=HORIZONTAL"); GridBagUtils.addToPanel(bandAssignmentPanel, availableBandsScrollPane, gbc, "gridy=1, fill=BOTH,gridheight=5"); GridBagUtils.addToPanel(bandAssignmentPanel, rightButton, gbc, "gridx=1,gridy=1,weightx=0,weighty=0,fill=NONE,gridheight=1"); GridBagUtils.addToPanel(bandAssignmentPanel, leftButton, gbc, "gridy=2"); GridBagUtils.addToPanel(bandAssignmentPanel, allRightButton, gbc, "gridy=3"); GridBagUtils.addToPanel(bandAssignmentPanel, allLeftButton, gbc, "gridy=4"); GridBagUtils.addVerticalFiller(bandAssignmentPanel, gbc); GridBagUtils.addToPanel(bandAssignmentPanel, selectedBandScrollPane, gbc, "gridx=2,gridy=1,weightx=1.0, weighty=1.0,fill=BOTH,gridheight=5"); return bandAssignmentPanel;
final JPanel panel = GridBagUtils.createPanel(); int line = 0; GridBagConstraints gbc = new GridBagConstraints(); GridBagUtils.addToPanel(panel, components[1], gbc, "gridwidth=3, fill=BOTH, weightx=1"); gbc.gridy = ++line; GridBagUtils.addToPanel(panel, components[0], gbc, "insets.top=3, gridwidth=3, fill=BOTH, anchor=WEST"); GridBagUtils.addToPanel(panel, components[1], gbc, "weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=WEST"); GridBagUtils.addToPanel(panel, components[0], gbc, "weightx=1, insets.top=3, gridwidth=2, fill=HORIZONTAL, anchor=WEST"); GridBagUtils.addToPanel(panel, components[1], gbc, "weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=WEST"); GridBagUtils.addToPanel(panel, components[0], gbc, "weightx=1, insets.top=3, gridwidth=2, fill=HORIZONTAL, anchor=WEST"); GridBagUtils.addToPanel(panel, components[1], gbc, "weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=WEST"); GridBagUtils.addToPanel(panel, components[0], gbc, "weightx=1, insets.top=3, gridwidth=2, fill=HORIZONTAL, anchor=WEST"); GridBagUtils.addToPanel(panel, components[1], gbc, "weightx=0, insets.top=3, gridwidth=1, fill=HORIZONTAL, anchor=WEST"); GridBagUtils.addToPanel(panel, components[0], gbc, "weightx=1, insets.top=3, gridwidth=2, fill=HORIZONTAL, anchor=WEST"); GridBagUtils.addToPanel(panel, components[0], gbc, "insets.top=3, gridwidth=3, fill=HORIZONTAL, anchor=EAST");
public static JPanel createDefaultEmptyBorderPanel() { JPanel panel = createPanel(); panel.setBorder(UIDefaults.getDialogBorder()); return panel; }
private JPanel createPageUI() { Parameter param; JPanel logConfigPane = GridBagUtils.createPanel(); GridBagConstraints gbc = GridBagUtils.createConstraints("fill=HORIZONTAL,anchor=WEST,weightx=1"); gbc.gridy = 0; gbc.gridy++; GridBagUtils.setAttributes(gbc, "gridwidth=1,weightx=0"); param = getConfigParam(PROPERTY_KEY_APP_LOG_LEVEL); gbc.gridwidth = 1;
final JLabel label = new JLabel("Target product(s):"); /*I18N*/ final JPanel content = GridBagUtils.createPanel(); final GridBagConstraints gbc = GridBagUtils.createDefaultConstraints(); gbc.gridy = 1; gbc.fill = GridBagConstraints.BOTH;
_basePanel = GridBagUtils.createDefaultEmptyBorderPanel(); setName(_basePanel, _label); final GridBagConstraints gbc = GridBagUtils.createConstraints(null); gbc.anchor = GridBagConstraints.WEST; gbc.weightx = 1;
private void createUI() { final JPanel panel = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = GridBagUtils.createDefaultConstraints(); final JLabel lonLabel = new JLabel("Longitude band:"); /*I18N*/ final JLabel latLabel = new JLabel("Latitude band:"); /*I18N*/
/** * Creates a <code>GridBagConstraints</code> instance with the attributes given as a comma separated key-value pairs * in a text string. * <p/> * <p>According to the public <code>GridBagConstraints</code> attributes, the following key-value pairs are can * occur in the text string: * <p/> * <ld> <li><code>{@link GridBagConstraints#gridx gridx}=<b>RELATIVE</b>|<i>integer</i></code></li> <li><code>{@link * GridBagConstraints#gridy gridy}=<b>RELATIVE</b>|<i>integer</i></code></li> <li><code>{@link * GridBagConstraints#gridwidth gridwidth}=<b>REMAINDER</b>|<b>RELATIVE</b>|<i>integer</i></code></li> * <li><code>{@link GridBagConstraints#gridheight gridheight}=<b>REMAINDER</b>|<b>RELATIVE</b>|<i>integer</i></code></li> * <li><code>{@link GridBagConstraints#weightx weightx}=<i>double</i></code></li> <li><code>{@link * GridBagConstraints#weighty weighty}=<i>double</i></code></li> <li><code>{@link GridBagConstraints#anchor * anchor}=<b>CENTER</b>|<b>NORTH</b>|<b>NORTHEAST</b>|<b>EAST</b>|<b>SOUTHEAST</b>|<b>SOUTH</b>|<b>SOUTHWEST</b>|<b>WEST</b>|<b>NORTHWEST</b>|<i>integer</i></code></li> * <li><code>{@link GridBagConstraints#fill fill}=<b>NONE</b>|<b>HORIZONTAL</b>|<b>VERTICAL</b>|<b>BOTH</b>|<i>integer</i></code></li> * <li><code>{@link GridBagConstraints#insets insets.bottom}=<i>integer</i></code></li> <li><code>{@link * GridBagConstraints#insets insets.left}=<i>integer</i></code></li> <li><code>{@link GridBagConstraints#insets * insets.right}=<i>integer</i></code></li> <li><code>{@link GridBagConstraints#insets * insets.top}=<i>integer</i></code></li> <li><code>{@link GridBagConstraints#ipadx * ipadx}=<i>integer</i></code></li> <li><code>{@link GridBagConstraints#ipady ipady}=<i>integer</i></code></li> * </ld> * * @param code a textual representation of the attributes to be set */ public static GridBagConstraints createConstraints(String code) { GridBagConstraints gbc = new GridBagConstraints(); setAttributes(gbc, code); return gbc; }
public void testGridBagPanel_sevenParams() { GridBagLayout gbl = new GridBagLayout(); JPanel panel = new JPanel(gbl); JLabel comp = new JLabel("text"); final GridBagConstraints gbconstraints = GridBagUtils.createDefaultConstraints(); GridBagUtils.setAttributes(gbconstraints, "gridx=2, gridy=4, anchor=SOUTHEAST, weighty=1.3, insets.top=5"); GridBagUtils.addToPanel(panel, comp, gbconstraints); GridBagConstraints gbc = gbl.getConstraints(comp); assertEquals(GridBagConstraints.SOUTHEAST, gbc.anchor); assertEquals(5, gbc.insets.top); assertEquals(3, gbc.insets.left); assertEquals(0, gbc.insets.bottom); assertEquals(3, gbc.insets.right); assertEquals(2, gbc.gridx); assertEquals(4, gbc.gridy); assertEquals(0, gbc.weightx, 0.01); assertEquals(1.3, gbc.weighty, 0.01); assertEquals(0, gbc.ipadx); assertEquals(0, gbc.ipady); assertEquals(1, gbc.gridheight); assertEquals(1, gbc.gridwidth); }