Java Code Examples for java.awt.GridBagConstraints#REMAINDER

The following examples show how to use java.awt.GridBagConstraints#REMAINDER . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceDialog.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
public GeneralPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.insets = panelInsets;
    c.weightx = 1.0;
    c.weighty = 1.0;

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlPrintService = new PrintServicePanel();
    addToGB(pnlPrintService, this, gridbag, c);

    c.gridwidth = GridBagConstraints.RELATIVE;
    pnlPrintRange = new PrintRangePanel();
    addToGB(pnlPrintRange, this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlCopies = new CopiesPanel();
    addToGB(pnlCopies, this, gridbag, c);
}
 
Example 2
Source File: ServiceDialog.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
public QualityPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weighty = 1.0;

    ButtonGroup bg = new ButtonGroup();
    rbDraft = createRadioButton("radiobutton.draftq", this);
    bg.add(rbDraft);
    addToGB(rbDraft, this, gridbag, c);
    rbNormal = createRadioButton("radiobutton.normalq", this);
    rbNormal.setSelected(true);
    bg.add(rbNormal);
    addToGB(rbNormal, this, gridbag, c);
    rbHigh = createRadioButton("radiobutton.highq", this);
    bg.add(rbHigh);
    addToGB(rbHigh, this, gridbag, c);
}
 
Example 3
Source File: ClientDialog.java    From megamek with GNU General Public License v2.0 6 votes vote down vote up
/** 
 * Adds a row (line) with the two JComponents <code>label, secondC</code>
 * to the given <code>panel</code>, using constraints c. The label will be
 * right-aligned, the secondC left-aligned to bring them close together. 
 * Only useful for simple panels with GridBagLayout.
 */
protected void addOptionRow(JPanel targetP, GridBagConstraints c, JLabel label, Component secondC) {
    int oldGridW = c.gridwidth;
    int oldAnchor = c.anchor;
    
    c.gridwidth = 1;
    c.anchor = GridBagConstraints.EAST;
    targetP.add(label, c);
    
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.WEST;
    targetP.add(secondC, c);
    
    c.gridwidth = oldGridW;
    c.anchor = oldAnchor;
}
 
Example 4
Source File: ServiceDialog.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
public GeneralPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.insets = panelInsets;
    c.weightx = 1.0;
    c.weighty = 1.0;

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlPrintService = new PrintServicePanel();
    addToGB(pnlPrintService, this, gridbag, c);

    c.gridwidth = GridBagConstraints.RELATIVE;
    pnlPrintRange = new PrintRangePanel();
    addToGB(pnlPrintRange, this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlCopies = new CopiesPanel();
    addToGB(pnlCopies, this, gridbag, c);
}
 
Example 5
Source File: ServiceDialog.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
public GeneralPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.insets = panelInsets;
    c.weightx = 1.0;
    c.weighty = 1.0;

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlPrintService = new PrintServicePanel();
    addToGB(pnlPrintService, this, gridbag, c);

    c.gridwidth = GridBagConstraints.RELATIVE;
    pnlPrintRange = new PrintRangePanel();
    addToGB(pnlPrintRange, this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlCopies = new CopiesPanel();
    addToGB(pnlCopies, this, gridbag, c);
}
 
Example 6
Source File: SimilarityTable.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
public SimilarityTable(DistanceMeasure measure, ExampleSet exampleSet) {
	GridBagLayout layout = new GridBagLayout();
	setLayout(layout);
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.weightx = 1;
	c.weighty = 1;
	c.gridwidth = GridBagConstraints.REMAINDER;

	similarityTable = new ExtendedJTable();
	SimilarityTableModel model = new SimilarityTableModel(measure, exampleSet);
	similarityTable.setModel(model);

	JScrollPane tablePane = new ExtendedJScrollPane(similarityTable);
	tablePane.setBorder(null);
	layout.setConstraints(tablePane, c);
	add(tablePane);
}
 
