File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Class Container not found :( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Class Container not found :( " Watch "Class Container not found :( " New topic

Class Container not found :(

Renu Mahesh

Joined: Sep 14, 2004
Posts: 2
I am new to swing. Trying to learn. I am trying to write some code to add a few labels, text fields and a button and add them to the JFrame. When I am setting the layout to Gridlayout and trying to compile, I am getting an error message "Class Container not found". can somebody help me?
Bernhard Jung

Joined: Sep 14, 2004
Posts: 11
read this:

import java.awt.*;
import javax.swing.*;

or post some code please.
[ September 15, 2004: Message edited by: Nargaff ]
Renu Mahesh

Joined: Sep 14, 2004
Posts: 2
The code is

import javax.swing.*;
import java.awt.*;
public class SampleCode extends JFrame{
JLabel name = new JLabel("Name");
JLabel occupation = new JLabel("occupation");
JButton submit = new JButton ("Submit");
JTextField txt_name = new JTextField(25);
JTextField txt_Occupation = new JTextField(35);
public static void main(String args[]){
SampleCode sc = new SampleCode();
Container cont = sc.getContentPane();
cont.setLayout(new GridLayout(2,2));

Bernhard Jung

Joined: Sep 14, 2004
Posts: 11
I don't get the 'Class Container not found' message, but check your Classpath if you still get it.

Trying to compile i get this:
non-static variable name cannot be referenced from a static context

You have to understand what's the difference between a class, an object/instance, a static field and a instance field.
and I recommend reading chapter 1+2 of 'Thinking in Java'.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24183


Welcome to JavaRanch!

You may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. Initials aren't enough. You can change your display name here.
Thanks, pardner, and hope to see you around the Ranch!

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: Class Container not found :(
Similar Threads
How to Add Scroll bars to a frame
jsp.JspException: No collection found
Dialog Class - Need an Example..
overriding methods in AbstractCollection
Event Listeners