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:net.sf.taverna.raven.plugins.ui.CheckForUpdatesDialog.java

private void initComponents() {
    // Base font for all components on the form
    Font baseFont = new JLabel("base font").getFont().deriveFont(11f);

    // Message saying that updates are available
    JPanel messagePanel = new JPanel(new BorderLayout());
    messagePanel.setBorder(//  ww w  . java  2  s.c om
            new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder(EtchedBorder.LOWERED)));
    JLabel message = new JLabel(
            "<html><body>Updates are available for some Taverna components. To review and <br>install them go to 'Updates and plugins' in the 'Advanced' menu.</body><html>");
    message.setFont(baseFont.deriveFont(12f));
    message.setBorder(new EmptyBorder(5, 5, 5, 5));
    message.setIcon(UpdatesAvailableIcon.updateIcon);
    messagePanel.add(message, BorderLayout.CENTER);

    // Buttons
    JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    JButton okButton = new JButton("OK"); // we'll check for updates again in 2 weeks
    okButton.setFont(baseFont);
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });

    buttonsPanel.add(okButton);

    getContentPane().setLayout(new BorderLayout());
    getContentPane().add(messagePanel, BorderLayout.CENTER);
    getContentPane().add(buttonsPanel, BorderLayout.SOUTH);

    pack();
    setResizable(false);
    // Center the dialog on the screen (we do not have the parent)
    Dimension dimension = getToolkit().getScreenSize();
    Rectangle abounds = getBounds();
    setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2);
    setSize(getPreferredSize());
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JLabel getFieldLabel(String text) {
    JLabel label = new JLabel(text);
    label.setForeground(UIConstants.INTEL_DARK_GRAY);
    label.setFont(UIConstants.H5_FONT.deriveFont(Font.BOLD));
    return label;
}

From source file:com.intel.stl.ui.common.view.ComponentFactory.java

public static JLabel getFieldContent(String text) {
    JLabel label = new JLabel(text);
    label.setForeground(UIConstants.INTEL_DARK_GRAY);
    label.setFont(UIConstants.H3_FONT);
    return label;
}

From source file:com.game.ui.views.MapEditor.java

public void generateGUI() throws IOException {
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);
    //        setResizable(false);
    JMenuBar menubar = new JMenuBar();
    ImageIcon icon = null;/*  www  .  j av a 2 s.c om*/
    try {
        icon = GameUtils.shrinkImage("save.png", 20, 20);
    } catch (IOException e) {
        System.out.println("Dialog : showDialogForMap(): Exception occured :" + e);
        e.printStackTrace();
    }
    JMenu file = new JMenu("File");
    JMenuItem save = new JMenuItem("Save", icon);
    save.setToolTipText("Save Map Information");
    save.setActionCommand("Save Map");
    save.addActionListener(this);
    file.add(save);
    menubar.add(file);
    setJMenuBar(menubar);
    JPanel topPanel = new JPanel();
    topPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    topPanel.setLayout(new GridBagLayout());
    JLabel headerLbl = new JLabel("Legend : ");
    headerLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    JLabel lbl1 = new JLabel();
    lbl1.setPreferredSize(new Dimension(50, 20));
    lbl1.setBackground(Configuration.pathColor);
    lbl1.setOpaque(true);
    JLabel lbl2 = new JLabel("- Represents the path.");
    JLabel lbl3 = new JLabel();
    lbl3.setPreferredSize(new Dimension(50, 20));
    lbl3.setBackground(Configuration.enemyColor);
    lbl3.setOpaque(true);
    JLabel lbl4 = new JLabel("- Represents the path with monsters");
    JLabel lbl5 = new JLabel();
    lbl5.setPreferredSize(new Dimension(50, 20));
    lbl5.setBackground(Configuration.startPointColor);
    lbl5.setOpaque(true);
    JLabel lbl6 = new JLabel("- Represents the starting point in the path");
    JLabel lbl7 = new JLabel();
    lbl7.setBackground(Configuration.endPointColor);
    lbl7.setOpaque(true);
    lbl7.setPreferredSize(new Dimension(50, 20));
    JLabel lbl8 = new JLabel("- Ending point in the path");
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 0;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 2;
    topPanel.add(headerLbl, c);
    c.fill = GridBagConstraints.NONE;
    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.ipadx = 5;
    c.ipady = 5;
    topPanel.add(lbl1, c);
    c.gridx = 1;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    topPanel.add(lbl2, c);
    c.gridx = 0;
    c.gridy = 2;
    topPanel.add(lbl3, c);
    c.gridx = 1;
    topPanel.add(lbl4, c);
    c.gridx = 0;
    c.gridy = 3;
    topPanel.add(lbl5, c);
    c.gridx = 1;
    topPanel.add(lbl6, c);
    c.gridx = 0;
    c.gridy = 4;
    topPanel.add(lbl7, c);
    c.gridx = 1;
    topPanel.add(lbl8, c);
    add(topPanel, BorderLayout.NORTH);
    bottomPanel = new JPanel();
    add(bottomPanel, BorderLayout.CENTER);
    bottomPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
    //        bottomPanel.add(new JButton("kaushik"));
    pack();
    setExtendedState(JFrame.MAXIMIZED_BOTH);
    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
    setMaximizedBounds(env.getMaximumWindowBounds());
    setVisible(true);
    callDialogForUsersInput();
}

From source file:edu.ku.brc.specify.config.init.DisciplinePanel.java

/**
 * Creates a dialog for entering database name and selecting the appropriate driver.
 *//*from w  ww.  j a v  a 2s .  co m*/
public DisciplinePanel(final String helpContext, final JButton nextBtn, final JButton prevBtn) {
    super("DISCIPLINE", helpContext, nextBtn, prevBtn);

    String header = getResourceString("DISP_INFO") + ":";

    CellConstraints cc = new CellConstraints();

    PanelBuilder builder = new PanelBuilder(new FormLayout("p,2px,p,f:p:g", "p,6px,p,2px,p"), this);
    int row = 1;

    builder.add(createLabel(header, SwingConstants.CENTER), cc.xywh(1, row, 3, 1));
    row += 2;

    Vector<DisciplineType> dispList = new Vector<DisciplineType>();
    for (DisciplineType disciplineType : DisciplineType.getDisciplineList()) {
        if (disciplineType.getType() == 0) {
            dispList.add(disciplineType);
        }
    }

    Collections.sort(dispList);

    disciplines = createComboBox(dispList);

    disciplines.setSelectedIndex(-1);

    // Discipline 
    JLabel lbl = createI18NFormLabel("DSP_TYPE", SwingConstants.RIGHT);
    lbl.setFont(bold);
    builder.add(lbl, cc.xy(1, row));
    builder.add(disciplines, cc.xy(3, row));
    row += 2;

    makeStretchy = true;
    disciplineName = createField(builder, "DISP_NAME", true, row, 64);
    row += 2;

    updateBtnUI();

    disciplines.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateBtnUI();

            if (disciplines.getSelectedIndex() > -1) {
                SwingUtilities.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        DisciplineType dt = (DisciplineType) disciplines.getSelectedItem();
                        disciplineName.setText(dt.getTitle());
                    }
                });
            }
        }
    });
}

From source file:MyStatsPanel.java

JPanel setFields() {
    getDatabaseInfo();/*from   w w w. ja va  2s. c o  m*/
    GroupLayout layout;
    JPanel p;

    numGuestsIn = new JLabel("Total guests in house .............................");
    numGuestsIn.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsIn.setForeground(Color.WHITE);
    checkIns = new JLabel("Todays guest check ins ............................");
    checkIns.setForeground(Color.WHITE);
    checkIns.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsOut = new JLabel("Todays guest check outs ...........................");
    numGuestsOut.setFont(new Font("Courier New", Font.PLAIN, 20));
    numGuestsOut.setForeground(Color.WHITE);
    overnights = new JLabel("Total overnight guests ............................");
    overnights.setForeground(Color.WHITE);
    overnights.setFont(new Font("Courier New", Font.PLAIN, 20));

    JLabel n1 = new JLabel(totalGuestsIn);
    n1.setForeground(Color.WHITE);
    n1.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n2 = new JLabel(todaysCheckIns);
    n2.setForeground(Color.WHITE);
    n2.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n3 = new JLabel(todaysCheckOuts);
    n3.setForeground(Color.WHITE);
    n3.setFont(new Font("Courier New", Font.PLAIN, 20));
    JLabel n4 = new JLabel(totalOvernights);
    n4.setForeground(Color.WHITE);
    n4.setFont(new Font("Courier New", Font.PLAIN, 20));

    p = new JPanel();
    p.setBackground(Color.GRAY);

    layout = new GroupLayout(p);
    p.setLayout(layout);
    layout.setAutoCreateGaps(true);
    layout.setAutoCreateContainerGaps(true);

    GroupLayout.SequentialGroup hGroup = layout.createSequentialGroup();
    hGroup.addGroup(layout.createParallelGroup().addComponent(numGuestsIn).addComponent(checkIns)
            .addComponent(numGuestsOut).addComponent(overnights));
    hGroup.addGroup(
            layout.createParallelGroup().addComponent(n1).addComponent(n2).addComponent(n3).addComponent(n4));
    layout.setHorizontalGroup(hGroup);

    GroupLayout.SequentialGroup vGroup = layout.createSequentialGroup();
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(numGuestsIn).addComponent(n1));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(checkIns).addComponent(n2));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(numGuestsOut).addComponent(n3));
    vGroup.addGroup(layout.createParallelGroup(BASELINE).addComponent(overnights).addComponent(n4));

    layout.setVerticalGroup(vGroup);

    return (p);
}

