Link to home
Start Free TrialLog in
Avatar of Drop_of_Rain
Drop_of_Rain

asked on

This came as a solution for a jlabel on top of the jpanel

It didn't work a method cll from nowhere I guess! HELP



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

public class MyClass4 extends JPanel {

  JLabel jLabel1;  
  ArrayList myArrayList = new ArrayList();

public MyClass4() {

     // Call it like this . . .
    jLabel = JLabel();

    setLayout(new GridLayout(0,3)); // Setting MY layout...
 
    add(jLabel1);  
    jLabel1.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);
    }
    }
}
}
Avatar of Javatm
Javatm
Flag of Singapore image

I didnt get the question can you clarify it ?
Avatar of Drop_of_Rain
Drop_of_Rain

ASKER

error message can't resolve method   jLabel = JLabel();
It is because it should be like :

jLabel = new JLabel();

here it is :

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

public class MyClass4 extends JPanel {

  JLabel jLabel1;  
  ArrayList myArrayList = new ArrayList();

public MyClass4() {

     // Call it like this . . .
    jLabel = new JLabel();

    setLayout(new GridLayout(0,3)); // Setting MY layout...
 
    add(jLabel1);  
    jLabel1.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);
    }
    }
}
}
you're also mixing names, jLabel and jLabel1.
ASKER CERTIFIED SOLUTION
Avatar of Javatm
Javatm
Flag of Singapore image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial