Solved

Error can't resolve Class  GridLayout

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

839 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