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

The following are Jave code examples for showing how to use getFont() 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: incubator-netbeans   File: CreateRulePanel.java   View Source Code Vote up 6 votes
public SelectorItemRenderer() {
    west = new JLabel();
    east = new JLabel();
    setLayout(new BorderLayout());
    add(west, BorderLayout.WEST);
    add(east, BorderLayout.EAST);

    fg = javax.swing.UIManager.getDefaults().getColor("ComboBox.foreground");
    bg = javax.swing.UIManager.getDefaults().getColor("ComboBox.background");
    fgSelected = javax.swing.UIManager.getDefaults().getColor("ComboBox.selectionForeground");
    bgSelected = javax.swing.UIManager.getDefaults().getColor("ComboBox.selectionBackground");
    inFile = Color.gray;

    plain = west.getFont();
    bold = plain.deriveFont(Font.BOLD);
}
 
Example 2
Project: rapidminer   File: SurfacePlot3D.java   View Source Code Vote up 6 votes
@Override
public JComponent getPlotter() {
	DataTable table = getDataTable();
	if (table != null && table.getNumberOfRows() > MAX_NUMBER_OF_ROWS) {
		LogService.getRoot().log(Level.INFO, "com.rapidminer.gui.plotter.mathplot.SurfacePlot2D.too_many_examples",
				new Object[] { table.getNumberOfRows(), MAX_NUMBER_OF_ROWS });
		// Display Label with error message because Plot3DPanel can not handle such a lot of
		// data points
		JLabel label = new JLabel(I18N.getGUILabel("surface3DPlot.too_many_examples", MAX_NUMBER_OF_ROWS));
		label.setHorizontalAlignment(SwingConstants.CENTER);
		Font originalFont = label.getFont();
		label.setFont(originalFont.deriveFont((float) (originalFont.getSize() * 1.25)));
		originalFont.deriveFont(new AffineTransform());

		return label;
	} else {
		return super.getPlotter();
	}
}
 
Example 3
Project: rapidminer   File: SettingsPropertyPanel.java   View Source Code Vote up 6 votes
/**
 * Creates a panel with a heading.
 *
 * @param labelText
 *            The text for the heading
 *
 * @return The panel
 */
private JPanel createSubGroupPanel(String labelText) {
    JLabel subGroupLabel = new JLabel();
    Font font = subGroupLabel.getFont();
    font = font.deriveFont(Font.BOLD, 14f);
    subGroupLabel.setFont(font);
    subGroupLabel.setForeground(SettingsTabs.COLOR_SUBGROUP);
    subGroupLabel.setText(labelText);
    int top = SUBGROUP_TOP_MARGIN;
    if (isFirstSubGroup) {
        isFirstSubGroup = false;
        top = FIRST_SUBGROUP_TOP_MARGIN;
    }
    subGroupLabel.setBorder(BorderFactory.createEmptyBorder(top, 0, 7, 0));

    JPanel subGroupPanel = new JPanel();
    subGroupPanel.setLayout(new BoxLayout(subGroupPanel, BoxLayout.LINE_AXIS));
    subGroupPanel.add(subGroupLabel);
    subGroupPanel.add(Box.createHorizontalGlue());
    return subGroupPanel;
}
 
Example 4
Project: VASSAL-src   File: WizardDisplayerImpl.java   View Source Code Vote up 5 votes
protected void buildStepTitle()
{
    ttlLabel = new JLabel(wizard.getStepDescription(wizard.getAllSteps()[0]));
    ttlLabel.setBorder(BorderFactory.createCompoundBorder(BorderFactory
        .createEmptyBorder(5, 5, 12, 5), BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager
        .getColor("textText")))); // NOI18N
    ttlPanel = new JPanel()
    {
        private static final long serialVersionUID = 1L;
        public void doLayout()
        {
            Dimension d = ttlLabel.getPreferredSize();
            if (ttlLabel.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
            {
                ttlLabel.setBounds(getWidth() - d.width, 0, getWidth(), d.height);
            }
            else
            {
                ttlLabel.setBounds(0, 0, getWidth(), d.height);
            }
        }

        public Dimension getPreferredSize()
        {
            return ttlLabel.getPreferredSize();
        }
    };
    ttlPanel.add(ttlLabel);
    Font f = ttlLabel.getFont();
    if (f == null)
    {
        f = UIManager.getFont("controlFont"); // NOI18N
    }
    if (f != null)
    {
        f = f.deriveFont(Font.BOLD);
        ttlLabel.setFont(f);
    }

}
 
