File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes JPanel(Container)addImpl(Component,Object,Int) line: not available Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JPanel(Container)addImpl(Component,Object,Int) line: not available" Watch "JPanel(Container)addImpl(Component,Object,Int) line: not available" New topic
Author

JPanel(Container)addImpl(Component,Object,Int) line: not available

Tony Rosamilia
Greenhorn

Joined: Feb 09, 2013
Posts: 1
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);

}

}
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Are you sure it's an error and not merely a warning? Either way, the solution is easy: add the serialVersionUID field.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2170
    
  47
Welcome to the Ranch.

This question isn't related to I/O and Streams so I've moved the thread to the Swing forum for you.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
Rob Spoor wrote:Are you sure it's an error and not merely a warning? Either way, the solution is easy: add the serialVersionUID field.
It’s definitely not an error. I wrote about it this morning: here. It is worth reading the two links I quoted, too.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JPanel(Container)addImpl(Component,Object,Int) line: not available
 
Similar Threads
else if
How do i apply font styles and sizes to a string ?
Help i need help with borderlayout