Solved

Error can't resolve Class  GridLayout

Posted on 2004-04-03
5
230 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
  • 4
5 Comments
 
LVL 30

Accepted Solution

by:
GrandSchtroumpf earned 125 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now