Results 1 to 3 of 3
  1. #1
    rahilgada is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default 2d array input user for gui

    Java Code:
    [CODE]import javax.swing.*;
       import javax.swing.table.*;
       import java.awt.*;
    
       public class SortTable {
         public static void main(String args[]) {
           Runnable runner = new Runnable() {
            public void run() {
               JFrame frame = new JFrame("Sorting JTable");
               frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
               Object rows[][] = {new Object[10][10]
                    
    
                 };// user input
               String columns[] = {"Name", "Roll No", "Sub1",”Sub2”,”total”,”Result”,};
               TableModel model =
                   new DefaultTableModel(rows, columns) {
                 public Class getColumnClass(int column) {
                   Class returnValue;
                   if ((column >= 0) && (column < getColumnCount())) {
                     returnValue = getValueAt(0, column).getClass();
                   } else {
                     returnValue = Object.class;
                   }
                   return returnValue;
                 }
               };
    
               JTable table = new JTable(model);
               RowSorter<TableModel> sorter =
                 new TableRowSorter<TableModel>(model);
               table.setRowSorter(sorter);
               JScrollPane pane = new JScrollPane(table);
               frame.add(pane, BorderLayout.CENTER);
               frame.setSize(300, 150);
               frame.setVisible(true);
             }
           };
           EventQueue.invokeLater(runner);
         }
       }
    [/CODE]

    Hello every1! can some1 help me to add user input.
    Thank u in advance..

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    843
    Rep Power
    6

    Default Re: 2d array input user for gui

    Please correct the compilation errors and explain clearly where u need user input?
    Ramya:cool:

  3. #3
    rahilgada is offline Member
    Join Date
    Feb 2014
    Posts
    6
    Rep Power
    0

    Default Re: 2d array input user for gui

    i just want to add user input to each individual rows

Similar Threads

  1. How to get user input stored in an array
    By ryan4509 in forum New To Java
    Replies: 3
    Last Post: 06-09-2013, 01:50 AM
  2. How to print array from user input?
    By sims34 in forum New To Java
    Replies: 1
    Last Post: 01-29-2013, 05:46 AM
  3. How to store user input into an array
    By codyjava in forum New To Java
    Replies: 11
    Last Post: 12-02-2012, 05:08 AM
  4. Creating 2D array from all user input
    By peek_a_boo in forum New To Java
    Replies: 1
    Last Post: 12-08-2011, 09:16 PM
  5. user input array
    By localhost in forum New To Java
    Replies: 5
    Last Post: 12-30-2010, 05:00 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •