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

The following are Jave code examples for showing how to use setIconTextGap() 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.
Example 1
Project: jmt   File: AboutDialogFactory.java   Source Code and License Vote up 6 votes
/**
 * @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;
	}
}
 
Example 2
Project: incubator-netbeans   File: JComponentBuilders.java   Source Code and License Vote up 5 votes
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);
}
 
Example 3
Project: jmt   File: AboutDialogPanel.java   Source Code and License Vote up 5 votes
/**
 * 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);
}
 
Example 4
Project: jmt   File: WarningWindow.java   Source Code and License Vote up 5 votes
/**
 * 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;
}
 
Example 5
Project: QN-ACTR-Release   File: WarningWindow.java   Source Code and License Vote up 5 votes
/**
 * 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;
}
 
Example 6
Project: incubator-netbeans   File: SwitcherTable.java   Source Code and License Vote up 4 votes
@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;
}
 
Example 7
Project: incubator-netbeans   File: FeaturesView.java   Source Code and License Vote up 4 votes
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;
    }
}