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:utybo.branchingstorytree.swing.visuals.AboutDialog.java

@SuppressWarnings("unchecked")
public AboutDialog(OpenBSTGUI parent) {
    super(parent);
    setTitle(Lang.get("about.title"));
    setModalityType(ModalityType.APPLICATION_MODAL);

    JPanel banner = new JPanel(new FlowLayout(FlowLayout.CENTER));
    banner.setBackground(OpenBSTGUI.OPENBST_BLUE);
    JLabel lblOpenbst = new JLabel(new ImageIcon(Icons.getImage("FullLogoWhite", 48)));
    lblOpenbst.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    banner.add(lblOpenbst, "flowx,cell 0 0,alignx center");
    getContentPane().add(banner, BorderLayout.NORTH);

    JPanel pan = new JPanel();
    pan.setLayout(new MigLayout("insets 10, gap 10px", "[grow]", "[][][grow]"));
    getContentPane().add(pan, BorderLayout.CENTER);

    JLabel lblWebsite = new JLabel("https://utybo.github.io/BST/");
    Font f = lblWebsite.getFont();
    @SuppressWarnings("rawtypes")
    Map attrs = f.getAttributes();
    attrs.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
    lblWebsite.setFont(f.deriveFont(attrs));
    lblWebsite.setForeground(OpenBSTGUI.OPENBST_BLUE);
    lblWebsite.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    lblWebsite.addMouseListener(new MouseAdapter() {
        @Override//from w  w w  .j a  v a2  s  .c om
        public void mouseClicked(MouseEvent e) {
            if (Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URL("https://utybo.github.io/BST/").toURI());
                } catch (IOException | URISyntaxException e1) {
                    OpenBST.LOG.warn("Exception when trying to open website", e1);
                }
            }
        }
    });
    pan.add(lblWebsite, "cell 0 0,alignx center");

    JLabel lblVersion = new JLabel(Lang.get("about.version").replace("$v", OpenBST.VERSION));
    pan.add(lblVersion, "flowy,cell 0 1");

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBorder(new LineBorder(pan.getBackground().darker(), 1, false));
    pan.add(scrollPane, "cell 0 2,grow");

    JTextArea textArea = new JTextArea();
    textArea.setMargin(new Insets(5, 5, 5, 5));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    textArea.setFont(new Font(textArea.getFont().getFontName(), Font.PLAIN, (int) (Icons.getScale() * 11)));

    try (InputStream in = getClass().getResourceAsStream("/utybo/branchingstorytree/swing/about.txt");) {
        textArea.setText(IOUtils.toString(in, StandardCharsets.UTF_8));
    } catch (IOException ex) {
        OpenBST.LOG.warn("Loading about information failed", ex);
    }
    textArea.setEditable(false);
    textArea.setCaretPosition(0);
    scrollPane.setViewportView(textArea);

    JLabel lblTranslatedBy = new JLabel(Lang.get("author"));
    pan.add(lblTranslatedBy, "cell 0 1");

    setSize((int) (Icons.getScale() * 450), (int) (Icons.getScale() * 400));
    setLocationRelativeTo(parent);
}

From source file:views.online.Panel_RejoindrePartieMulti.java

/**
 * Constructeur/*from   www.  jav  a  2 s  .  c  om*/
 * 
 * @param parent le fenetre parent
 */
