[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Error can't resolve Class  GridLayout

Posted on 2004-04-03
5
Medium Priority
?
245 Views
Last Modified: 2010-03-31
Why does #1 compile fine, while #2  Error can't resolve Class  GridLayout

#1
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;

public class MyClass extends JPanel {

ArrayList myArrayList = new ArrayList();

// Constructor
public MyClass() {

setLayout(new GridLayout(0,3)); // Setting MY layout...
looprow:
for (int row=0; row<20; row++) {
for(int col=0; col<3; col++) {
int n=(20*col+row+1);
if (n>50) break looprow;
JCheckBox check = new JCheckBox("" + n);
}
}

}
}



#2
import java.awt.event.*;
import java.util.*;
import javax.swing.*;

public class MyClass4 extends JPanel {

  JLabel jLabel = new JLabel();
  ArrayList myArrayList = new ArrayList();

public MyClass4() {

     // Call it like this . . .
    JPanel p1 = new JPanel();

    p1.setLayout(new GridLayout(0,3));// Setting MY layout...
 
    add(jLabel);  
    jLabel.setText("Defensive Moves");
    setBackground(Color.white);

    looprow:
    for (int row=0; row<20; row++) {
    for(int col=0; col<3; col++) {
    int n=(20*col+row+1);
    if (n>50) break looprow;
    JCheckBox check = new JCheckBox("" + n);

    myArrayList.add(check);
    add(check);
    }
    }
}
}
0
Comment
Question by:Drop_of_Rain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 500 total points
ID: 10748216
you need
import java.awt.*;
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10748219
or just
import java.awt.GridLayout;
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10748245
or use fully qualified name:
    p1.setLayout(new java.awt.GridLayout(0,3));// Setting MY layout...
0
 

Author Comment

by:Drop_of_Rain
ID: 10748295
Thanks, I have another question up
0
 
LVL 30

Expert Comment

by:GrandSchtroumpf
ID: 10748459
:°)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question