Solved

Change the numbers of the chechboxs

Posted on 2004-04-02
3
211 Views
Last Modified: 2010-03-31
Hello everyone out there, another question.

How could I get the numbers to start at 1 and end in 50
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() {
// JPanel myPanel = new JPanel(); // No JPanel - why do we need it? I'M a JPanel...
setLayout(new GridLayout(0,3)); // Setting MY layout...
for (int row=0; row<20; row++) {
for(int col=0; col<3; col++) {
JCheckBox check = new JCheckBox("" + (20*col+row));
myArrayList.add(check);
add(check); // Adding it to ME
}
}
// myPanel.setLayout(new FlowLayout()); Why would I change the layout back to FlowLayout? All hell would break loose...
// add(myPanel); Don't need it at it's ME...
}
}
0
Comment
Question by:Drop_of_Rain
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Webstorm earned 75 total points
ID: 10742031
Hi Drop_of_Rain,

Try this:

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);

0
 

Author Comment

by:Drop_of_Rain
ID: 10742387
I didn't know about looprow:

Thanks
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 10747147
:-)

looprow: is a label which indicate which loop you want to break or continue, ...
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to parse custom JSON to POJO java 4 73
JUnit 4 @Before and @BeforeClass differences 3 60
rhino JavaScript import, load 25 84
jsp login check 12 32
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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

810 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