JComponent setFont - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for JComponent setFont method.

This code example shows how to use the following methods:setBackground, setFont, setForeground, setText
        final JTableHeader header = table.getTableHeader();
        final boolean isPressed = (cc == this.pressedColumn);
 
        if (this.useLabels) {
            final JLabel label = getRendererLabel(isSorting, isAscending);
            label.setText((value == null) ? "" : value.toString());
            component = label;
        } 
        else { 
            final JButton button = getRendererButton(isSorting, isAscending);
            button.setText((value == null) ? "" : value.toString());
            button.getModel().setPressed(isPressed);
            button.getModel().setArmed(isPressed);
            component = button;
        } 
 
        if (header != null) {
            component.setForeground(header.getForeground());
            component.setBackground(header.getBackground());
            component.setFont(header.getFont());

6
CodeRank
This code example shows how to use the following methods:setFont, getPreferredSize, setText, setParagraphAttributes
	@Override 
	protected void updateViewportSize(GeoText previewGeo) {
 
		Dimension d = new Dimension();
		ImageIcon testIcon = new ImageIcon();
		JTextPane dummyText = new JTextPane();
		int padding = 5; // account for inset
 
		if (previewGeo == null) {
			return; 
		} 
 
		if (previewGeo.isLaTeX()) {
			// LaTex geo, use dummy ImageIcon 
 
			GeoGebraIcon.drawLatexImageIcon(app, testIcon,
					previewGeo.getTextString(), app.getPlainFont(), true,
					Color.black, null);
			// System.out.println("=============> " + testIcon.getIconHeight() + 
			// " : " + testIcon.getIconWidth()); 

6
CodeRank
This code example shows how to use the following methods:setLocation, setSize, getPreferredSize, setFont, setForeground
      } 
 
      public void setName(String name){
         super.setName(name);
 
         this.label = new JLabel(name);
         label.setFont(f);
         label.setForeground(Color.white);
         add(label);
          
         Dimension s = label.getPreferredSize();
         label.setLocation(5,5);
         label.setSize(s);
 
         s.height += 10;
         s.width += 10;
         setActualSize(s);                
      } 
       
      public void paintComponent(Graphics g){
8
CodeRank
This code example shows how to use the following methods:setFont, setForeground
     * 
     * @return The label. 
     */ 
    public static JLabel createJLabel(final String text, final Font font, final Color color) {
 
        final JLabel result = new JLabel(text);
        result.setFont(font);
        result.setForeground(color);
        return result;
 
    } 
 
    /** 
     * Creates a {@link JButton}. 
     * 
     * @param label  the label. 
     * @param font  the font. 
     * 
     * @return The button. 
     */ 
7
CodeRank
This code example shows how to use the following methods:getFont, setFont, setForeground, setText
 
	public StatusBar(Application app) {
		setLayout(new FlowLayout(FlowLayout.LEFT));
		setBorder(BorderFactory.createLoweredBevelBorder());
 
		message = new JLabel("", SwingConstants.LEFT);
		Font font = message.getFont();
		message.setFont(font.deriveFont(Font.PLAIN, (float) (font.getSize() * 0.90)));
		message.setForeground(Color.DARK_GRAY);
		add(message);
 
		message(app.getInfo().getName() + ", V" + app.getInfo().getVersion());
	} 
 
	public void message(String txt) {
		message.setText(txt);
	} 
 
	public void message(String fmt, Object... args) {
		message(String.format(fmt, args));
	} 
7
CodeRank
This code example shows how to use the following methods:addActionListener, setActionCommand, setFont
 
    private final JTextField filename = new JTextField(10);
 
    private final JLabel label;
 
    private final JButton browse = new JButton(JMeterUtils.getResString("browse")); //$NON-NLS-1$
 
    private static final String ACTION_BROWSE = "browse"; //$NON-NLS-1$
 
    private final List<ChangeListener> listeners = new LinkedList<ChangeListener>();
 
    private final String[] filetypes;
 
    // Mainly needed for unit test Serialisable tests 
    public FilePanelEntry() { 
        this(JMeterUtils.getResString("file_visualizer_filename")); //$NON-NLS-1$ 
    } 
 
    public FilePanelEntry(String label) {
        this(label, (ChangeListener) null);

7
CodeRank
This code example shows how to use the following methods:setBackground, setFont, setForeground
    catch (Exception e) {
      e.printStackTrace();
      props = new Properties();
    } 
     
    result = new JTextPane();
    if (props.getProperty("Syntax", "false").equals("true")) {
      doc    = new SyntaxDocument(props);
      result.setDocument(doc);
      result.setBackground(doc.getBackgroundColor());
    } 
    else { 
      result.setForeground(VisualizeUtils.processColour(props.getProperty("ForegroundColor", "black"), Color.BLACK));
      result.setBackground(VisualizeUtils.processColour(props.getProperty("BackgroundColor", "white"), Color.WHITE));
      result.setFont(new Font(props.getProperty("FontName", "monospaced"), Font.PLAIN, Integer.parseInt(props.getProperty("FontSize", "12"))));
    } 
     
    return result;
  } 
   
7
CodeRank
This code example shows how to use the following methods:setFont, setForeground
This code example shows how to use the following methods:getFont, setFont, setIndeterminate, setStringPainted
canvas = new SlideShowCanvas();
        canvas.addPropertyChangeListener(model);
        getVerticalScrollBar().addMouseMotionListener(this);
        getHorizontalScrollBar().addMouseMotionListener(this);
        progressBar = new JProgressBar();
        progressBar.setStringPainted(true);
        progressBar.setIndeterminate(false);
        progressBar.setFont(progressBar.getFont().deriveFont(Font.BOLD));
        statusPane = new JPanel();
        statusPane.setOpaque(false);
        statusPane.setLayout(new BoxLayout(statusPane, BoxLayout.Y_AXIS));
        statusPane.add(progressBar);
        statusPane.add(UIUtilities.setTextFont("Loading...", Font.BOLD, 14));
        currentComp = statusPane;
    } 
     
    /** Builds and lays out the GUI. */ 
    private void buildGUI() 
    { 
7
CodeRank
This code example shows how to use the following methods:setFont
setFont Method Overview
Sets the font for this component.
See Code Examples for other Java 8 JComponent Methods: