Hello im a new
java programmer and i have a problem with my code.
The serializable class Javabt does not declare a static final serialVersionUID field of type long
this error alert pops up on my Javabt class below. PLEASE HELP im goin nuts...
the code
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JFrame;
import javax.swing.ButtonGroup;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
ERROR
The serializable class Javabt does not declare a static final serialVersionUID field of type long
public class Javabt extends JFrame {
<<<<JPanel(Container)addImpl(Component,Object,Int) line: not available DEBUGERROR
private JTextField tf;
private Font pf;
private Font bf;
private Font itf;
private Font bif;
private JRadioButton pb;
private JRadioButton bb;
private JRadioButton ib;
private JRadioButton bib;
private ButtonGroup group;
public Javabt(){
super("The title");
setLayout(new FlowLayout());
tf = new JTextField("Tony and bunny forever", 25);
add(tf);
pb = new JRadioButton("plain", true);
pb = new JRadioButton("bold", false);
ib = new JRadioButton("italic", false);
bib = new JRadioButton("Bold and italic", false);
add(pb);
add(bb);
add(ib);
add(bib);
group = new ButtonGroup(); // buttons need to be grouped to know if another button in group is checked.
group.add(pb);
group.add(pb);
group.add(ib);
group.add(bib);
pf = new Font("Serif", Font.PLAIN, 14);
bf = new Font("Serif", Font.BOLD, 14);
itf = new Font("Serif", Font.ITALIC, 14);
bif = new Font("Serif", Font.BOLD + Font.ITALIC, 14);
tf.setFont(pf);
pb.addItemListener(new HandlerClass(pf)); //listens for user command, pass in font object to constructor
bb.addItemListener(new HandlerClass(bf)); //takes HandlerClass object as its attributes.
ib.addItemListener(new HandlerClass(itf));
bib.addItemListener(new HandlerClass(bif));
}
private class HandlerClass implements ItemListener{
private Font font;
//the font object get variable font
public HandlerClass(Font f){
font = f;
}
public void itemStateChanged(ItemEvent event){
tf.setFont(font);
}
}
}
>>>>MAIN<<<<
import javax.swing.JFrame;
public class Mainpoop {
public static void main(
String[] args) {
Javabt go = new Javabt();
go.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
go.setSize(300,200); //size of frame width, height in pixels
go.setVisible(true);
}
}