Example 7
Source File: ServiceDialog.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public AppearancePanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);

    c.fill = GridBagConstraints.BOTH;
    c.insets = panelInsets;
    c.weightx = 1.0;
    c.weighty = 1.0;

    c.gridwidth = GridBagConstraints.RELATIVE;
    pnlChromaticity = new ChromaticityPanel();
    addToGB(pnlChromaticity, this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlQuality = new QualityPanel();
    addToGB(pnlQuality, this, gridbag, c);

    c.gridwidth = 1;
    pnlSides = new SidesPanel();
    addToGB(pnlSides, this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlJobAttributes = new JobAttributesPanel();
    addToGB(pnlJobAttributes, this, gridbag, c);

}
 
Example 8
Source File: ServiceDialog.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
public MediaPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    cbSize = new JComboBox();
    cbSource = new JComboBox();

    c.fill = GridBagConstraints.BOTH;
    c.insets = compInsets;
    c.weighty = 1.0;

    c.weightx = 0.0;
    lblSize = new JLabel(getMsg("label.size"), JLabel.TRAILING);
    lblSize.setDisplayedMnemonic(getMnemonic("label.size"));
    lblSize.setLabelFor(cbSize);
    addToGB(lblSize, this, gridbag, c);
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(cbSize, this, gridbag, c);

    c.weightx = 0.0;
    c.gridwidth = 1;
    lblSource = new JLabel(getMsg("label.source"), JLabel.TRAILING);
    lblSource.setDisplayedMnemonic(getMnemonic("label.source"));
    lblSource.setLabelFor(cbSource);
    addToGB(lblSource, this, gridbag, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(cbSource, this, gridbag, c);
}
 
Example 9
Source File: ServiceDialog.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public CopiesPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = compInsets;

    lblCopies = new JLabel(getMsg("label.numcopies"), JLabel.TRAILING);
    lblCopies.setDisplayedMnemonic(getMnemonic("label.numcopies"));
    lblCopies.getAccessibleContext().setAccessibleName(
                                     getMsg("label.numcopies"));
    addToGB(lblCopies, this, gridbag, c);

    snModel = new SpinnerNumberModel(1, 1, 999, 1);
    spinCopies = new JSpinner(snModel);
    lblCopies.setLabelFor(spinCopies);
    // REMIND
    ((JSpinner.NumberEditor)spinCopies.getEditor()).getTextField().setColumns(3);
    spinCopies.addChangeListener(this);
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(spinCopies, this, gridbag, c);

    cbCollate = createCheckBox("checkbox.collate", this);
    cbCollate.setEnabled(false);
    addToGB(cbCollate, this, gridbag, c);
}
 
Example 10
Source File: ParameterDialog.java    From FancyBing with GNU General Public License v3.0 5 votes vote down vote up
public void createComponents(int gridy, JPanel panel,
                             GridBagLayout gridbag)
{
    m_checkBox = new JCheckBox(getLabel(), m_initialValue);
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = gridy;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.weightx = 1.0;
    constraints.anchor = GridBagConstraints.WEST;
    gridbag.setConstraints(m_checkBox, constraints);
    panel.add(m_checkBox);
}
 
Example 11
Source File: ListView.java    From Raccoon with Apache License 2.0 5 votes vote down vote up
public ListView() {
	setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));
	setLayout(new GridBagLayout());
	gbc = new GridBagConstraints();
	gbc.anchor = GridBagConstraints.CENTER;
	gbc.insets = new Insets(0, 0, 10, 0);
	gbc.fill = GridBagConstraints.HORIZONTAL;
	gbc.gridx = GridBagConstraints.REMAINDER;
	// We don't stretch aand depending on the LAF, the underlying container
	// might have a different color.
	setOpaque(false);
}
 
Example 12
Source File: SummaryInfoTab.java    From pcgen with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void initComponents()
{
	this.setFocusCycleRoot(true);
	this.setFocusTraversalPolicyProvider(true);
	this.setFocusTraversalPolicy(new SummaryTabFocusTraversalPolicy());

	LanguageTableModel.initializeTable(languageTable);

	setLayout(new GridBagLayout());
	GridBagConstraints gbc = new GridBagConstraints();

	setPanelTitle(basicsPanel, LanguageBundle.getString("in_sumCharacterBasics")); //$NON-NLS-1$
	basicsPanel.setLayout(new GridBagLayout());
	deityComboBox.setRenderer(infoBoxRenderer);
	raceComboBox.setRenderer(infoBoxRenderer);
	classComboBox.setRenderer(classBoxRenderer);
	gbc.fill = GridBagConstraints.BOTH;
	gbc.weightx = 0.1;
	gbc.weighty = 0.7;
	add(basicsPanel, gbc);

	setPanelTitle(todoPanel, LanguageBundle.getString("in_tipsString")); //$NON-NLS-1$
	initTodoPanel(todoPanel);
	gbc.gridy = 1;
	gbc.gridheight = GridBagConstraints.REMAINDER;
	add(todoPanel, gbc);

	initMiddlePanel(scoresPanel);
	gbc.gridy = GridBagConstraints.RELATIVE;
	gbc.weightx = 1;
	add(scoresPanel, gbc);

	JPanel rightPanel = new JPanel();
	setPanelTitle(racePanel, LanguageBundle.getString("in_raceString")); //$NON-NLS-1$
	setPanelTitle(classPanel, LanguageBundle.getString("in_sumClassLevel")); //$NON-NLS-1$
	initRightPanel(rightPanel);
	gbc.weightx = 0.1;
	gbc.weighty = 1;
	add(rightPanel, gbc);
}
 
Example 13
Source File: ServiceDialog.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public CopiesPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = compInsets;

    lblCopies = new JLabel(getMsg("label.numcopies"), JLabel.TRAILING);
    lblCopies.setDisplayedMnemonic(getMnemonic("label.numcopies"));
    lblCopies.getAccessibleContext().setAccessibleName(
                                     getMsg("label.numcopies"));
    addToGB(lblCopies, this, gridbag, c);

    snModel = new SpinnerNumberModel(1, 1, 999, 1);
    spinCopies = new JSpinner(snModel);
    lblCopies.setLabelFor(spinCopies);
    // REMIND
    ((JSpinner.NumberEditor)spinCopies.getEditor()).getTextField().setColumns(3);
    spinCopies.addChangeListener(this);
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(spinCopies, this, gridbag, c);

    cbCollate = createCheckBox("checkbox.collate", this);
    cbCollate.setEnabled(false);
    addToGB(cbCollate, this, gridbag, c);
}
 
Example 14
Source File: ServiceDialog.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private JLabel addLabel(String text,
                        GridBagLayout gridbag, GridBagConstraints c)
{
    c.gridwidth = 1;
    addToGB(new JLabel(text, JLabel.TRAILING), this, gridbag, c);

    c.gridwidth = GridBagConstraints.REMAINDER;
    JLabel label = new JLabel();
    addToGB(label, this, gridbag, c);

    return label;
}
 
Example 15
Source File: ServiceDialog.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public MediaPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    cbSize = new JComboBox();
    cbSource = new JComboBox();

    c.fill = GridBagConstraints.BOTH;
    c.insets = compInsets;
    c.weighty = 1.0;

    c.weightx = 0.0;
    lblSize = new JLabel(getMsg("label.size"), JLabel.TRAILING);
    lblSize.setDisplayedMnemonic(getMnemonic("label.size"));
    lblSize.setLabelFor(cbSize);
    addToGB(lblSize, this, gridbag, c);
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(cbSize, this, gridbag, c);

    c.weightx = 0.0;
    c.gridwidth = 1;
    lblSource = new JLabel(getMsg("label.source"), JLabel.TRAILING);
    lblSource.setDisplayedMnemonic(getMnemonic("label.source"));
    lblSource.setLabelFor(cbSource);
    addToGB(lblSource, this, gridbag, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    addToGB(cbSource, this, gridbag, c);
}
 
Example 16
Source File: BasicStrokeEditor.java    From pentaho-reporting with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 *
 */
private void initGUI() {
  this.setLayout( new GridBagLayout() );
  final GridBagConstraints constraints = new GridBagConstraints();

  // Add the width label
  constraints.gridx = 0;
  constraints.gridy = 0;
  constraints.anchor = GridBagConstraints.EAST;
  this.add( new JLabel( "Width:" ), constraints );

  // Add the spinner with its model
  constraints.gridx = 1;
  constraints.gridy = 0;
  constraints.anchor = GridBagConstraints.WEST;
  final JTextField strokeWidthField = new JTextField();
  strokeWidthField.getDocument().addDocumentListener( new WidthUpdateHandler( strokeWidthField ) );
  strokeWidthField.setText( String.valueOf( width ) );
  strokeWidthField.setColumns( 6 );
  this.add( strokeWidthField, constraints );

  // Add the dash Label
  constraints.gridx = 0;
  constraints.gridy = 1;
  constraints.anchor = GridBagConstraints.CENTER;
  this.add( new JLabel( "Dashes:" ), constraints );

  // Add the dash comboBox
  constraints.gridx = 1;
  constraints.gridy = 1;

  final JComboBox dashComboBox =
      new JComboBox( new Object[] { BorderStyle.SOLID, BorderStyle.DASHED, BorderStyle.DOTTED,
        BorderStyle.DOT_DASH, BorderStyle.DOT_DOT_DASH } );
  dashComboBox.setRenderer( new BorderStyleRenderer() );
  dashComboBox.setSelectedItem( borderStyle );
  dashComboBox.addActionListener( new DashSelectionHandler( dashComboBox ) );
  this.add( dashComboBox, constraints );

  // Add the sample box
  constraints.gridx = 0;
  constraints.gridy = 2;
  constraints.gridwidth = GridBagConstraints.REMAINDER;
  constraints.fill = GridBagConstraints.HORIZONTAL;

  this.add( samplePanel, constraints );
}
 
Example 17
Source File: UnitDisplay.java    From megamek with GNU General Public License v2.0 4 votes vote down vote up
public UnitDisplay(@Nullable ClientGUI clientgui,
        @Nullable MegaMekController controller) {
    super(new GridBagLayout());
    this.clientgui = clientgui;

    tabStrip = new MechPanelTabStrip(this);

    displayP = new JPanel(new CardLayout());
    mPan = new MovementPanel();
    displayP.add("movement", mPan); //$NON-NLS-1$
    pPan = new PilotPanel(this);
    displayP.add("pilot", pPan); //$NON-NLS-1$
    aPan = new ArmorPanel(clientgui != null ? clientgui.getClient().getGame() : null, this);
    displayP.add("armor", aPan); //$NON-NLS-1$
    wPan = new WeaponPanel(this);
    displayP.add("weapons", wPan); //$NON-NLS-1$
    sPan = new SystemPanel(this);
    displayP.add("systems", sPan); //$NON-NLS-1$
    ePan = new ExtraPanel(this);
    displayP.add("extras", ePan); //$NON-NLS-1$

    // layout main panel
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(4, 1, 0, 1);

    c.weightx = 1.0;
    c.weighty = 0.0;

    c.gridwidth = GridBagConstraints.REMAINDER;
    addBag(tabStrip, c);
    c.insets = new Insets(0, 1, 1, 1);
    c.weighty = 1.0;
    addBag(displayP, c);

    ((CardLayout) displayP.getLayout()).show(displayP, "movement"); //$NON-NLS-1$
    
    if (controller != null) {
        registerKeyboardCommands(this, controller);
    }
}
 
