Java Code Examples for java.awt.Component#setName()

The following examples show how to use java.awt.Component#setName() . 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: LayoutModelTest.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void prepareModel() {
    TabData[] td = new TabData[25];
    int ct = 0;
    for (char c='a'; c < 'z'; c++) {
        char[] ch = new char[ct+1];
        Arrays.fill (ch, c);
        String name = new String (ch);
        Component comp = new JLabel(name);
        comp.setName (name);
        td[ct] = new TabData (comp, ic, name, "tip:"+name);
        ct++;
    }
    padX = 2;
    padY = 2;
    mdl = new DefaultTabDataModel (td);
    JLabel jl = new JLabel();
    jl.setBorder (BorderFactory.createEmptyBorder());
    lay = new TestLayoutModel (mdl, jl);
    lay.setPadding (new Dimension(padX, padY));
}
 
Example 2
Source File: DataModelTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void prepareModel() {
    if (mdl != null) {
        mdl.removeComplexListDataListener(this);
    }
    TabData[] td = new TabData[25];
    int ct = 0;
    for (char c='a'; c < 'z'; c++) {
        String name = new String (new char[]{c});
        Component comp = new JLabel(name);
        comp.setName (name);
        td[ct] = new TabData (comp, ic, name, "tip:"+name);
        ct++;
    }
    mdl = new DefaultTabDataModel (td);
}
 
Example 3
Source File: LuckSpinnerUI.java    From littleluck with Apache License 2.0 5 votes vote down vote up
/**
 * <p>使用{@link LuckArrowButton}替换默认按钮。</p>
 *
 * <p>use {@link LuckArrowButton} to replace the default button.</p>
 */
protected Component createNextButton()
{
    Component c = createArrowButton(SwingConstants.NORTH);

    c.setName("Spinner.nextButton");

    installNextButtonListeners(c);

    return c;
}
 
Example 4
Source File: LuckSpinnerUI.java    From littleluck with Apache License 2.0 5 votes vote down vote up
/**
 * <p>使用{@link LuckArrowButton}替换默认按钮。</p>
 *
 * <p>use {@link LuckArrowButton} to replace the default button.</p>
 */
protected Component createPreviousButton()
{
    Component c = createArrowButton(SwingConstants.SOUTH);

    c.setName("Spinner.previousButton");

    installPreviousButtonListeners(c);

    return c;
}
 
Example 5
Source File: SeaGlassComboBoxUI.java    From seaglass with Apache License 2.0 5 votes vote down vote up
/**
 * Paints the currently selected item.
 */
@Override
public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus) {
    ListCellRenderer renderer = comboBox.getRenderer();
    Component c;

    c = renderer.getListCellRendererComponent(listBox, comboBox.getSelectedItem(), -1, false, false);

    // Fix for 4238829: should lay out the JPanel.
    boolean shouldValidate = false;
    if (c instanceof JPanel) {
        shouldValidate = true;
    }

    if (c instanceof UIResource) {
        c.setName("ComboBox.renderer");
    }

    boolean force = forceOpaque && c instanceof JComponent;
    if (force) {
        ((JComponent) c).setOpaque(false);
    }

    int x = bounds.x, y = bounds.y, w = bounds.width, h = bounds.height;
    if (padding != null) {
        x = bounds.x + padding.left;
        y = bounds.y + padding.top;
        w = bounds.width - (padding.left + padding.right);
        h = bounds.height - (padding.top + padding.bottom);
    }

    currentValuePane.paintComponent(g, c, comboBox, x, y, w, h, shouldValidate);

    if (force) {
        ((JComponent) c).setOpaque(true);
    }

}
 
Example 6
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createVariablesButtonPanel(String labelName) {
    final JPanel variableButtonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    variableButtonsPanel.setName(labelName);

    final Component bandFilterButton = createBandFilterButton();
    bandFilterButton.setName(labelName + "_bandFilter");
    variableButtonsPanel.add(bandFilterButton);

    final Component newVariableButton = createNewVariableButton();
    newVariableButton.setName(labelName + "_newVariable");
    variableButtonsPanel.add(newVariableButton);

    final Component removeVariableButton = createRemoveVariableButton();
    removeVariableButton.setName(labelName + "_removeVariable");
    variableButtonsPanel.add(removeVariableButton);

    final Component moveVariableUpButton = createMoveVariableUpButton();
    moveVariableUpButton.setName(labelName + "moveVariableUp");
    variableButtonsPanel.add(moveVariableUpButton);

    final Component moveVariableDownButton = createMoveVariableDownButton();
    moveVariableDownButton.setName(labelName + "moveVariableDown");
    variableButtonsPanel.add(moveVariableDownButton);
    bindingCtx.addPropertyChangeListener("updateMode", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            final boolean enabled = Boolean.FALSE.equals(evt.getNewValue());
            bandFilterButton.setEnabled(enabled);
            newVariableButton.setEnabled(enabled);
            removeVariableButton.setEnabled(enabled);
            moveVariableUpButton.setEnabled(enabled);
            moveVariableDownButton.setEnabled(enabled);

        }
    });
    return variableButtonsPanel;
}
 
Example 7
Source File: MosaicExpressionsPanel.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private JPanel createConditionsButtonPanel(String labelName) {
    final JPanel conditionButtonsPanel = new JPanel(new FlowLayout(FlowLayout.LEFT, 5, 0));
    conditionButtonsPanel.setName(labelName);

    final Component newConditionButton = createNewConditionButton();
    newConditionButton.setName(labelName + "_newCondition");
    conditionButtonsPanel.add(newConditionButton);

    final Component removeConditionButton = createRemoveConditionButton();
    removeConditionButton.setName(labelName + "_removeCondition");
    conditionButtonsPanel.add(removeConditionButton);

    final Component moveConditionUpButton = createMoveConditionUpButton();
    moveConditionUpButton.setName(labelName + "moveConditionUp");
    conditionButtonsPanel.add(moveConditionUpButton);

    final Component moveConditionDownButton = createMoveConditionDownButton();
    moveConditionDownButton.setName(labelName + "moveConditionDown");
    conditionButtonsPanel.add(moveConditionDownButton);

    bindingCtx.addPropertyChangeListener("updateMode", new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            final boolean enabled = Boolean.FALSE.equals(evt.getNewValue());
            newConditionButton.setEnabled(enabled);
            removeConditionButton.setEnabled(enabled);
            moveConditionUpButton.setEnabled(enabled);
            moveConditionDownButton.setEnabled(enabled);
        }
    });

    return conditionButtonsPanel;
}
 
Example 8
Source File: FileArrayEditor.java    From snap-desktop with GNU General Public License v3.0 4 votes vote down vote up
private void setName(final Component comp, String name) {
    comp.setName(name);
}