public Panel_RejoindrePartieMulti(JFrame parent) {
    // initialisation
    super(new BorderLayout());
    this.parent = parent;
    parent.setTitle(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL)));
    setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // ---------
    // -- TOP --
    // ---------
    JPanel pTop = new JPanel(new BorderLayout());
    pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    JLabel titre = new JLabel(Language.getTexte(Language.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    titre.setFont(ManageFonts.POLICE_TITRE);
    titre.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    pTop.add(titre, BorderLayout.NORTH);

    // filtre
    JPanel pADroite = new JPanel(new BorderLayout());
    pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    tfFiltre.setPreferredSize(new Dimension(100, 25));
    tfFiltre.addKeyListener(this);
    tfFiltre.addMouseListener(this);

    pADroite.add(tfFiltre, BorderLayout.WEST);
    pTop.add(pADroite, BorderLayout.CENTER);
    ManageFonts.setStyle(bRafraichir);
    pTop.add(bRafraichir, BorderLayout.EAST);
    bRafraichir.addActionListener(this);

    add(pTop, BorderLayout.NORTH);

    // ------------
    // -- CENTER --
    // ------------

    // cration de la table avec boquage des editions
    tbServeurs = new JTable(model) {
        public boolean isCellEditable(int rowIndex, int colIndex) {
            return false; // toujours dsactiv
        }
    };

    // Simple selection
    tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // nom de colonnes
    model.addColumn(Language.getTexte(Language.ID_TXT_NOM));
    model.addColumn(Language.getTexte(Language.ID_TXT_IP));
    model.addColumn(Language.getTexte(Language.ID_TXT_PORT));
    model.addColumn(Language.getTexte(Language.ID_TXT_MODE));
    model.addColumn(Language.getTexte(Language.ID_TXT_TERRAIN));
    model.addColumn(Language.getTexte(Language.ID_TXT_PLACES_DISPO));

    // Cration du canal avec le serveur d'enregistrement
    try {
        canalServeurEnregistrement = new ChannelTCP(Configuration.getIpSE(), Configuration.getPortSE());

        mettreAJourListeDesServeurs();
    } catch (ConnectException e) {
        connexionSEImpossible();
    } catch (ChannelException e) {
        connexionSEImpossible();
    }

    // ajout dans le panel
    add(new JScrollPane(tbServeurs), BorderLayout.CENTER);

    // ------------
    // -- BOTTOM --
    // ------------
    JPanel pBottom = new JPanel(new BorderLayout());
    pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    bRetour.addActionListener(this);
    ManageFonts.setStyle(bRetour);
    bRetour.setPreferredSize(new Dimension(80, 50));
    pBottom.add(bRetour, BorderLayout.WEST);

    JPanel bottomCenter = new JPanel();
    bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // connexion par IP 
    lblConnexionParIP.setFont(ManageFonts.POLICE_SOUS_TITRE);
    lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblConnexionParIP);
    tfConnexionParIP.setPreferredSize(new Dimension(100, 25));
    bottomCenter.add(tfConnexionParIP);
    tfConnexionParIP.addMouseListener(this);

    // pseudo
    JPanel pPseudo = new JPanel();
    JPanel pTmp = new JPanel();

    lblPseudo.setFont(ManageFonts.POLICE_SOUS_TITRE);
    lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblPseudo);

    tfPseudo.setText(Configuration.getPseudoJoueur());
    bottomCenter.add(tfPseudo);

    pPseudo.add(pTmp, BorderLayout.EAST);
    pBottom.add(bottomCenter, BorderLayout.CENTER);

    // bouton rejoindre
    bRejoindre.setPreferredSize(new Dimension(100, 50));
    ManageFonts.setStyle(bRejoindre);
    pBottom.add(bRejoindre, BorderLayout.EAST);
    bRejoindre.addActionListener(this);

    pBottom.add(lblEtat, BorderLayout.SOUTH);

    add(pBottom, BorderLayout.SOUTH);
}

From source file:vues.reseau.Panel_RejoindrePartieMulti.java

/**
 * Constructeur/*from w w  w  .  ja v a  2 s .com*/
 * 
 * @param parent le fenetre parent
 */
public Panel_RejoindrePartieMulti(JFrame parent) {
    // initialisation
    super(new BorderLayout());
    this.parent = parent;
    parent.setTitle(Langue.getTexte(Langue.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    setBorder(new EmptyBorder(new Insets(MARGES_PANEL, MARGES_PANEL, MARGES_PANEL, MARGES_PANEL)));
    setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // ---------
    // -- TOP --
    // ---------
    JPanel pTop = new JPanel(new BorderLayout());
    pTop.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    JLabel titre = new JLabel(Langue.getTexte(Langue.ID_TITRE_REJOINDRE_UNE_PARTIE_MULTI));
    titre.setFont(GestionnaireDesPolices.POLICE_TITRE);
    titre.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    pTop.add(titre, BorderLayout.NORTH);

    // filtre
    JPanel pADroite = new JPanel(new BorderLayout());
    pADroite.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    tfFiltre.setPreferredSize(new Dimension(100, 25));
    tfFiltre.addKeyListener(this);
    tfFiltre.addMouseListener(this);

    pADroite.add(tfFiltre, BorderLayout.WEST);
    pTop.add(pADroite, BorderLayout.CENTER);
    GestionnaireDesPolices.setStyle(bRafraichir);
    pTop.add(bRafraichir, BorderLayout.EAST);
    bRafraichir.addActionListener(this);

    add(pTop, BorderLayout.NORTH);

    // ------------
    // -- CENTER --
    // ------------

    // cration de la table avec boquage des editions
    tbServeurs = new JTable(model) {
        public boolean isCellEditable(int rowIndex, int colIndex) {
            return false; // toujours dsactiv
        }
    };

    // Simple selection
    tbServeurs.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    // nom de colonnes
    model.addColumn(Langue.getTexte(Langue.ID_TXT_NOM));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_IP));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_PORT));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_MODE));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_TERRAIN));
    model.addColumn(Langue.getTexte(Langue.ID_TXT_PLACES_DISPO));

    // Cration du canal avec le serveur d'enregistrement
    try {
        canalServeurEnregistrement = new CanalTCP(Configuration.getIpSE(), Configuration.getPortSE());

        mettreAJourListeDesServeurs();
    } catch (ConnectException e) {
        connexionSEImpossible();
    } catch (CanalException e) {
        connexionSEImpossible();
    }

    // ajout dans le panel
    add(new JScrollPane(tbServeurs), BorderLayout.CENTER);

    // ------------
    // -- BOTTOM --
    // ------------
    JPanel pBottom = new JPanel(new BorderLayout());
    pBottom.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    bRetour.addActionListener(this);
    GestionnaireDesPolices.setStyle(bRetour);
    bRetour.setPreferredSize(new Dimension(80, 50));
    pBottom.add(bRetour, BorderLayout.WEST);

    JPanel bottomCenter = new JPanel();
    bottomCenter.setBackground(LookInterface.COULEUR_DE_FOND_PRI);

    // connexion par IP 
    lblConnexionParIP.setFont(GestionnaireDesPolices.POLICE_SOUS_TITRE);
    lblConnexionParIP.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblConnexionParIP);
    tfConnexionParIP.setPreferredSize(new Dimension(100, 25));
    bottomCenter.add(tfConnexionParIP);
    tfConnexionParIP.addMouseListener(this);

    // pseudo
    JPanel pPseudo = new JPanel();
    JPanel pTmp = new JPanel();

    lblPseudo.setFont(GestionnaireDesPolices.POLICE_SOUS_TITRE);
    lblPseudo.setForeground(LookInterface.COULEUR_TEXTE_PRI);
    bottomCenter.add(lblPseudo);

    tfPseudo.setText(Configuration.getPseudoJoueur());
    bottomCenter.add(tfPseudo);

    pPseudo.add(pTmp, BorderLayout.EAST);
    pBottom.add(bottomCenter, BorderLayout.CENTER);

    // bouton rejoindre
    bRejoindre.setPreferredSize(new Dimension(100, 50));
    GestionnaireDesPolices.setStyle(bRejoindre);
    pBottom.add(bRejoindre, BorderLayout.EAST);
    bRejoindre.addActionListener(this);

    pBottom.add(lblEtat, BorderLayout.SOUTH);

    add(pBottom, BorderLayout.SOUTH);
}

From source file:xtrememp.XtremeMP.java

