Java Code Examples for javax.swing.JLabel#getLabelFor()

The following examples show how to use javax.swing.JLabel#getLabelFor() . These examples are extracted from open source projects. 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
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 2
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 3
Source Project: jdk8u60   File: TestObject.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 4
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 5
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 6
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 7
private static JComboBox findComboBox(Component comp) {

        if (comp instanceof JLabel) {
            JLabel label = (JLabel) comp;
            if (LABEL_TEXT.equals(label.getText())) {
                return (JComboBox) label.getLabelFor();
            }
        }

        if (comp instanceof Container) {
            Container cont = (Container) comp;
            for (int i = 0; i < cont.getComponentCount(); i++) {

                JComboBox result = findComboBox(cont.getComponent(i));
                if (result != null) {
                    return result;
                }
            }
        }

        return null;
    }
 
Example 8
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 9
Source Project: hottub   File: TestObject.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 10
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 11
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 12
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 13
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 14
@Override
protected void validate(XMLDecoder decoder) {
    JPanel panel = (JPanel) decoder.readObject();
    if (2 != panel.getComponents().length) {
        throw new Error("unexpected component count");
    }
    JButton button = (JButton) panel.getComponents()[0];
    if (!button.getText().equals("button")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected button text");
    }
    if (SwingConstants.CENTER != button.getVerticalAlignment()) {
        throw new Error("unexpected vertical alignment");
    }
    JLabel label = (JLabel) panel.getComponents()[1];
    if (!label.getText().equals("label")) { // NON-NLS: hardcoded in XML
        throw new Error("unexpected label text");
    }
    if (button != label.getLabelFor()) {
        throw new Error("unexpected component");
    }
}
 
Example 15
Source Project: netbeans   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
public static void hideLabelAndLabelFor(JComponent component, String lab) {
    JLabel label = findLabel(component, lab);
    if (label != null) {
        label.setVisible(false);
        Component c = label.getLabelFor();
        if (c != null) {
            c.setVisible(false);
        }
    }
}
 
Example 16
Source Project: netbeans   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
public static void hideLabelAndLabelFor(JComponent component, String lab) {
    JLabel label = findLabel(component, lab);
    if (label != null) {
        label.setVisible(false);
        Component c = label.getLabelFor();
        if (c != null) {
            c.setVisible(false);
        }
    }
}
 
Example 17
Source Project: netbeans   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
public static void hideLabelAndLabelFor(JComponent component, String lab) {
    JLabel label = findLabel(component, lab);
    if(label != null) {
        label.setVisible(false);
        Component c = label.getLabelFor();
        if(c != null) {
            c.setVisible(false);
        }
    }
}
 
Example 18
Source Project: netbeans   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
public static void hideLabelAndLabelFor(JComponent component, String lab) {
    JLabel label = findLabel(component, lab);
    if(label != null) {
        label.setVisible(false);
        Component c = label.getLabelFor();
        if(c != null) {
            c.setVisible(false);
        }
    }
}
 
Example 19
Source Project: netbeans   File: Util.java    License: Apache License 2.0 5 votes vote down vote up
public static void hideLabelAndLabelFor(JComponent component, String lab) {
    JLabel label = findLabel(component, lab);
    if(label != null) {
        label.setVisible(false);
        Component c = label.getLabelFor();
        if(c != null) {
            c.setVisible(false);
        }
    }
}
 
Example 20
/**
 * Creates a JPanel with the specified options. Interal use only.
 * 
 * @param opts the options
 * @return a jpanel
 */
private static JPanel optionsPanel(final List<Option> opts) {
	final JPanel options = new JPanel();
	final GroupLayout gl = new GroupLayout(options);

	options.setLayout(gl);
	gl.setAutoCreateGaps(true);
	gl.setAutoCreateContainerGaps(true);

	final GroupLayout.ParallelGroup labels = gl.createParallelGroup();
	final GroupLayout.ParallelGroup values = gl.createParallelGroup();
	final GroupLayout.ParallelGroup titles = gl.createParallelGroup();
	final GroupLayout.ParallelGroup horiz = gl.createParallelGroup();
	final GroupLayout.SequentialGroup cols = gl.createSequentialGroup();
	final GroupLayout.SequentialGroup rows = gl.createSequentialGroup();

	cols.addGroup(labels);
	cols.addGroup(values);
	horiz.addGroup(cols);
	horiz.addGroup(titles);

	for (final Option o : opts) {
		final JLabel l = o.getLabel();
		final JComponent c = o.getComponent();

		if (c == null) {
			// This is a label-only row, allowed to take up the whole row
			titles.addComponent(l);
			rows.addComponent(l);
		} else {
			if (l.getBorder() == null) {
				l.setBorder(new EmptyBorder(3, 0, 0, 0));
			}

			if (l.getLabelFor() == null) {
				l.setLabelFor(c);
			}

			labels.addComponent(l);
			values.addComponent(c);

			final GroupLayout.ParallelGroup row = gl.createParallelGroup(GroupLayout.Alignment.BASELINE);

			row.addComponent(l);
			row.addComponent(c);
			rows.addGroup(row);
		}
	}

	gl.setHorizontalGroup(horiz);
	gl.setVerticalGroup(rows);

	return options;
}