Drop_of_Rain
asked on
Need Label on top of Jpanel
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class MyClass4 extends JPanel {
ArrayList myArrayList = new ArrayList();
// Constructor
public MyClass4() {
setLayout(new GridLayout(0,3)); // Setting MY layout...
JLabel jLabel1 = new JLabel();
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); // Adding it to ME
}
}
}
}
import java.awt.event.*;
import java.util.*;
import javax.swing.*;
public class MyClass4 extends JPanel {
ArrayList myArrayList = new ArrayList();
// Constructor
public MyClass4() {
setLayout(new GridLayout(0,3)); // Setting MY layout...
JLabel jLabel1 = new JLabel();
add(jLabel1); jLabel1.setText("Defensive
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); // Adding it to ME
}
}
}
}
ASKER
That isn't creating what I need. I need it to be in the top center. It is in the left top corner but is changing the layout of thr columns.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the support,
Christopher
Christopher
// Here is the new JLabel . . .
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
add(jLabel1); add(jLabel1);
jLabel1.setText("Defensive
setBackground(Color.white)
Hope that helps . . .
Javatm