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

The following are Jave code examples for showing how to use setFont() 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: osumer   File: TextPanel.java   View Source Code Vote up 6 votes
/**
 * Create the panel.
 */
public TextPanel(String text) {
	
	JLabel lblUpdateChangelog = new JLabel("Update description/change-log:");
	
	JScrollPane scrollPane = new JScrollPane();
	
	JLabel lblDoYouWant = new JLabel("Do you want to install this update?");
	lblDoYouWant.setFont(new Font("Tahoma", Font.PLAIN, 15));
	lblDoYouWant.setHorizontalAlignment(SwingConstants.CENTER);
	GroupLayout groupLayout = new GroupLayout(this);
	groupLayout.setHorizontalGroup(
	    groupLayout.createParallelGroup(Alignment.TRAILING)
	        .addGroup(groupLayout.createSequentialGroup()
	            .addContainerGap()
	            .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
	                .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
	                .addComponent(lblUpdateChangelog, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE)
	                .addComponent(lblDoYouWant, Alignment.TRAILING, GroupLayout.DEFAULT_SIZE, 430, Short.MAX_VALUE))
	            .addContainerGap())
	);
	groupLayout.setVerticalGroup(
	    groupLayout.createParallelGroup(Alignment.LEADING)
	        .addGroup(groupLayout.createSequentialGroup()
	            .addContainerGap()
	            .addComponent(lblUpdateChangelog)
	            .addPreferredGap(ComponentPlacement.RELATED)
	            .addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 249, Short.MAX_VALUE)
	            .addPreferredGap(ComponentPlacement.RELATED)
	            .addComponent(lblDoYouWant)
	            .addContainerGap())
	);
	
	JTextArea textArea = new JTextArea();
	scrollPane.setViewportView(textArea);
	setLayout(groupLayout);
	textArea.setEditable(false);
	textArea.setText(text);

}
 
Example 2
Project: Moenagade   File: MainFrame.java   View Source Code Vote up 6 votes
public void openNothing()
{
    // eanble scrolling
    editorScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    editorScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    
    JLabel label = new JLabel();
    label.setText("");
    label.setFont(new Font("Monospaced", Font.BOLD, 20));
    label.setHorizontalAlignment(JLabel.CENTER);
    label.setVerticalAlignment(JLabel.CENTER);
    label.setBackground(BloxsColors.$BACKGROUND);
    label.setOpaque(true);
  
    editorScroller.getViewport().add(label);
    editorScroller.getViewport().validate();
    editorScroller.repaint();
}
 
Example 3
Project: scorekeeperfrontend   File: AddByNamePanel.java   View Source Code Vote up 5 votes
private JComponent createTitle(String text)
{
	JLabel lbl = new JLabel(text);
	lbl.setFont(new Font("serif", Font.BOLD, 16));
	lbl.setBorder(new UnderlineBorder(0, 0, 0, 0));

	return lbl;
}
 
Example 4
Project: SER316-Ingolstadt   File: NotesList.java   View Source Code Vote up 5 votes
public ListCellRenderer getCellRenderer() {
       return new DefaultListCellRenderer()  {

    public Component getListCellRendererComponent(
      JList list,
      Object value,            // value to display
      int index,               // cell index
      boolean isSelected,      // is the cell selected
      boolean cellHasFocus)    // the list and the cell have the focus
    {
        JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
        String s = value.toString();
        label.setText(s);
        //Note currentNote = CurrentProject.getNoteList().getActiveNote();
	 Note currentNote = CurrentNote.get();
        if (currentNote != null) {
           if (getNote(index).getId().equals(currentNote.getId()))
               label.setFont(label.getFont().deriveFont(Font.BOLD));
        }
        if (getNote(index).isMarked())
           label.setIcon(bookmarkIcon);
        //setIcon();
      /*if (isSelected) {
            setBackground(list.getSelectionBackground());
          setForeground(list.getSelectionForeground());
      }
        else {
          setBackground(list.getBackground());
          setForeground(list.getForeground());
      }
      setEnabled(list.isEnabled());
      setFont(list.getFont());
        setOpaque(true);*/
        label.setToolTipText(s);
        return label;
    }
   };

}
 
Example 5
Project: Progetto-A   File: PartitaOnlineGuiView.java   View Source Code Vote up 5 votes
private void inizializza_salaAttesa() {
    imgSalaAttesa = new JLabel(caricaImmagine("dominio/immagini/salaAttesa.jpg"));
    fraseSalaAttesa = new JLabel("In attesa di altri giocatori");

    Font font = new Font("Sala Attesa", Font.BOLD, 40);
    fraseSalaAttesa.setFont(font);
    fraseSalaAttesa.setForeground(Color.black);
    int strWidth = fraseSalaAttesa.getFontMetrics(font).stringWidth("In attesa di altri giocatori");

    imgSalaAttesa.setBounds(this.getWidth() / 2 - 350, 100, 700, 557);
    fraseSalaAttesa.setBounds(this.getWidth() / 2 - strWidth / 2, 10, strWidth, 100);
}
 
Example 6
Project: AgentWorkbench   File: DynTableJPanel.java   View Source Code Vote up 5 votes
/**
 * Returns an empty JPanel with an specified test on it.
 *
 * @param text the text to display
 * @return the JPanel
 */
private JPanel getJPanelEmpty(String text) {

	JLabel jLabelText = new JLabel(text);
	jLabelText.setFont(new Font("Dialog", Font.BOLD, 12));
	jLabelText.setHorizontalAlignment(SwingConstants.CENTER);
	
	JPanel emptyPanel = new JPanel();
	emptyPanel.setLayout(new BorderLayout());
	emptyPanel.add(jLabelText, BorderLayout.CENTER);
	return emptyPanel;
}
 
Example 7
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 8
Project: Progetto-A   File: PartitaOfflineGuiView.java   View Source Code Vote up 5 votes
private void estrazioneMazziere() {
    int nGiocatori = model.getGiocatori().size();
    
    for(int i = 0; i < nGiocatori; i++)
        stampaNomeFiches(model.getGiocatori().get(i));
    
    pausa(pausa_breve);
    
    for(int i = 0; i < nGiocatori; i++) {
        stampaValoreMano(model.getGiocatori().get(i));
        if(i != nGiocatori - 1)
            stampaCarta((this.getWidth()*(2*i+1))/((nGiocatori-1)*2) - 125, 180, model.getGiocatori().get(i).getCartaCoperta().toString());
        else
            stampaCarta(this.getWidth()/2 - 125, 3*this.getHeight()/4 - 60, model.getGiocatori().get(i).getCartaCoperta().toString());
        
        pausa(pausa_breve);
    }
    
    pausa(pausa_breve);
    
    Giocatore mazziere = model.getMazziere();
    Font font = new Font("Player", Font.BOLD, 70);
    JLabel messaggioMazziere = new JLabel("Il mazziere è: " + mazziere.getNome());
    messaggioMazziere.setFont(font);
    messaggioMazziere.setForeground(Color.black);
    int strWidth = messaggioMazziere.getFontMetrics(font).stringWidth("Il mazziere è: " + mazziere.getNome() + " !!");
    messaggioMazziere.setBounds(this.getWidth()/2 - strWidth/2, this.getHeight()/2 - 60, strWidth, 90);
    
    sfondo.add(messaggioMazziere);
    sfondo.repaint();
    
    pausa(pausa_lunga);
    
    sfondo.removeAll();
    needToMarkMazziere = true;
    for(int i = 0; i < nGiocatori; i++)
        stampaNomeFiches(model.getGiocatori().get(i));
            
    sfondo.repaint();
}
 
Example 9
Project: Recaf   File: RenderFormatter.java   View Source Code Vote up 5 votes
/**
 * Sets the desired look of the lavel.
 * 
 * @param label
 *            Label to apply style to.
 * @param selected
 *            If label is selected or not.
 */
default void formatLabel(JLabel label, boolean selected) {
	label.setFont(Fonts.monospace);
	label.setOpaque(true);
	label.setBorder(BorderFactory.createEtchedBorder());
	if (selected) {
		label.setBackground(Color.decode(getTheme().listItemSelected));
	} else {
		label.setBackground(Color.decode(getTheme().listItemBackground));
	}
}
 
