List of usage examples for javax.swing JLabel setFont
@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.") public void setFont(Font font)
From source file:Main.java
public static void italicLabel(JLabel label) { label.setFont(label.getFont().deriveFont(Font.ITALIC)); }
From source file:Main.java
public static void italicBoldLabel(JLabel label) { label.setFont(label.getFont().deriveFont(Font.BOLD + Font.ITALIC)); }
From source file:Main.java
private static JPanel createLogin() { JPanel p = new JPanel(); p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); JLabel label = new JLabel("login panel."); label.setFont(label.getFont().deriveFont(Font.ITALIC, 24f)); label.setAlignmentX(0.5f);//from w w w . ja va2 s .c om label.setBorder(new EmptyBorder(0, 20, 0, 20)); p.add(Box.createVerticalStrut(36)); p.add(label); p.add(Box.createVerticalStrut(144)); return p; }
From source file:Main.java
public static void changeFontSize(JLabel label, int newSize) { label.setFont(label.getFont().deriveFont((float) newSize)); }
From source file:Main.java
public static JLabel modifyLabelFont(JLabel label, int style, int delta) { Font font = label.getFont();//ww w . j a v a2s . c o m label.setFont(font.deriveFont(style, font.getSize() + delta)); label.setForeground(new Color(140, 140, 140)); return label; }
From source file:Main.java
/** * Apply bold font to a Jlabel./*from ww w. ja v a2 s. c o m*/ * @param label */ public static void bold(final JLabel label) { final Font font = label.getFont(); label.setFont(font.deriveFont(font.getStyle() ^ Font.BOLD)); }
From source file:Main.java
/** * Displays a message dialog with given information. *///from ww w . j av a 2 s . c o m public static void showInformationDialog(Component component, String message) { final JPanel panel = new JPanel(new BorderLayout(5, 5)); final JLabel messageLabel = new JLabel(message); messageLabel.setFont(new Font("Dialog", Font.BOLD, messageLabel.getFont().getSize())); panel.add(messageLabel, BorderLayout.CENTER); // Adjust stack trace dimensions final Dimension screenDimension = Toolkit.getDefaultToolkit().getScreenSize(); screenDimension.setSize(screenDimension.getWidth() * 0.7, screenDimension.getHeight() * 0.7); final Dimension maxStackTraceDimension = new Dimension(500, 500); maxStackTraceDimension.setSize(Math.min(maxStackTraceDimension.getWidth(), screenDimension.getWidth()), Math.min(maxStackTraceDimension.getHeight(), screenDimension.getHeight())); JOptionPane.showMessageDialog(component, panel, "Information", JOptionPane.INFORMATION_MESSAGE); }
From source file:Main.java
public static void changeFont(JLabel label, float sizeMultipler) { float size = label.getFont().getSize() * sizeMultipler; label.setFont(label.getFont().deriveFont(size)); }
From source file:Main.java
/** * Creates a label with a specific font. * * @param text the text for the label.//from ww w. jav a 2 s.c om * @param font the font. * * @return The label. */ public static JLabel createJLabel(final String text, final Font font) { final JLabel result = new JLabel(text); result.setFont(font); return result; }
From source file:Main.java
/** * Creates a label with a specific font and color. * * @param text the text for the label.//from w ww. j a va 2 s .c o m * @param font the font. * @param color the color. * * @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; }