Java Code Examples for javax.swing.JLabel.getIconTextGap()

The following are Jave code examples for showing how to use getIconTextGap() of the javax.swing.JLabel class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ramus   File: FirstRowCellEditor.java   View Source Code Vote up 6 votes
public boolean isCellEditable(final EventObject anEvent) {
    if (anEvent instanceof MouseEvent) {
        final MouseEvent event = (MouseEvent) anEvent;
        final int row = treeTable.rowAtPoint(event.getPoint());
        final Rectangle bounds = tree.getRowBounds(row);
        int offset = bounds.x;
        final Object node = tree.getPathForRow(row).getLastPathComponent();
        final boolean leaf = tree.getModel().isLeaf(node);
        final boolean expanded = tree.isExpanded(row);
        final TreeCellRenderer tcr = tree.getCellRenderer();
        final Component treeComponent = tcr.getTreeCellRendererComponent(
                tree, node, true, expanded, leaf, row, false);
        if (treeComponent instanceof JLabel) {
            final JLabel label = (JLabel) treeComponent;

            final Icon icon = label.getIcon();
            if (icon != null) {
                offset += icon.getIconWidth() + label.getIconTextGap();
            }

        }
        if (event.getPoint().x < offset)
            return false;
    }
    return deligate.isCellEditable(anEvent);
}
 
Example 2
Project: incubator-netbeans   File: CustomizerPane.java   View Source Code Vote up 4 votes
public CustomizerPane(JPanel categoryView, CategoryModel categoryModel, ProjectCustomizer.CategoryComponentProvider componentProvider) {
    initComponents();
    this.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(CustomizerPane.class,"AD_CustomizerPane")); // NOI18N
    this.componentProvider = componentProvider;
    fillConstraints = new GridBagConstraints();
    fillConstraints.gridwidth = GridBagConstraints.REMAINDER;
    fillConstraints.gridheight = 1;
    fillConstraints.fill = GridBagConstraints.BOTH;
    fillConstraints.weightx = 1.0;
    fillConstraints.weighty = 1.0;
    categoryModel.addPropertyChangeListener( new CategoryChangeListener() );
    categoryPanel.add( categoryView, fillConstraints );

    errorIcon = new JLabel();
    errorPanel = new JPanel(new BorderLayout(errorIcon.getIconTextGap(), 0)); // cf. BasicLabelUI.layoutCL
    errorPanel.add(errorIcon, BorderLayout.LINE_START);
    errorIcon.setVerticalAlignment(SwingConstants.TOP);
    errorMessageValue = new JTextArea();
    errorMessageValue.setLineWrap(true);
    errorMessageValue.setWrapStyleWord(true);
    errorMessageValue.setBorder(BorderFactory.createEmptyBorder());
    errorMessageValue.setBackground(customizerPanel.getBackground());
    errorMessageValue.setEditable(false);
    errorPanel.add(errorMessageValue, BorderLayout.CENTER);
    
    // put it into under categoryView
    errMessConstraints = new GridBagConstraints();
    errMessConstraints.gridx = 0;
    errMessConstraints.gridy = 1;
    errMessConstraints.gridwidth = 1;
    errMessConstraints.gridheight = 1;
    errMessConstraints.insets = new Insets(12, 0, 0, 0);
    errMessConstraints.fill = GridBagConstraints.HORIZONTAL;
    customizerPanel.add(errorPanel, errMessConstraints);

    /*Preferences prefs = NbPreferences.forModule(org.netbeans.modules.project.uiapi.CustomizerPane.class);
    int paneWidth = prefs.getInt(CUSTOMIZER_DIALOG_WIDTH, 0);
    int paneHeight = prefs.getInt(CUSTOMIZER_DIALOG_HEIGHT, 0);
    if (paneWidth != 0 && paneHeight != 0) {
        previousDimension = new Dimension(paneWidth, paneHeight);
    }*/

    setCategory( categoryModel.getCurrentCategory() );
}