本文整理汇总了Java中javax.swing.JLabel.setIconTextGap方法的典型用法代码示例。如果您正苦于以下问题:Java JLabel.setIconTextGap方法的具体用法?Java JLabel.setIconTextGap怎么用?Java JLabel.setIconTextGap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JLabel
的用法示例。
在下文中一共展示了JLabel.setIconTextGap方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLogo
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* @return the logo of the contributor company
*/
public JComponent getLogo() {
switch (this) {
case POLIMI:
JLabel logo = new JLabel(GraphStartScreen.HTML_POLI);
logo.setHorizontalTextPosition(SwingConstants.TRAILING);
logo.setVerticalTextPosition(SwingConstants.CENTER);
logo.setIconTextGap(10);
logo.setIcon(JMTImageLoader.loadImage("logo", new Dimension(70, 70)));
return logo;
case ICL:
return new JLabel(JMTImageLoader.loadImage("logo_icl", new Dimension(-1,40)));
default:
return null;
}
}
示例2: setupInstance
import javax.swing.JLabel; //导入方法依赖的package包/类
protected void setupInstance(JLabel instance) {
super.setupInstance(instance);
instance.setText(text);
if (defaultIcon != null) instance.setIcon(defaultIcon.createInstance());
instance.setVerticalAlignment(verticalAlignment);
instance.setHorizontalAlignment(horizontalAlignment);
instance.setVerticalTextPosition(verticalTextPosition);
instance.setHorizontalTextPosition(horizontalTextPosition);
instance.setIconTextGap(iconTextGap);
}
示例3: initialize
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* Initialize the panel
*/
private void initialize() {
// Initialize dialog layout
JPanel panel = new JPanel(new BorderLayout(BORDERSIZE / 2, BORDERSIZE / 2));
panel.setBorder(BorderFactory.createEmptyBorder(BORDERSIZE, BORDERSIZE, BORDERSIZE, BORDERSIZE));
// Adds website image
JPanel tmpPanel = new JPanel(new BorderLayout(BORDERSIZE, BORDERSIZE));
// Adds polimi description
HtmlPanel titleLabel = new HtmlPanel();
titleLabel.setText(GraphStartScreen.HTML_CONTENT_TITLE_HREF);
titleLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
titleLabel.setAlignmentY(Component.CENTER_ALIGNMENT);
titleLabel.setOpaque(false);
tmpPanel.add(titleLabel, BorderLayout.CENTER);
// Adds application title
title = new JLabel();
title.setHorizontalTextPosition(SwingConstants.RIGHT);
title.setHorizontalAlignment(SwingConstants.CENTER);
title.setIconTextGap(BORDERSIZE);
tmpPanel.add(title, BorderLayout.SOUTH);
panel.add(tmpPanel, BorderLayout.NORTH);
// Adds text area
mainArea = new JPanel();
mainArea.setOpaque(false);
BoxLayout mainLayout = new BoxLayout(mainArea, BoxLayout.Y_AXIS);
mainArea.setLayout(mainLayout);
panel.add(mainArea, BorderLayout.CENTER);
JLabel legal = new JLabel(LEGAL);
panel.add(legal, BorderLayout.SOUTH);
panel.setPreferredSize(new Dimension(600,480));
JScrollPane scroll = new JScrollPane(panel, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
this.add(scroll, BorderLayout.CENTER);
}
示例4: getEntry
import javax.swing.JLabel; //导入方法依赖的package包/类
/**
* This is used to create components to be shown inside box
* @param text text to be displayed inside box
* @return created component
*/
private Component getEntry(String text) {
JLabel label = new JLabel("<HTML>" + text + "</HTML>");
label.setIcon(JMTImageLoader.loadImage("Warning"));
label.setIconTextGap(BORDER);
label.setHorizontalTextPosition(SwingConstants.RIGHT);
label.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
return label;
}
示例5: prepareRenderer
import javax.swing.JLabel; //导入方法依赖的package包/类
@Override
public Component prepareRenderer(
TableCellRenderer renderer,
int row,
int column) {
SwitcherTableItem item
= (SwitcherTableItem) getSwitcherTableModel().getValueAt(row, column);
boolean selected = row == getSelectedRow() &&
column == getSelectedColumn() && item != null;
Component ren = renderer.getTableCellRendererComponent(this, item,
selected, selected, row, column);
JLabel lbl = null;
if (ren instanceof JLabel) {
// #199007: Swing HTML renderer does a poor job of truncating long labels
JLabel prototype = (JLabel) ren;
lbl = HtmlRenderer.createLabel();
if( lbl instanceof HtmlRenderer.Renderer ) {
((HtmlRenderer.Renderer)lbl).setRenderStyle( HtmlRenderer.STYLE_TRUNCATE );
}
lbl.setForeground(prototype.getForeground());
lbl.setBackground(prototype.getBackground());
lbl.setFont(prototype.getFont());
// border, text will be overwritten below anyway
ren = lbl;
}
if (item == null) {
// it's a filler space, we're done
if( null != lbl ) {
lbl.setOpaque(false);
lbl.setIcon(null);
}
return ren;
}
Icon icon = item.getIcon();
if (icon == null || icon.getIconWidth() == 0 ) {
icon = nullIcon;
}
boolean active = item.isActive();
if( null != lbl ) {
lbl.setText((selected || (active && !TABNAMES_HTML)) ? stripHtml( item.getHtmlName() ) : item.getHtmlName());
lbl.setBorder(rendererBorder);
if( showIcons ) {
lbl.setIcon(icon);
lbl.setIconTextGap(26 - icon.getIconWidth());
}
}
if (active) {
if (TABNAMES_HTML) {
if( null != lbl )
lbl.setText(lbl.getText() + " ←"); // NOI18N
} else if (Utilities.isWindows()) {
ren.setFont(getFont().deriveFont(Font.BOLD, getFont().getSize()));
} else {
// don't use deriveFont() - see #49973 for details
ren.setFont(new Font(getFont().getName(), Font.BOLD, getFont().getSize()));
}
}
if( null != lbl )
lbl.setOpaque(true);
return ren;
}
示例6: FeaturesView
import javax.swing.JLabel; //导入方法依赖的package包/类
public FeaturesView(Component defaultView, String buttonString) {
if (UIUtils.isOracleLookAndFeel()) {
setOpaque(true);
setBackground(UIUtils.getProfilerResultsBackground());
} else {
setOpaque(false);
}
setBorder(BorderFactory.createEmptyBorder());
setLayout(new BorderLayout(0, 0));
if (defaultView != null) {
JScrollPane sp = new JScrollPane(defaultView, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER) {
public Dimension getMinimumSize() { return getPreferredSize(); }
};
sp.getVerticalScrollBar().setUnitIncrement(20);
sp.setBorder(null);
sp.setViewportBorder(null);
this.defaultView = sp;
add(this.defaultView, BorderLayout.CENTER);
} else {
this.defaultView = null;
}
if (buttonString != null) {
hintLabel = new JLabel();
hintLabel.setIcon(Icons.getIcon(GeneralIcons.INFO));
hintLabel.setIconTextGap(hintLabel.getIconTextGap() + 1);
hintLabel.setOpaque(false);
Font font = new JToolTip().getFont();
Color f = hintLabel.getForeground();
int r = f.getRed() + 70;
if (r > 255) r = f.getRed() - 70; else r = Math.min(r, 70);
int g = f.getGreen() + 70;
if (g > 255) g = f.getRed() - 70; else g = Math.min(g, 70);
int b = f.getBlue() + 70;
if (b > 255) b = f.getRed() - 70; else b = Math.min(b, 70);
hintLabel.setText("<html><body text=\"rgb(" + r + ", " + g + ", " + b + ")\" style=\"font-size: " + //NOI18N
(font.getSize()) + "pt; font-family: " + font.getName() + ";\">" + //NOI18N
Bundle.FeaturesView_noData("<b>" + buttonString + "</b>") + "</body></html>"); //NOI18N
hintLabel.setSize(hintLabel.getPreferredSize());
Color c = UIUtils.getProfilerResultsBackground();
hintColor = Utils.checkedColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), 245));
} else {
hintColor = null;
}
}