Example 5
Project: VASSAL-src   File: Dialogs.java   View Source Code Vote up 5 votes
/**
 * Creates dialog contents with the given title and description.
 *
 * @param title the title
 * @param description the description
 */
private static Component buildContents(String title, String description) {
  final JLabel titleLabel = new JLabel(title);
  final Font f = titleLabel.getFont();
  titleLabel.setFont(f.deriveFont(Font.BOLD, f.getSize()*1.2f));

  final FlowLabel descriptionLabel = new FlowLabel(description);

  final JPanel panel = new JPanel();
  final GroupLayout layout = new GroupLayout(panel);
  panel.setLayout(layout);

  layout.setAutocreateGaps(true);
  layout.setAutocreateContainerGaps(false);

  layout.setHorizontalGroup(
    layout.createParallelGroup(GroupLayout.LEADING, true)
      .add(titleLabel)
      .add(descriptionLabel));

  layout.setVerticalGroup(
    layout.createSequentialGroup()
      .add(titleLabel)
      .addPreferredGap(LayoutStyle.UNRELATED)
      .add(descriptionLabel));

  return panel;
}
 
Example 6
Project: open-java-trade-manager   File: ChartJDialog.java   View Source Code Vote up 5 votes
/**
 * Reset all day labels back to plain font.
 */
private void resetAllDayLabels() {
    JLabel[] labels = {jLabel9, jLabel10, jLabel11, jLabel12, jLabel13, jLabel14, jLabel5, jLabel6};
    for (JLabel label : labels) {
        final Font oldFont = label.getFont();
        // Reset BOLD attribute.
        final Font font = oldFont.deriveFont(oldFont.getStyle() & ~Font.BOLD);
        label.setFont(font);
    }
}
 
Example 7
Project: org.alloytools.alloy   File: PreferencesDialog.java   View Source Code Vote up 5 votes
private <T> Hashtable<Integer,JLabel> mkDict(final ChoicePref<T> pref) {
	Hashtable<Integer,JLabel> dict = new Hashtable<Integer,JLabel>();
	int sel = pref.getSelectedIndex();
	for (int i = 0; i < pref.validChoices().size(); i++) {
		JLabel label = makeLabel(pref.renderValueShort(pref.validChoices().get(i)));
		if (i == sel) {
			Font font = label.getFont();
			label = OurUtil.make(label, new Font(font.getName(), Font.BOLD, font.getSize()));
		}
		dict.put(i, label);
	}
	return dict;
}
 
Example 8
Project: Equella   File: UniversalControlSettingPanel.java   View Source Code Vote up 5 votes
/**
 * Uses a MigLayout("wrap 2, insets 10 15 20 5", "[][fill, grow]")
 */
protected UniversalControlSettingPanel()
{
	super(new MigLayout("wrap 2, insets 10 15 20 5", "[][fill, grow]"));
	JLabel label = new JLabel(CurrentLocale.get(getTitleKey()));
	Font titleFont = label.getFont();
	label.setFont(new Font(titleFont.getName(), Font.BOLD, titleFont.getSize()));
	add(label, "span 2, gapbottom 10");
}
 
Example 9
Project: geomapapp   File: GeneralUtils.java   View Source Code Vote up 5 votes
/**
 * Create a JEditorPane that will convert the text into html with working hyperlinks.
 * This can be included in a messageDialog with, e.g.
 * JOptionPane.showMessageDialog(null, ep)
 * @param text
 * @return
 */