From source file:LabelDemo.java

public LabelDemo() {
    super("JLabel Demo");
    setSize(600, 100);//  ww w  .  j  a  v  a2 s  . co m

    JPanel content = new JPanel(new GridLayout(1, 4, 4, 4));

    JLabel label = new JLabel("Java2s");
    label.setBackground(Color.white);
    content.add(label);

    label = new JLabel("Java2s", SwingConstants.CENTER);
    label.setOpaque(true);
    label.setBackground(Color.white);
    content.add(label);

    label = new JLabel("Java2s");
    label.setFont(new Font("Helvetica", Font.BOLD, 18));
    label.setOpaque(true);
    label.setBackground(Color.white);
    content.add(label);

    ImageIcon image = new ImageIcon("java2sLogo.gif");
    label = new JLabel("Java2s", image, SwingConstants.RIGHT);
    label.setVerticalTextPosition(SwingConstants.TOP);
    label.setOpaque(true);
    label.setBackground(Color.white);
    content.add(label);

    getContentPane().add(content);
    setVisible(true);
}

From source file:Main.java

public Main() {
    super("JLabel Demo");
    setSize(600, 100);//  ww w.java  2  s  . c  o m

    JPanel content = new JPanel(new GridLayout(1, 4, 4, 4));

    JLabel label = new JLabel("Java2s");
    label.setBackground(Color.white);
    content.add(label);

    label = new JLabel("Java2s", SwingConstants.CENTER);
    label.setOpaque(true);
    label.setBackground(Color.white);
    content.add(label);

    label = new JLabel("Java2s");
    label.setFont(new Font("Helvetica", Font.BOLD, 18));
    label.setOpaque(true);
    label.setBackground(Color.white);
    content.add(label);

    ImageIcon image = new ImageIcon("java2sLogo.gif");
    label = new JLabel("Java2s", image, SwingConstants.RIGHT);
    label.setVerticalTextPosition(SwingConstants.TOP);
    label.setOpaque(true);
    label.setBackground(Color.white);
    content.add(label);

    getContentPane().add(content);
    setVisible(true);
}

From source file:com.polivoto.vistas.Editor.java

/**
 * Ventana Editor - configura el color de las preguntas.
 *///w w w.j a v  a 2s  .  c  o m
public Editor(JSONArray js) {
    initComponents();
    for (int i = 0; i < js.length(); i++) {
        try {
            JPanel panel = new JPanel(new GridLayout(0, 2, 10, 10));
            panel.setBackground(new Color(255, 255, 255));
            jTabbedPane.add(panel, "Pregunta " + (i + 1));
            JLabel lab1 = new JLabel(
                    "Pregunta " + (i + 1) + ": " + ((JSONObject) js.get(i)).getString("pregunta"), JLabel.LEFT);
            lab1.setFont(new Font("Roboto", 1, 18));
            lab1.setForeground(new Color(134, 36, 31));
            panel.add(lab1);
            panel.add(new JLabel(""));
            JSONArray jarr = ((JSONObject) js.get(i)).getJSONArray("opciones");
            for (int j = 0; j < jarr.length(); j++) {
                JLabel lab2 = new JLabel("Opcin " + (j + 1) + ": " + jarr.getString(j), JLabel.LEFT);
                JButton colBut = new JButton("Seleccionar color de la opcin");
                colBut.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        jFrame1.setVisible(true);
                    }
                });
                lab2.setFont(new Font("Roboto", 1, 15));
                lab2.setForeground(new Color(0, 0, 0));
                panel.add(lab2);
                panel.add(colBut);
            }

        } catch (JSONException ex) {
            Logger.getLogger(AnalistaLocal.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:com.intel.stl.ui.monitor.view.PSEventsPieChart.java

protected JPanel getLengendPanel() {
    JPanel panel = new JPanel();
    panel.setOpaque(false);//from   w ww.j a  va2 s  . c  o  m
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();

    gc.fill = GridBagConstraints.BOTH;
    StateLongTypeViz[] states = StateLongTypeViz.values();
    stateLabels = new JLabel[states.length];
    for (int i = 0; i < states.length; i++) {
        StateLongTypeViz state = states[i];
        gc.insets = new Insets(2, 5, 2, 2);
        gc.weightx = 0;
        gc.gridwidth = 1;

        JLabel label = new JLabel(state.getName(),
                Util.generateImageIcon(state.getColor(), 8, new Insets(1, 1, 1, 1)), JLabel.LEFT);
        label.setFont(UIConstants.H5_FONT);
        label.setForeground(UIConstants.INTEL_DARK_GRAY);
        panel.add(label, gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        gc.weightx = 0;
        stateLabels[i] = new JLabel();
        stateLabels[i].setForeground(UIConstants.INTEL_DARK_GRAY);
        stateLabels[i].setFont(UIConstants.H5_FONT);
        panel.add(stateLabels[i], gc);
    }
    return panel;
}