1

So, I'm writing a java code that get a number of places from a file (int pl), the places are named by their number from 1 to max place number(pl). So I want to get the available places from those places from user. I want to create in GUI a list of Chekboxes with their names place 1 place 2

------ place pl

and the user check the available places

package dlp;
import java.io.*;
import java.util.ArrayList;
import javax.swing.*;

public class Run1 extends javax.swing.JFrame {

public Run1() {
    initComponents();
}

public static void main(String args[])  throws IOException  {
  FileReader fr = new FileReader("Dis.txt");
  ArrayList<Integer> dis = new ArrayList();
  String di=  fr.toString();
  String[] d = di.split(" ");

      for(int i=0; i<d.length;i++){
        dis.add(Integer.parseInt(d[i]));          
      }

 FileReader f2=new FileReader("Pla.txt");
 String s=f2.toString();
 int pl = Integer.parseInt(s);      
}
Roman C
  • 49,761
  • 33
  • 66
  • 176
Firas Gerges
  • 67
  • 1
  • 7
  • Dont paste the netbean's code Paste the code where you actally think that some question logic is required – Deepak Dec 04 '13 at 16:57
  • 1
    how to create in GUI a list of Chekboxes with their names place 1 place 2 ------ place pl and the user check the available places – Firas Gerges Dec 04 '13 at 17:01

1 Answers1

2

One approach might be to use a JTable. The default renderer and editor for a model value of type Boolean.class is a JCheckBox. Examples illustrating single- and multiple-selection are shown here and here, respectively.

image1

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • +1, And What is the reason for a icon name with `trash` :| This name doesn't fit with your nicer and simplistic personality at all. :) – Sage Dec 04 '13 at 18:09
  • The trashcan is my most important design tool! :-) – trashgod Dec 04 '13 at 18:49