Example 18
Source File: ServiceDialog.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
public JobAttributesPanel() {
    super();

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    setLayout(gridbag);
    setBorder(BorderFactory.createTitledBorder(strTitle));

    c.fill = GridBagConstraints.NONE;
    c.insets = compInsets;
    c.weighty = 1.0;

    cbJobSheets = createCheckBox("checkbox.jobsheets", this);
    c.anchor = GridBagConstraints.LINE_START;
    addToGB(cbJobSheets, this, gridbag, c);

    JPanel pnlTop = new JPanel();
    lblPriority = new JLabel(getMsg("label.priority"), JLabel.TRAILING);
    lblPriority.setDisplayedMnemonic(getMnemonic("label.priority"));

    pnlTop.add(lblPriority);
    snModel = new SpinnerNumberModel(1, 1, 100, 1);
    spinPriority = new JSpinner(snModel);
    lblPriority.setLabelFor(spinPriority);
    // REMIND
    ((JSpinner.NumberEditor)spinPriority.getEditor()).getTextField().setColumns(3);
    spinPriority.addChangeListener(this);
    pnlTop.add(spinPriority);
    c.anchor = GridBagConstraints.LINE_END;
    c.gridwidth = GridBagConstraints.REMAINDER;
    pnlTop.getAccessibleContext().setAccessibleName(
                               getMsg("label.priority"));
    addToGB(pnlTop, this, gridbag, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.CENTER;
    c.weightx = 0.0;
    c.gridwidth = 1;
    char jmnemonic = getMnemonic("label.jobname");
    lblJobName = new JLabel(getMsg("label.jobname"), JLabel.TRAILING);
    lblJobName.setDisplayedMnemonic(jmnemonic);
    addToGB(lblJobName, this, gridbag, c);
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    tfJobName = new JTextField();
    lblJobName.setLabelFor(tfJobName);
    tfJobName.addFocusListener(this);
    tfJobName.setFocusAccelerator(jmnemonic);
    tfJobName.getAccessibleContext().setAccessibleName(
                                     getMsg("label.jobname"));
    addToGB(tfJobName, this, gridbag, c);

    c.weightx = 0.0;
    c.gridwidth = 1;
    char umnemonic = getMnemonic("label.username");
    lblUserName = new JLabel(getMsg("label.username"), JLabel.TRAILING);
    lblUserName.setDisplayedMnemonic(umnemonic);
    addToGB(lblUserName, this, gridbag, c);
    c.gridwidth = GridBagConstraints.REMAINDER;
    tfUserName = new JTextField();
    lblUserName.setLabelFor(tfUserName);
    tfUserName.addFocusListener(this);
    tfUserName.setFocusAccelerator(umnemonic);
    tfUserName.getAccessibleContext().setAccessibleName(
                                     getMsg("label.username"));
    addToGB(tfUserName, this, gridbag, c);
}
 
Example 19
Source File: TableDemo.java    From beautyeye with Apache License 2.0 4 votes vote down vote up
protected JPanel createControlPanel() {
	JPanel controlPanel = new JPanel();
	GridBagLayout gridbag = new GridBagLayout();
	GridBagConstraints c = new GridBagConstraints();
	controlPanel.setLayout(gridbag);

	c.gridx = 0;
	c.gridy = 1;
	c.gridheight = 1;
	c.insets = new Insets(20, 10, 0, 10);
	c.anchor = GridBagConstraints.SOUTHWEST;
	JLabel searchLabel = new JLabel(getString("TableDemo.searchLabel",
			"Search Titles and Recipients"));
	controlPanel.add(searchLabel, c);

	c.gridx = 0;
	c.gridy = 2;
	c.weightx = 1.0;
	c.insets.top = 0;
	c.insets.bottom = 12;
	c.anchor = GridBagConstraints.SOUTHWEST;
	// c.fill = GridBagConstraints.HORIZONTAL;
	filterField = new JTextField(24);
	filterField.getDocument().addDocumentListener(
			new SearchFilterListener());
	controlPanel.add(filterField, c);

	c.gridx = 1;
	c.gridy = 2;
	c.gridwidth = GridBagConstraints.REMAINDER;
	// c.insets.right = 24;
	// c.insets.left = 12;
	c.weightx = 0.0;
	c.anchor = GridBagConstraints.EAST;
	c.fill = GridBagConstraints.NONE;
	winnersCheckbox = new JCheckBox(getString("TableDemo.winnersLabel",
			"Show Only Winners"));
	winnersCheckbox.addChangeListener(new ShowWinnersListener());
	controlPanel.add(winnersCheckbox, c);

	return controlPanel;
}
 
Example 20
Source File: Query.java    From OpenDA with GNU Lesser General Public License v3.0 4 votes vote down vote up
/** Add a label and a widget to the panel.
 *  @param name The name of the entry.
 *  @param label The label.
 *  @param widget The interactive entry to the right of the label.
 *  @param entry The object that contains user data.
 */
protected void _addPair(
    String name,
    JLabel label,
    Component widget,
    Object entry) {
    // Surely there is a better layout manager in swing...
    // Note that Box and BoxLayout do not work because they do not
    // support gridded layout.
    _constraints.gridwidth = 1;
    _constraints.insets = _leftPadding;
    _grid.setConstraints(label, _constraints);
    _entryPanel.add(label);

    _constraints.insets = _noPadding;
    if (_columns > 1 && ((_entries.size() + 1) % _columns != 0)) {
        _constraints.gridwidth = 1;
    } else {
        _constraints.gridwidth = GridBagConstraints.REMAINDER;
    }
    _grid.setConstraints(widget, _constraints);
    _entryPanel.add(widget);

    _entries.put(name, entry);
    _labels.put(name, label);
    _previous.put(name, getStringValue(name));

    Dimension preferredSize = _entryPanel.getPreferredSize();
    // Add some slop to the width to take in to account
    // the width of the vertical scrollbar.
    preferredSize.width += 25;

    // Applets seem to need this, see CT/SigmaDelta
    _widgetsHeight += widget.getPreferredSize().height;
    preferredSize.height = _widgetsHeight;

    Toolkit tk = Toolkit.getDefaultToolkit();
    if (preferredSize.height > tk.getScreenSize().height) {
        // Fudge factor to keep this window smaller than the screen
        // height.  CGSUnitBase and the Code Generator are good tests.
        preferredSize.height = (int) (tk.getScreenSize().height * 0.75);
        _entryScrollPane.setPreferredSize(preferredSize);
    }

    _entryScrollPane.setPreferredSize(preferredSize);
    // Call revalidate for the scrollbar.
    _entryPanel.revalidate();
}