public static JEditorPane makeEditorPane(String text) {
    // for copying style
    JLabel label = new JLabel();
    Font font = label.getFont();

    // create some css from the label's font
    StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
    style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
    style.append("font-size:" + font.getSize() + "pt;");
	
    //need to use editor pane and hyperlink listener so that we can include hyperlinks in help text
    JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
            + text //
            + "</body></html>");

    ep.addHyperlinkListener(new HyperlinkListener()
    {
        @Override
        public void hyperlinkUpdate(HyperlinkEvent e)
        {
            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
            	BrowseURL.browseURL(e.getURL().toString());
        }
    });
	ep.setEditable(false);
	ep.setBackground(label.getBackground());
	
	return ep;
}
 
Example 10
Project: scorekeeperfrontend   File: BaseDialog.java   View Source Code Vote up 5 votes
/**
 * Create a new label with some default look
 * @param name		the string data for the label
 * @param bold		whether or not to make the Font bold
 * @return			a pointer to the new JLabel
 */
protected JLabel label(String name, boolean bold)
{
    JLabel lbl = new JLabel(name);

    Font base = lbl.getFont();
    if (bold) lbl.setFont(base.deriveFont(Font.BOLD));
    else lbl.setFont(base.deriveFont(Font.PLAIN));

    labels.put(name, lbl);
    return lbl;
}
 
Example 11
Project: incubator-netbeans   File: BrowserMenu.java   View Source Code Vote up 4 votes
private JComponent createHeader( String title ) {
    JLabel label = createLabel( title );
    Font defaultFont = label.getFont();
    label.setFont( defaultFont.deriveFont( Font.BOLD ).deriveFont( defaultFont.getSize2D()+2.0f ));
    return label;
}
 
Example 12
Project: BrainControl   File: TextToSpeech.java   View Source Code Vote up 4 votes
private void showErrorMessage() {
		 // for copying style
	    JLabel label = new JLabel();
	    Font font = label.getFont();

	    // create some css from the label's font
	    StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
	    style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
	    style.append("font-size:" + font.getSize() + "pt;");
		 JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">"//
		            + "TextToSpeech executable not found."
		            + "<br>Please make sure that the path variable leads to the espeak executable!"
		            + "<br>If you do not have espeak installed yet, please download it from <a href=http://espeak.sourceforge.net\">http://espeak.sourceforge.net</a>."
		            + "<br>Linux users can use the following command: 'sudo apt-get install espeak' " //
		            + "</body></html>");

		    // handle link events
		    ep.addHyperlinkListener(new HyperlinkListener()
		    {
		        @Override
		        public void hyperlinkUpdate(HyperlinkEvent e)
		        {
		            if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
		            	if (Desktop.isDesktopSupported()) {
		            	      Desktop desktop = Desktop.getDesktop();
		            	      try {
		            	        desktop.browse(e.getURL().toURI());
		            	      } catch (IOException f) {
		            	        JOptionPane.showMessageDialog(null,
		            	            "Failed to launch the link, your computer is likely misconfigured.",
		            	            "Cannot Launch Link",JOptionPane.WARNING_MESSAGE);
		            	      } catch (URISyntaxException e1) {
								// TODO Auto-generated catch block
								e1.printStackTrace();
							}
		            	    } else {
		            	      JOptionPane.showMessageDialog(null,
		            	          "Java is not able to launch links on your computer.",
		            	          "Cannot Launch Link", JOptionPane.WARNING_MESSAGE);
		            	    }
//		                ProcessHandler.launchUrl(e.getURL().toString()); // roll your own link launcher or use Desktop if J6+
		        }
		    });
		    ep.setEditable(false);
		    ep.setBackground(label.getBackground());

//
//		JOptionPane.showMessageDialog(PlayRelease.startGui, "TextToSpeech executable not found.\nPlease make sure that the path variable leads to the espeak executable!\nIf you do not have espeak installed yet, please downlaod it from '<HTML>http://espeak.sourceforge.net/</HTML>'."
//				+ "\n Linux users can use the following command: sudo apt-get install espeak","Error occurred",JOptionPane.ERROR_MESSAGE);
		JOptionPane.showMessageDialog(PlayRelease.startGui, ep,"Error occurred",JOptionPane.ERROR_MESSAGE);
	}
 