Example 10
Project: QN-ACTR-Release   File: TestWizardPanel.java   View Source Code Vote up 5 votes
public TestWizardPanel() {
	counter++;
	name = "Panel " + counter;
	JLabel jl = new JLabel("<html><center>This is <b>" + name + "</b>.<br>Have a nice day!</center></html>");
	jl.setHorizontalAlignment(SwingConstants.CENTER);
	jl.setHorizontalTextPosition(SwingConstants.CENTER);
	jl.setFont(new Font("Arial", Font.PLAIN, 16));
	jl.setBorder(BorderFactory.createEtchedBorder());

	setLayout(new BorderLayout());

	add(jl, BorderLayout.CENTER);
}
 
Example 11
Project: scorekeeperfrontend   File: SelectionBar.java   View Source Code Vote up 5 votes
public SelectionBar()
{
	super();

	Messenger.register(MT.TIMER_SERVICE_CONNECTION, this);
	Messenger.register(MT.SERIES_CHANGED, this);
	Messenger.register(MT.NEW_CHALLENGE, this);
	Messenger.register(MT.CHALLENGE_DELETED, this);

	setBorder(new BevelBorder(0));

	Font f = new Font(Font.DIALOG, Font.BOLD, 14);

	seriesLabel = new CurrentSeriesLabel();
	seriesLabel.setFont(f.deriveFont(Font.PLAIN));
	challengeSelect  = createCombo("challengeChange");
	eventSelect = createCombo("eventChange");
	
	connectLabel = new JLabel("Not Connected");
	connectLabel.setForeground(Color.RED);
	connectLabel.setFont(f);

	add(createLabel("Series:", f));
	add(seriesLabel);
	add(Box.createHorizontalStrut(40));

	add(createLabel("Event:", f));
	add(eventSelect);
	add(Box.createHorizontalStrut(40));

	add(createLabel("Challenge:", f));
	add(challengeSelect);
	add(Box.createHorizontalStrut(15));
	
	add(createLabel("Timer:", f));
	add(connectLabel);
}
 
Example 12
Project: incubator-netbeans   File: SearchResultRender.java   View Source Code Vote up 4 votes
private void configRenderer () {
    categoryLabel = new JLabel();
    categoryLabel.setFont(categoryLabel.getFont().deriveFont(Font.BOLD));
    categoryLabel.setBorder(new EmptyBorder(0, 5, 0, 0));
    categoryLabel.setForeground(QuickSearchComboBar.getCategoryTextColor());

    resultLabel = HtmlRenderer.createLabel();
    ((HtmlRenderer.Renderer)resultLabel).setHtml(true);
    ((HtmlRenderer.Renderer)resultLabel).setRenderStyle(HtmlRenderer.STYLE_CLIP);
    resultLabel.setOpaque(true);
    resultLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));

    shortcutLabel = new JLabel();
    shortcutLabel.setOpaque(true);
    shortcutLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));

    cutLabel = new JLabel("...");
    cutLabel.setOpaque(true);
    cutLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 4));

    itemLinePanel = new JPanel();
    itemLinePanel.setBackground(QuickSearchComboBar.getResultBackground());
    itemLinePanel.setLayout(new BorderLayout());
    itemLinePanel.add(resultLabel, BorderLayout.CENTER);


    itemPanel = new JPanel();
    itemPanel.setBackground(QuickSearchComboBar.getResultBackground());
    itemPanel.setBorder(BorderFactory.createEmptyBorder(2, 4, 2, 3));
    itemPanel.setLayout(new BorderLayout());
    itemPanel.add(itemLinePanel, BorderLayout.CENTER);

    dividerLine = new JPanel();
    dividerLine.setBackground(QuickSearchComboBar.getPopupBorderColor());
    dividerLine.setPreferredSize(new Dimension(dividerLine.getPreferredSize().width, 1));

    rendererComponent = new JPanel();
    rendererComponent.setLayout(new BorderLayout());
    rendererComponent.add(itemPanel, BorderLayout.CENTER);
    rendererComponent.add(categoryLabel, BorderLayout.WEST);
}
 
