Solved

Error can't resolve Class  GridLayout

Posted on 2004-04-03
5
228 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
array220 challenge 8 48
wordcount challenge 11 76
for i loop in grovy 1 32
Groovy:unable to resolve class error 2 31
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

759 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