Problem z metodą .setFont.

0

Witam.
Mam takie pewnie banalny problem, że .setFont świeci się na czerwono. Kod:

import javax.swing.;
import javax.swing.JCheckBox;
import java.awt.
;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Font;
import javax.swing.JFrame;

public class CelsiusToFarenheit extends JFrame implements ActionListener
{
private JLabel LblCelsius, LblFarenheit;
private JTextField TxtCelsius, TxtFarenheit;
private JButton BtnKonwertuj;
private JCheckBox chWielkie;
private double tempCelsius,tempFarenheit;

public CelsiusToFarenheit()
{
    setSize(550, 250);
    setTitle("Przelicznie stopni celsiusza na farenheita");
    setLayout(null);

    //Celsius
    LblCelsius = new JLabel("Stopnie celsiusza");
    LblCelsius.setBounds(20,20,150,20);
    add(LblCelsius);

    TxtCelsius = new JTextField("");
    TxtCelsius.setBounds(170,20,150,20);
    add(TxtCelsius);

    //Farenheit
    LblFarenheit = new JLabel("Stopnie farenheita");
    LblFarenheit.setBounds(20,70,150,20);
    add(LblFarenheit);

    TxtFarenheit = new JTextField("");
    TxtFarenheit.setBounds(170,70,150,20);
    add(TxtFarenheit);

    //Przycisk
    BtnKonwertuj = new JButton("Konwertuj");
    BtnKonwertuj.setBounds(120,125,150,20);
    add(BtnKonwertuj);
    BtnKonwertuj.addActionListener(this);

    //Wielkie Litery
    chWielkie = new JCheckBox("Wielkie Litery");
    chWielkie.setBounds(300, 130, 150, 15);
    add(chWielkie);
    chWielkie.addActionListener(this);

}

@Override
public void actionPerformed(ActionEvent e) {

    Object zrodlo = e.getSource();
    if(zrodlo==BtnKonwertuj)
    {
        tempCelsius = Double.parseDouble(TxtCelsius.getText());
        tempFarenheit = 32.0 + (9.0/5.0) * tempCelsius;
        TxtFarenheit.setText(String.valueOf(tempFarenheit));
    }
    else if (zrodlo==chWielkie)
    {
        if (chWielkie.isSelected()==true)
        {
            tempFarenheit.setFont(new Font("SansSerif", Font.BOLD, 18));
        }
        else
        {
            tempFarenheit.setFont(new Font("SansSerif", Font.PLAIN, 12));

        }
    }

    }
public static void main(String[] args)
{
    CelsiusToFarenheit aplikacja = new CelsiusToFarenheit() ;
    aplikacja.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    aplikacja.setVisible(true);
}

}
Jak mam zaimportować .setFont?

0

tempFarenheit to double - nie zmienisz temu czcionki :P

1 użytkowników online, w tym zalogowanych: 0, gości: 1