本文整理匯總了Java中javax.swing.JLabel.getIconTextGap方法的典型用法代碼示例。如果您正苦於以下問題:Java JLabel.getIconTextGap方法的具體用法?Java JLabel.getIconTextGap怎麽用?Java JLabel.getIconTextGap使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.getIconTextGap方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isCellEditable
import javax.swing.JLabel; //導入方法依賴的package包/類
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);
}
示例2: CustomizerPane
import javax.swing.JLabel; //導入方法依賴的package包/類
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() );
}