Example 13
Project: Equella   File: FileListPanel.java   View Source Code Vote up 4 votes
public Renderer()
{
	dateFormat = new SimpleDateFormat();

	icon = new IconLabel();

	filename = new JLabel(" ");
	// filename.setVerticalAlignment(SwingConstants.CENTER);

	Font f = filename.getFont();
	filename.setFont(f.deriveFont((float) (f.getSize() + 2)));

	sizeLabel = new JLabel(CurrentLocale.get("cell.size"));
	size = new JLabel();
	modifiedLabel = new JLabel(CurrentLocale.get("cell.modified"));
	modified = new JLabel();

	Dimension modPrefSize = modifiedLabel.getPreferredSize();
	final int width1 = 40;
	final int width2 = Math.max(sizeLabel.getPreferredSize().width, modPrefSize.width) + 5;
	final int height1 = filename.getPreferredSize().height;
	final int height2 = modPrefSize.height;

	MigLayout layout = new MigLayout("", "[" + width1 + "][" + width2 + "][200 - " + (width2 + width1) + "]",
		"[" + height1 + "]2[" + height2 + "]2[" + height2 + "]");

	base = new JPanel(layout);
	base.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
	base.setBackground(Color.WHITE);

	base.add(icon, "cell 0 0, spany 3");
	base.add(filename, "cell 1 0, spanx 2");
	base.add(sizeLabel, "cell 1 1");
	base.add(size, "cell 2 1");
	base.add(modifiedLabel, "cell 1 2");
	base.add(modified, "cell 2 2");
	int prefHeight = height1 + (height2 * 2) + 24; // size of the 3 rows
													// plus a little
													// padding

	base.setPreferredSize(new Dimension(MAX_CELL_WIDTH, prefHeight));
	base.setMaximumSize(new Dimension(MAX_CELL_WIDTH, prefHeight));
	base.setMinimumSize(new Dimension(MAX_CELL_WIDTH, prefHeight));

	if( CurrentLocale.isRightToLeft() )
	{
		base.applyComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);

	}
}
 
Example 14
Project: Equella   File: GlassProgressPane.java   View Source Code Vote up 4 votes
protected GlassProgressPane(final String messageText, final int total, final Component activeComponent,
	final boolean stopClosing, final AdvancedSwingWorker<?> worker, final boolean cancellable)
{
	super(activeComponent, stopClosing);

	this.worker = worker;

	message = new JLabel(messageText);
	message.setForeground(Color.WHITE);
	message.setHorizontalAlignment(SwingConstants.CENTER);
	message.setHorizontalTextPosition(SwingConstants.CENTER);

	Font font = message.getFont();
	message.setFont(new Font(font.getFamily(), Font.BOLD, (int) (font.getSize() * 1.2)));

	progress = new JProgressBar();
	setTotal(total);

	// We cannot I18N the button text, as this class is initialised before
	// CurrentLocale.
	cancel = new JButton("Cancel");
	cancel.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			cancel.setEnabled(false);
			GlassProgressPane.this.worker.interrupt();
		}
	});

	final int height1 = message.getPreferredSize().height;
	final int height2 = progress.getPreferredSize().height;
	final int height3 = cancel.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

	final int[] rows = {height3, TableLayout.FILL, height1, height2, TableLayout.FILL, height3,};
	final int[] cols = {width1, TableLayout.FILL, 100, TableLayout.FILL, width1,};

	setLayout(new TableLayout(rows, cols));
	setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
	add(message, new Rectangle(0, 2, 5, 1));
	add(progress, new Rectangle(2, 3, 1, 1));
	add(cancel, new Rectangle(4, 5, 1, 1));

	setCancellable(cancellable);
}
 
Example 15
Project: enigma-vk   File: GuiTricks.java   View Source Code Vote up 4 votes
public static JLabel unboldLabel(JLabel label) {
	Font font = label.getFont();
	label.setFont(font.deriveFont(font.getStyle() & ~Font.BOLD));
	return label;
}