Example usage for javax.swing JLabel setFont

List of usage examples for javax.swing JLabel setFont

Introduction

In this page you can find the example usage for javax.swing JLabel setFont.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The font for the component.")
public void setFont(Font font) 

Source Link

Document

Sets the font for this component.

Usage

From source file:Main.java

private JLabel createLabel(String label) {
    JLabel jLabel = new JLabel(label);
    jLabel.setHorizontalAlignment(JLabel.CENTER);
    jLabel.setFont(jLabel.getFont().deriveFont(48.0f));
    jLabel.setFocusable(true);/*from  w w w  . j a v  a 2s  .co  m*/
    return jLabel;
}

From source file:Main.java

public Main() {
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JLabel label = new JLabel("Some label text");
    label.setBorder(BorderFactory.createLineBorder(Color.green));
    label.setFont(new Font("Serif", Font.ITALIC, 16));

    getContentPane().add(label);//from   w  ww.ja  v  a  2  s .co  m
    pack();
    setVisible(true);
}

From source file:SplashScreen.java

public void showSplash() {
    JPanel content = (JPanel) getContentPane();
    content.setBackground(Color.white);

    // Set the window's bounds, centering the window
    int width = 450;
    int height = 115;
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int x = (screen.width - width) / 2;
    int y = (screen.height - height) / 2;
    setBounds(x, y, width, height);//w ww. j  a v a  2  s  .c o m

    // Build the splash screen
    JLabel label = new JLabel(new ImageIcon("1.gif"));
    JLabel copyrt = new JLabel("Copyright 2002, O'Reilly & Associates", JLabel.CENTER);
    copyrt.setFont(new Font("Sans-Serif", Font.BOLD, 12));
    content.add(label, BorderLayout.CENTER);
    content.add(copyrt, BorderLayout.SOUTH);
    Color oraRed = new Color(156, 20, 20, 255);
    content.setBorder(BorderFactory.createLineBorder(oraRed, 10));

    // Display it
    setVisible(true);

    // Wait a little while, maybe while loading resources
    try {
        Thread.sleep(duration);
    } catch (Exception e) {
    }

    setVisible(false);
}

From source file:Main.java

public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
        boolean cellHasFocus) {
    JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
    Font font = new Font((String) value, Font.PLAIN, 20);
    label.setFont(font);
    return label;
}

From source file:com.antelink.sourcesquare.gui.view.CopyrightPanel.java

public CopyrightPanel() {
    super();// w  w  w  . j  a va  2  s. c o  m

    ArrayList<JLabel> sentence = new ArrayList<JLabel>();
    sentence.add(new JLabel("Powered by"));
    sentence.add(createJLabelWithHyperlink("Antepedia", "http://www.antepedia.com"));
    sentence.add(new JLabel(", an "));
    sentence.add(createJLabelWithHyperlink("Antelink", "http://www.antelink.com"));
    sentence.add(new JLabel(" product - "));
    sentence.add(
            createJLabelWithHyperlink("About SourceSquare", "https://sourcesquare.antepedia.com/about.html"));

    setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));

    for (JLabel jLabel : sentence) {
        jLabel.setFont(new Font("Lucida Grande", Font.PLAIN, 11));
        this.add(jLabel);
    }
    this.setSize(360, 25);
}

From source file:app.gui.ViewGraphic.java

public ViewGraphic(String title) {
    setSize(600, 400);/*from w w  w.  j a  va 2  s . c o  m*/
    setLocationRelativeTo(this);
    setTitle(title);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            dispose();
        }
    });
    setLayout(new BorderLayout());

    serieError = new XYSeries(title);

    dataset = new XYSeriesCollection();
    dataset.addSeries(serieError);

    chart = ChartFactory.createXYLineChart(title, Translate.get("GUI_PERIODS"), Translate.get("GUI_ERROR"),
            dataset, PlotOrientation.VERTICAL, true, true, false);
    add(new ChartPanel(chart), BorderLayout.CENTER);

    JPanel south = new JPanel(new MigLayout());

    lblError = new JLabel("");
    lblError.setHorizontalTextPosition(SwingConstants.LEFT);
    lblError.setFont(new Font("ARIAL", Font.BOLD, 26));
    JLabel lblErrorTitle = new JLabel(Translate.get("GUI_ERROR") + ": ");
    lblErrorTitle.setFont(new Font("ARIAL", Font.BOLD, 26));
    south.add(lblErrorTitle);
    south.add(lblError, "wrap");

    add(south, BorderLayout.SOUTH);
    setVisible(true);
}