Example 13
Project: COE1186   File: TrnControllerGUI.java   View Source Code Vote up 4 votes
public void stylizeHeadingLabel(JLabel l){
	l.setFont(font_20_bold);
	l.setForeground(Color.WHITE);
	l.setHorizontalAlignment(SwingConstants.LEFT);
}
 
Example 14
Project: jOthelloT   File: Display.java   View Source Code Vote up 4 votes
private void setSideMenu() {
    gridLayout = new GridLayout(8, 1, 0, 0);
    sideMenu.setLayout(gridLayout);
    sideMenu.setBackground(Color.BLACK);

    playerTurn = new JLabel("Turn");
    playerTurn.setFont(new Font("Verdana", 0, 20));
    playerTurn.setForeground(new Color(255, 255, 255));

    player1Name = new JLabel();
    player1Name.setFont(new Font("Verdana", 0, 20));
    player1Name.setForeground(new Color(255, 255, 255));

    player1Score = new JLabel();
    player1Score.setIcon(blue);
    player1Score.setFont(new Font("Verdana", 0, 35));
    player1Score.setForeground(new Color(255, 255, 255));

    player2Name = new JLabel();
    player2Name.setFont(new Font("Verdana", 0, 20));
    player2Name.setForeground(new Color(255, 255, 255));

    player2Score = new JLabel();
    player2Score.setIcon(red);
    player2Score.setFont(new Font("Verdana", 0, 35));
    player2Score.setForeground(new Color(255, 255, 255));

    winner = new JLabel("Winner");
    winner.setFont(new Font("Verdana", 0, 20));
    winner.setForeground(new Color(255, 255, 255));
    winner.setVisible(false);

    sideMenu.add(playerTurn);
    sideMenu.add(player1Name);
    sideMenu.add(player1Score);
    sideMenu.add(new JLabel());
    sideMenu.add(player2Name);
    sideMenu.add(player2Score);
    sideMenu.add(new JLabel());
    sideMenu.add(winner);
}
 
Example 15
Project: AgentWorkbench   File: NetworkAddresses.java   View Source Code Vote up 4 votes
/**
 * Gets the JLabel for a header.
 * @param headerText the header text
 * @return the JLabel header
 */
private JLabel getJLabelHeader(String headerText) {
	JLabel jLabelHeader = new JLabel("  " + headerText);
	jLabelHeader.setFont(new Font("Dialog", Font.BOLD, 12));
	return jLabelHeader;
}
 
Example 16
Project: COE1186   File: TrackModelGUI.java   View Source Code Vote up 4 votes
public void stylizeInfoLabel_Bold(JLabel l){
	l.setHorizontalAlignment(SwingConstants.LEFT);
	l.setForeground(new Color(234, 201, 87));
	l.setFont(font_16_bold);
}
 
Example 17
Project: COE1186   File: TrainControllerGUI.java   View Source Code Vote up 4 votes
public void stylizeInfoLabel_Bold(JLabel l){
	l.setHorizontalAlignment(SwingConstants.LEFT);
	l.setForeground(new Color(234, 201, 87));
	l.setFont(font_16_bold);
}
 
Example 18
Project: COE1186   File: TrainControllerGUI.java   View Source Code Vote up 4 votes
public void stylizeInfoLabel_Small(JLabel l){
	l.setHorizontalAlignment(SwingConstants.LEFT);
	l.setForeground(UIManager.getColor("Button.disabledToolBarBorderBackground"));
	l.setFont(font_14_bold);
}
 
Example 19
Project: bridgechat   File: WindowLoad.java   View Source Code Vote up 4 votes
/**
 * Create the frame.
 * 
 * @throws MalformedURLException
 */