protected void createPanels() {
    JPanel framePanel = new JPanel(new MigLayout("fill"));

    mainPanel = new JPanel(new CardLayout());
    playlistManager = new PlaylistManager(this);
    visualizationManager = new VisualizationManager(audioPlayer.getDSS());
    if (Settings.getLastView().equals(Utilities.VISUALIZATION_PANEL)) {
        visualizationManager.setDssEnabled(true);
        mainPanel.add(visualizationManager, Utilities.VISUALIZATION_PANEL);
        mainPanel.add(playlistManager, Utilities.PLAYLIST_MANAGER);
        visualizationMenuItem.setSelected(true);
    } else {/*from  ww  w.  j av  a  2 s. co m*/
        mainPanel.add(playlistManager, Utilities.PLAYLIST_MANAGER);
        mainPanel.add(visualizationManager, Utilities.VISUALIZATION_PANEL);
        playlistManagerMenuItem.setSelected(true);
    }
    framePanel.add(mainPanel, "grow");

    JPanel southPanel = new JPanel(new MigLayout("fill", "[center]"));
    SubstanceLookAndFeel.setDecorationType(southPanel, DecorationAreaType.TOOLBAR);
    seekSlider = new SeekSlider(this);
    seekSlider.setEnabled(false);
    southPanel.add(seekSlider, "north, gap 4 4 1 0");

    controlPanel = new JPanel(new MigLayout("gap 0, ins 0", "[center]"));
    controlPanel.setOpaque(false);
    stopButton = new StopButton();
    stopButton.setEnabled(false);
    stopButton.addActionListener(this);
    controlPanel.add(stopButton);
    previousButton = new PreviousButton();
    previousButton.setEnabled(false);
    previousButton.addActionListener(this);
    controlPanel.add(previousButton);
    playPauseButton = new PlayPauseButton();
    playPauseButton.addActionListener(this);
    controlPanel.add(playPauseButton, "height pref!");
    nextButton = new NextButton();
    nextButton.setEnabled(false);
    nextButton.addActionListener(this);
    controlPanel.add(nextButton);
    volumeButton = new VolumeButton(Utilities.MIN_GAIN, Utilities.MAX_GAIN, Settings.getGain(),
            Settings.isMuted());
    volumeButton.addMouseWheelListener((MouseWheelEvent e) -> {
        try {
            int volumeValue = volumeSlider.getValue() - 5 * e.getWheelRotation();
            int volumeMin = volumeSlider.getMinimum();
            int volumeMax = volumeSlider.getMaximum();
            if (volumeValue < volumeMin) {
                volumeValue = volumeMin;
            } else if (volumeValue > volumeMax) {
                volumeValue = volumeMax;
            }
            volumeButton.setVolumeIcon(volumeValue);
            volumeSlider.setValue(volumeValue);
            audioPlayer.setGain(volumeValue / 100.0F);
            Settings.setGain(volumeValue);
        } catch (PlayerException ex) {
            logger.debug(ex.getMessage(), ex);
        }
    });
    JPopupMenu volumePopupMenu = volumeButton.getPopupMenu();
    volumeSlider = new JSlider(JSlider.VERTICAL, Utilities.MIN_GAIN, Utilities.MAX_GAIN, Settings.getGain());
    volumeSlider.setMajorTickSpacing(25);
    volumeSlider.setMinorTickSpacing(5);
    volumeSlider.setPaintTicks(true);
    volumeSlider.setPaintLabels(true);
    volumeSlider.addChangeListener((ChangeEvent e) -> {
        if (volumeSlider.getValueIsAdjusting()) {
            try {
                int volumeValue = volumeSlider.getValue();
                volumeButton.setVolumeIcon(volumeValue);
                audioPlayer.setGain(volumeValue / 100.0F);
                Settings.setGain(volumeValue);
            } catch (PlayerException ex) {
                logger.debug(ex.getMessage(), ex);
            }
        }
    });
    volumeSlider.setEnabled(!Settings.isMuted());
    JPanel volumePanel = new JPanel(new MigLayout("fill"));
    JLabel volumeLabel = new JLabel(tr("MainFrame.Menu.Player.Volume"), JLabel.CENTER);
    volumeLabel.setFont(volumeLabel.getFont().deriveFont(Font.BOLD));
    volumePanel.add(volumeLabel, "north");
    volumePanel.add(volumeSlider);
    JCheckBox muteCheckBox = new JCheckBox(tr("MainFrame.Menu.Player.Mute"));
    muteCheckBox.setSelected(Settings.isMuted());
    muteCheckBox.addItemListener((ItemEvent e) -> {
        try {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                volumeSlider.setEnabled(false);
                volumeButton.setVolumeMutedIcon();
                audioPlayer.setMuted(true);
                Settings.setMuted(true);
            } else {
                volumeSlider.setEnabled(true);
                volumeButton.setVolumeIcon(Settings.getGain());
                audioPlayer.setMuted(false);
                Settings.setMuted(false);
            }
        } catch (PlayerException ex) {
            logger.debug(ex.getMessage(), ex);
        }
    });
    volumePanel.add(muteCheckBox, "south");
    volumePopupMenu.add(volumePanel);
    controlPanel.add(volumeButton);
    southPanel.add(controlPanel, "gap 0 0 2 5");

    JPanel statusBar = new JPanel(new MigLayout("ins 2 0 2 0"));
    SubstanceLookAndFeel.setDecorationType(statusBar, DecorationAreaType.FOOTER);
    timeLabel = new JLabel(Utilities.ZERO_TIMER);
    timeLabel.setFont(timeLabel.getFont().deriveFont(Font.BOLD));
    statusBar.add(timeLabel, "gap 6 6 0 0, west");
    statusBar.add(new JSeparator(SwingConstants.VERTICAL), "hmin 16");
    statusLabel = new JLabel();
    statusBar.add(statusLabel, "gap 0 2 0 0, wmin 0, push");
    statusBar.add(new JSeparator(SwingConstants.VERTICAL), "hmin 16");
    playModeLabel = new JLabel();
    playModeLabel.addMouseListener(new MouseAdapter() {

        @Override
        public void mousePressed(MouseEvent e) {
            Playlist.PlayMode[] playModes = Playlist.PlayMode.values();
            Playlist.PlayMode playMode = playlist.getPlayMode();
            int ordinal = playMode.ordinal();
            playlist.setPlayMode(playModes[(ordinal == playModes.length - 1) ? 0 : ordinal + 1]);
        }
    });
    statusBar.add(playModeLabel, "east, gap 2 2 2 2, width 18!, height 18!");
    southPanel.add(statusBar, "south");
    framePanel.add(southPanel, "south");
    mainFrame.setContentPane(framePanel);
}