From source file:WelcomeApplet.java

 public void init()
{
   EventQueue.invokeLater(new Runnable()
      {//from w  w w.j  a v a 2  s  . c om
         public void run()
         {
            setLayout(new BorderLayout());

            JLabel label = new JLabel(getParameter("greeting"), SwingConstants.CENTER);
            label.setFont(new Font("Serif", Font.BOLD, 18));
            add(label, BorderLayout.CENTER);

            JPanel panel = new JPanel();

            JButton cayButton = new JButton("Cay Horstmann");
            cayButton.addActionListener(makeAction("http://www.horstmann.com"));
            panel.add(cayButton);

            JButton garyButton = new JButton("Gary Cornell");
            garyButton.addActionListener(makeAction("mailto:gary_cornell@apress.com"));
            panel.add(garyButton);

            add(panel, BorderLayout.SOUTH);
         }
      });
}

From source file:be.tutul.naheulcraft.launcher.auth.LogInForm.java

private void createUserDropdownPanel(Font labelFont) {
    this.userDropdownPanel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.fill = 2;/* w  ww.  jav a  2  s  .com*/
    constraints.gridx = 0;
    constraints.gridy = -1;
    constraints.weightx = 1.0D;

    this.userDropdownPanel.add(Box.createVerticalStrut(8), constraints);

    JLabel userDropdownLabel = new JLabel("Pseudo : ");
    userDropdownLabel.setFont(labelFont);
    this.userDropdownPanel.add(userDropdownLabel, constraints);
    this.userDropdownPanel.add(this.userDropdown, constraints);

    this.userDropdownPanel.setVisible(false);
}

From source file:geneticalgorithm.gui.view.VGraphic.java

public VGraphic(String title, String xLabel, String yLabel) {
    setSize(800, 600);/*ww w  .  j  a v  a 2 s . c o m*/
    setLocationRelativeTo(this);
    setTitle(title);

    addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent arg0) {
            dispose();
        }
    });
    setLayout(new BorderLayout());

    average = new XYSeries("Average");
    offline = new XYSeries("Offline");
    online = new XYSeries("Online");

    dataset = new XYSeriesCollection();
    dataset.addSeries(average);
    dataset.addSeries(offline);
    dataset.addSeries(online);

    chart = ChartFactory.createXYLineChart(title, xLabel, yLabel, dataset, PlotOrientation.VERTICAL, true, true,
            false);
    add(new ChartPanel(chart), BorderLayout.CENTER);

    JPanel south = new JPanel(new MigLayout());

    lblAverage = new JLabel("");
    lblAverage.setHorizontalTextPosition(SwingConstants.LEFT);
    lblAverage.setFont(new Font("ARIAL", Font.BOLD, 26));
    JLabel lblAverageTitle = new JLabel("Average: ");
    lblAverageTitle.setFont(new Font("ARIAL", Font.BOLD, 26));
    south.add(lblAverageTitle);
    south.add(lblAverage, "wrap");

    lblOffline = new JLabel("");
    lblOffline.setHorizontalTextPosition(SwingConstants.LEFT);
    lblOffline.setFont(new Font("ARIAL", Font.BOLD, 26));
    JLabel lblOfflineTitle = new JLabel("Offline: ");
    lblOfflineTitle.setFont(new Font("ARIAL", Font.BOLD, 26));
    south.add(lblOfflineTitle);
    south.add(lblOffline, "wrap");

    lblOnline = new JLabel("");
    lblOnline.setHorizontalTextPosition(SwingConstants.LEFT);
    lblOnline.setFont(new Font("ARIAL", Font.BOLD, 26));
    JLabel lblOnlineTitle = new JLabel("Online: ");
    lblOnlineTitle.setFont(new Font("ARIAL", Font.BOLD, 26));
    south.add(lblOnlineTitle);
    south.add(lblOnline, "wrap");

    add(south, BorderLayout.SOUTH);
}

From source file:com.thoughtworks.go.agent.bootstrapper.osx.MacAboutBox.java

private JLabel label(String content, Font font) {
    JLabel jLabel = new JLabel(content);
    jLabel.setHorizontalAlignment(JLabel.CENTER);
    if (font != null) {
        jLabel.setFont(font);
    }/*ww  w  .  j a  v  a 2s .  c om*/
    return jLabel;
}