Q:

Checkbox align in 3 rows

Hello i am coding a JFrame which has alot of checkboxes which are dynamically generated i want to make sure these checkboxes come in 4 different columns and the submit button at the end please help 
Here is the code 
final JFrame frame=new JFrame("Button Frame");
            //JCheckBox[] checkBoxes = new JCheckBox[6];
            final JCheckBox[] checkBoxes= //= {new JCheckBox("bool"), new JCheckBox("list"), new JCheckBox("3"), new JCheckBox("4"), new JCheckBox("5"), new JCheckBox("6")};
            {
                new JCheckBox("alist"),new JCheckBox("arithmetic"),new JCheckBox("ASCIInumbers"),new JCheckBox("bag"),    
                new JCheckBox("basicSize"),new JCheckBox(" basis_emit"),new JCheckBox("bitstring"),new JCheckBox("bit"),        
                new JCheckBox("blast"),new JCheckBox("bool"),new JCheckBox("canonical"),new JCheckBox("Coder"),       
                new JCheckBox("combin"),new JCheckBox("complex"),new JCheckBox("ConseqConv"),new JCheckBox("container"),
                new JCheckBox("Decode"),new JCheckBox("DeepSyntax"),new JCheckBox("defCNF"),new JCheckBox("divides"),
                new JCheckBox("Encode"),new JCheckBox("EncodeVar"),new JCheckBox("extended_emit"),new JCheckBox("extreal"),new JCheckBox("fcp"),       
                new JCheckBox("finite_map"),new JCheckBox("fixedPoint"),new JCheckBox("float"),new JCheckBox("fmaptree"),   
                new JCheckBox("frac"),new JCheckBox("gcdset"),new JCheckBox("gcd"),new JCheckBox("HolSmt"),new JCheckBox("hrat"),    
                new JCheckBox("hreal"),new JCheckBox("ieee"),new JCheckBox("ind_type"), new JCheckBox("inftree"),
                new JCheckBox("int_arith"),new JCheckBox("integer_word"),new JCheckBox("integerRing"),new JCheckBox("integer"),     
                new JCheckBox("integral"),new JCheckBox("intExtension"),new JCheckBox("intreal"),new JCheckBox("lbtree"),new JCheckBox("lebesgue"),   
                new JCheckBox("lim"),new JCheckBox("list"),new JCheckBox("llist"),new JCheckBox("logroot"),   
                new JCheckBox("marker"),new JCheckBox("measure"),new JCheckBox("nets"),new JCheckBox("normalForms"),   
                new JCheckBox("numeral_bit"),new JCheckBox("numeral"),new JCheckBox("numpair"),new JCheckBox("numposrep"),    
                new JCheckBox("numRing"),new JCheckBox("num"),new JCheckBox("Omega_Automata"),new JCheckBox("Omega"),new JCheckBox("one"),
                new JCheckBox("operator"),new JCheckBox("option"),new JCheckBox("pair"),     
                new JCheckBox("Past_Temporal_Logic"),new JCheckBox("path"),new JCheckBox("patricia_casts"),new JCheckBox("patricia"),  
                new JCheckBox("poly"),new JCheckBox("poset"),new JCheckBox("powser"),        
                new JCheckBox("pred_set"),new JCheckBox("prelim"),new JCheckBox("prim_rec"),new JCheckBox("primeFactor"),new JCheckBox("probability"),    
                new JCheckBox("quantHeuristics"),new JCheckBox("quote"),      
                new JCheckBox("quotient_list"),new JCheckBox("quotient_option"),new JCheckBox("quotient_pair"),new JCheckBox("quotient_pred_set"),new JCheckBox("quotient_sum"),     
                new JCheckBox("quotient"),new JCheckBox("ratRing"),new JCheckBox("rat"),new JCheckBox("real_sigma"),
                new JCheckBox("realax"),new JCheckBox("real"),new JCheckBox("relation"),new JCheckBox("res_quan"),     
                new JCheckBox("rich_list"),new JCheckBox("ringNorm"),new JCheckBox("ring"),new JCheckBox("sat"),new JCheckBox("semi_ring"),     
                new JCheckBox("seq"),new JCheckBox("set_relation"),new JCheckBox("sorting"),    
                new JCheckBox("state_option"),new JCheckBox("state_transformer"),new JCheckBox("string_num"),new JCheckBox("string"), 
                new JCheckBox("sum_num"),new JCheckBox("sum"),new JCheckBox("Temporal_Logic"),   
                new JCheckBox("topology"),new JCheckBox("transc"),new JCheckBox("update"),new JCheckBox("util_prob"),new JCheckBox("while"),new JCheckBox("words")};

            int numb=checkBoxes.length;
            //List<Checkbox> checkboxes = new ArrayList<Checkbox>();
            int align = BoxLayout.PAGE_AXIS;

            frame.setLayout(new FlowLayout(align));
           // String labels[] = {"A", "B", "C", "D", "E", "F"};
            for (int i = 0; i < numb; i++) {
                //checkBoxes[i].setText(labels[i]);
                frame.add(checkBoxes[i]);
               // Checkbox checkbox = new Checkbooks(labels[i]);
                //checkboxes.add(checkbox); //for further use you add it to the list
                //frame.add(checkbox);
            }
            JButton button = new JButton("Submit");
            frame.add(button);

        }

            frame.setSize(600,600);
            frame.setVisible(true);
            button.addActionListener(new ActionListener() {
                int numb=checkBoxes.length;

                @Override
                public void actionPerformed(ActionEvent arg0) {
                    for(int a=0;a<numb;a++)
                    {
                        if (checkBoxes[a].isSelected()) {

                            //execute("app load [\""+checkBoxes[a].getText()+"Theory\"]; open "+checkBoxes[a].getText()+"Theory;");
                            JOptionPane.showMessageDialog(frame, checkBoxes[a].getText());
                        }
                    }

Here is the image of my current view 

                        }

A:

Don't use a FlowLayout. Instead you should be using a GridLayout.
Read the section from the Swing tutorial on How to Use GridLayout for more information and examples.
If you don't want the button as part of the Grid then you will need to nest panels with different layout managers.