public WindowLoad() throws MalformedURLException {

	// can't resize the window
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setResizable(false);

	setIconImage(Toolkit.getDefaultToolkit().getImage(WindowLoad.class.getResource("/resource/chip.png")));
	setTitle("Bridge Chat");
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 331, 422);
	contentPane = new JPanel();
	contentPane.setBackground(new Color(204, 204, 255));
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);

	try {

		// URL url = new
		// URL("https://media.giphy.com/media/sSgvbe1m3n93G/giphy.gif");
		// ImageIcon icon = new ImageIcon(url);
		// ImageIcon icon = new ImageIcon("resource/ellipsis.gif","test");
		// label1 = new JLabel("Image and Text", icon, JLabel.CENTER);
		ClassLoader cldr = this.getClass().getClassLoader(); // set my
																// resource
		java.net.URL imageURL = cldr.getResource("resource/ellipsis.gif");
		ImageIcon icon2 = new ImageIcon(imageURL);
		JLabel labelGifLoading = new JLabel(icon2);
		labelGifLoading.setBounds(152, 22, 145, 15);
		contentPane.add(labelGifLoading);

		JLabel labelTextLoading = new JLabel("L o a d i n g ");
		labelTextLoading.setFont(new Font("AR ESSENCE", Font.PLAIN, 18));
		labelTextLoading.setBounds(32, 14, 106, 23);
		contentPane.add(labelTextLoading);

		ClassLoader cldr2 = this.getClass().getClassLoader(); // set my
																// resource
		java.net.URL imageURL2 = cldr2.getResource("resource/loading.gif");
		ImageIcon icon = new ImageIcon(imageURL2);
		// ImageIcon icon = new ImageIcon(new
		// URL("https://i.giphy.com/3o8doNAGKZXsrsgzW8.gif"));
		JLabel labelGifBg = new JLabel(icon);
		labelGifBg.setBounds(0, 0, 335, 393);
		contentPane.add(labelGifBg);
	} catch (Exception e) {
		e.printStackTrace();
	}
}
 
Example 20
Project: AgentWorkbench   File: OntologyTabClassView.java   View Source Code Vote up 4 votes
/**
 * This method initializes this
 */
private void initialize() {
	GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
	gridBagConstraints2.gridx = 2;
	gridBagConstraints2.gridy = 0;
	GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
	gridBagConstraints1.fill = GridBagConstraints.BOTH;
	gridBagConstraints1.insets = new Insets(10, 0, 10, 10);
	gridBagConstraints1.weightx = 1.0;
	GridBagConstraints gridBagConstraints = new GridBagConstraints();
	gridBagConstraints.gridx = 3;
	gridBagConstraints.insets = new Insets(10, 10, 10, 5);
	gridBagConstraints.gridy = 0;
	GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
	gridBagConstraints6.fill = GridBagConstraints.BOTH;
	gridBagConstraints6.gridwidth = 5;
	gridBagConstraints6.gridx = 0;
	gridBagConstraints6.gridy = 1;
	gridBagConstraints6.weightx = 1.0;
	gridBagConstraints6.weighty = 1.0;
	gridBagConstraints6.insets = new Insets(0, 10, 0, 10);
	GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
	gridBagConstraints5.fill = GridBagConstraints.BOTH;
	gridBagConstraints5.gridx = 1;
	gridBagConstraints5.gridy = 0;
	gridBagConstraints5.weightx = 1.0;
	gridBagConstraints5.anchor = GridBagConstraints.CENTER;
	gridBagConstraints5.weighty = 0.0;
	gridBagConstraints5.insets = new Insets(10, 0, 10, 10);
	GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
	gridBagConstraints4.insets = new Insets(10, 10, 10, 5);
	gridBagConstraints4.gridy = 0;
	gridBagConstraints4.anchor = GridBagConstraints.WEST;
	gridBagConstraints4.gridx = 0;

	jLabelDummy = new JLabel();
	jLabelDummy.setText(" ");

	jLabelClassDescCaption = new JLabel();
	jLabelClassDescCaption.setText("Text");
	jLabelClassDescCaption.setVisible(false);

	jLabelClassNameCaption = new JLabel();
	jLabelClassNameCaption.setText("Name:");
	jLabelClassNameCaption.setFont(new Font("Dialog", Font.BOLD, 12));

	this.setSize(392, 238);
	this.setLayout(new GridBagLayout());
	this.add(jLabelClassNameCaption, gridBagConstraints4);
	this.add(getJTextFieldClassName(), gridBagConstraints5);
	this.add(getJScrollPaneClassSlots(), gridBagConstraints6);
	this.add(jLabelClassDescCaption, gridBagConstraints);
	this.add(getJTextFieldClassDescription1(), gridBagConstraints1);
	this.add(jLabelDummy, gridBagConstraints2);
}