Using custom table model with the Net Beans JTable

I am using the net beans editor to create an application. For the JTable that net beans provides, I would like to use my own Table Model instead of the default one that is provided. How do I specify to the form editor that I want to use my own TableModel instead of the DeafaultTableModel?

I am using the net beans editor to create an application. For the JTable that net beans provides, I would like to use my own Table Model instead of the default one that is provided. How do I specify to the form editor that I want to use my own TableModel instead of the DeafaultTableModel?

Similar Messages

  • JTable column headers not displaying using custom table model

    Hi,
    I'm attempting to use a custom table model (by extending AbstractTableModel) to display the contents of a data set in a JTable. The table is displaying the data itself correctly but there are no column headers appearing. I have overridden getColumnName of the table model to return the correct header and have tried playing with the ColumnModel for the table but have not been able to get the headers to display (at all).
    Any ideas?
    Cheers

    Class PublicationTableModel:
    public class PublicationTableModel extends AbstractTableModel
        PublicationManager pubManager;
        /** Creates a new instance of PublicationTableModel */
        public PublicationTableModel(PublicationManager pm)
            super();
            pubManager = pm;
        public int getColumnCount()
            return GUISettings.getDisplayedFieldCount();
        public int getRowCount()
            return pubManager.getPublicationCount();
        public Class getColumnClass(int columnIndex)
            Object o = getValueAt(0, columnIndex);
            if (o != null) return o.getClass();
            return (new String()).getClass();
        public String getColumnName(int columnIndex)
            System.out.println("asked for column name "+columnIndex+" --> "+GUISettings.getColumnName(columnIndex));
            return GUISettings.getColumnName(columnIndex);
        public Publication getPublicationAt(int rowIndex)
            return pubManager.getPublicationAt(rowIndex);
        public Object getValueAt(int rowIndex, int columnIndex)
            Publication pub = (Publication)pubManager.getPublicationAt(rowIndex);
            String columnName = getColumnName(columnIndex);
            if (columnName.equals("Address"))
                if (pub instanceof Address) return ((Address)pub).getAddress();
                else return null;
            else if (columnName.equals("Annotation"))
                if (pub instanceof Annotation) return ((Annotation)pub).getAnnotation();
                else return null;
            etc
           else if (columnName.equals("Title"))
                return pub.getTitle();
            else if (columnName.equals("Key"))
                return pub.getKey();
            return null;
        public boolean isCellEditable(int rowIndex, int colIndex)
            return false;
        public void setValueAt(Object vValue, int rowIndex, int colIndex)
        }Class GUISettings:
    public class GUISettings {
        private static Vector fields = new Vector();
        private static Vector classes = new Vector();
        /** Creates a new instance of GUISettings */
        public GUISettings() {
        public static void setFields(Vector f)
            fields=f;
        public static int getDisplayedFieldCount()
            return fields.size();
        public static String getColumnName(int columnIndex)
            return (String)fields.elementAt(columnIndex);
        public static Vector getFields()
            return fields;
    }GUISettings.setFields has been called before table is displayed.
    Cheers,
    garsher

  • JTable: Custom Table Model (pI)

    This is a follow-up to thread http://forum.java.sun.com/thread.jspa?threadID=725162 and thread http://forum.java.sun.com/thread.jspa?threadID=725158.
    As I'm hoping to have a table of 5 columns, where the 4th and 5th columns are for integer and float data types respectively, I am creating a custom table model under the assumption that I will not know beforehand the number of rows the table will contain.
    Problems? Having not specified the cell contents of the table, since it will be pupulated by users unknown to me, I did not declare or initialize a variable similar to TableDemo's data variable of type Object (see the TableDemo tutorial http://java.sun.com/docs/books/tutorial/uiswing/components/example-swing/TableDemo.java). As such, I am unable to specify the return parameters for the getRowCount() and getValueAt(~, ~) methods.
    To overcome this, I sought to replicate the example shown in TableDemo by doing the following:
    Object[][] cell = {"", "", "", new Integer(0), new Float(0.00f)};
    public int getRowCount()
      returncell.length;
    public Object getValueAt(int row, int column)
      return cell[row][column];
    //...I got the following errors:
    pathname\CustomTableModel.java:line #: incompatible types
    found: java.lang.String
    required: java.lang.Object[]
    and the errors continue...
    So I tried
    Object[] cell = {"", "", "", new Integer(0), new Float(0.00f)};
    // ...However, I got this error:
    C:\...\CustomTableModel.java:line #:array required, but java.lang.String found
    return cell[row][column];
    .......................... ^
    I just want to set the return parameters for getRowCount() and getValueAt(~,~) in the custom table model I'm creating. How do I do this?
    Cheers!
    PS Thanks for reading this far...

    I decided to use the DefaultTableModel, after all. I was using it before, but at the time, i didn't know that certain things I wanted to accomplish, it could too.
    Anyways, here's what I have been doing: http://forum.java.sun.com/thread.jspa?threadID=725861
    Thanks nonetheless for your help. And by the way, my client is adamant that I use a LinkedList, rather than a Vector for this project. But nevertheless, thanks.

  • Want to add rows from database in custom table model

    Hello all,
    I have written custom table model which has single blank row intially.
    Once user clicks on button, i want to add more rows in custom table model and display them in JTable.
    I have created JTable object as shown below.
    Jtable patientTable = new JTable( new DiagnosticTableModel());
    My custom tabel model is as shown below.
    import javax.swing.table.AbstractTableModel;
    public class DiagnosticTableModel extends AbstractTableModel
         private String[] columnNames = {
                         "Date",
                                              "Diagnosis",
                                              "Severity",
                                              "Medications"};
         private String[][] data = {
          public int getColumnCount()
             return columnNames.length;
          public int getRowCount()
               return data.length;
          public String getColumnName(int col)
             return columnNames[col];
          public Class getColumnClass(int col)
             return getValueAt(0, col).getClass();
          public Object getValueAt(int row, int col)
             return data[row][col];
          public boolean isCellEditable(int row, int col)
          return true;
          public void setValueAt(Object value, int row, int col)
             data[row][col] = value.toString();
             fireTableCellUpdated(row, col);
    }Thanx a lot in advance.

    I have written custom table model which has single blank row intially.Why did you write a custom TableModel? The DefaultTableModel will work fine and it has methods that allow you to dynamically add rows to the table.

  • Dynamic Table Creation with the sortable collection model in the bean.

    Hi all,
    My requirement: I want to create the table dynamically with the set of rows. This set of rows will be holded in the Bean for the sortable variable.
    (private SortableModel viewDeleteCollectionModel)
    Issue: "_No Data to Display_" is coming in the Dynamic Table. Whereas when i checked with the collection model row count it is showing the correct no of rows.
    Code for Dynamic Table in JSFF:
    <af:table varStatus="rowStat" value="#{ViewHistoryDelete.viewDeleteCollectionModel}"
    rows="#{ViewHistoryDelete.viewDeleteCollectionModel.rowCount}"
    rowSelection="single" width="99%" var="row" id="t2" summary=" " >
    <af:forEach items="#{ViewHistoryDelete.viewDeleteColumnNames}" var="name">
    <af:column headerText="#{name}" sortable="true" sortProperty="#{name}" id="pt_c1">
    <af:inputText value="#{row[name]}" label="#{row[name]}" readOnly="true" id="it2"/>
    </af:column>
    </af:forEach>
    </af:table>
    Bean Code:
    Varaible DEclaration : private SortableModel viewDeleteCollectionModel;
    Row assignig to collection model : viewDeleteCollectionModel = new SortableModel(new ArrayList<Map<String, Object>>());
    ((List<Map<String, Object>>) viewDeleteCollectionModel.getWrappedData()).addAll(viewDeletedData);
    viewHistoryDelete.setViewDeleteCollectionModel(viewDeleteCollectionModel);
    After this iam checked by putting sop for the table row count
    iam getting actual no.of rows. But to the screen it is not showing the rows.
    Any solution............
    reg,
    bakkia.
    Edited by: Bakkia on Oct 11, 2011 11:20 PM

    Did you find solution to this problem ?

  • JButton in JTable with custom table model

    Hi!
    I want to include a JButton into a field of a JTable. I do not know why Java does not provide a standard renderer for JButton like it does for JCheckBox, JComboBox and JTextField. I found some previous postings on how to implement custom CellRenderer and CellEditor in order to be able to integrate a button into the table. In my case I am also using a custom table model and I was not able to create a clickable button with any of the resources that I have found. The most comprehensive resource that I have found is this one: http://www.java2s.com/Code/Java/Swing-Components/ButtonTableExample.htm.
    It works fine (rendering and clicking) when I start it. However, as soon as I incorporate it into my code, the clicking does not work anymore (but the buttons are displayed). If I then use a DefaultTableModel instead of my custom one, rendering and clicking works again. Does anyone know how to deal with this issue? Or does anyone have a good pointer to a resource for including buttons into tables? Or does anyone have a pointer to a resource that explains how CellRenderer and CellEditor work and which methods have to be overwritten in order to trigger certain actions (like a button click)?
    thanks

    Yes, you were right, the TableModel was causing the trouble, everything else worked fine. Somehow I had this code (probably copy and pasted from a tutorial - damn copy and pasting) in my TableModel:
            public boolean isCellEditable(int row, int col) {
                //Note that the data/cell address is constant,
                //no matter where the cell appears onscreen.
                if (col < 3) {
                    return false;
                } else {
                    return true;
    }A pretty stupid thing when you want to edit the 3rd column...

  • Custom table model, table sorter, and cell renderer to use hidden columns

    Hello,
    I'm having a hard time figuring out the best way to go about this. I currently have a JTable with an custom table model to make the cells immutable. Furthermore, I have a "hidden" column in the table model so that I can access the items selected from a database by their recid, and then another hidden column that keeps track of the appropriate color for a custom cell renderer.
    Subject -- Sender -- Date hidden rec id color
    Hello Pete Jan 15, 2003 2900 blue
    Basically, when a row is selected, it grabs the record id from the hidden column. This essentially allows me to have a data[][] object independent of the one that is used to display the JTable. Instinctively, this does not seem right, but I don't know how else to do it. I know that the DefaultTableModel uses a Vector even when it's constructed with an array and I've read elsewhere that it's not a good idea to do what I'm trying to do.
    The other complication is that I have a table sorter as well. So, when it sorts the objects in the table, I have it recreate the data array and then set the data array of the ImmutableTableModel when it has rearranged all of the items in the array.
    On top of this, I have a custom cell renderer as well. This checks yet another hidden field and displays the row accordingly. So, not only does the table sort need to inform the table model of a change in the data structure, but also the cell renderer.
    Is there a better way to keep the data in sync between all of these?

    To the OP, having hidden columns is just fine, I do that all the time.. Nothing says you have to display ALL the info you have..
    Now, the column appears to be sorting properly
    whenever a new row is added. However, when I attempt
    to remove the selected row, it now removes a seemingly
    random row and I am left with an unselectable blank
    line in my JTable.I have a class that uses an int[] to index the data.. The table model displays rows in order of the index, not the actual order of the data (in my case a Vector of Object[]'s).. Saves a lotta work when sorting..
    If you're using a similar indexing scheme: If you're deleting a row, you have to delete the data in the vector at the INDEX table.getSelectedRow(), not the actual data contained at
    vector.elementAt(table.getSelectedRow()). This would account for a seemingly 'random' row getting deleted, instead of the row you intend.
    Because the row is unselectable, it sounds like you have a null in your model where you should have a row of data.. When you do
    vector.removeElementAt(int), the Vector class packs itself. An array does not. If you have an array, when you delete the row you must make sure you dont have that gap.. Make a new array of
    (old array length-1), populate it, and give it back to your model.. Using Vectors makes this automatic.
    Also, you must make sure your model knows the data changed:
    model.fireTableDataChanged(); otherwise it has no idea anything happened..
    IDK if that's how you're doing it, but it sounds remarkably similar to what I went thru when I put all this together..

  • Error while binding the model with the custom controller

    Hi All,
    I first started with a dummy project and in that binded the model with the custom controller.
    For some reason, I deleted the project and created a new one. I have deleted the whole project from the workspace.
    Now, when I am trying to bind the model  again , I am getting an error when selecting the response parameters saying that DUPICATE ENTRIES.Ideally it should not happen when I am deleting it completely.
    I am using a Webservice Model. Can any one help me out to resolve the same.
    Looking forward for your response.
    Regards
    Dipendra

    Hi Raman,
    I did that and even I have Installed the IDE again.
    Still I have that error.
    Regards
    Dipendra

  • HT2463 Since I installed my new d6300 netgear my downloads on Apple TV have taken a lot longer than previously using a billion router.  Do I need to do something with the net gear set up?

    Since I installed my new d6300 netgear my downloads on Apple TV have taken a lot longer than previously using a billion router.  Do I need to do something with the net gear set up?

    Just connect the new iPod to your computer and setup the iPod via iTunes (instead of via wifi).
    If you want to copy all the infor from an old iPod touch to the inew iPod see:
    iOS: Transferring information from your current iPhone, iPad, or iPod touch to a new device

  • I lost the ability to order and hide site columns if i use custom content type with a custom Create Form

    I have a team site collection and I want to add a new App of type Issue Tracking list. so I did the following:-
    From the site collection I created a new App of type issue tracking.
    Then from the site collection I created a new Content type named “CustomIssue” which has its parent as “Issue” content type.
    I went to the Issue tracking list and I changed the default content type from Issue , to the new “CustomeIssue” content type.
    I open the site collection using SP designer and I created a new Create form for my Issue tracking list based on the "CustomIssue" content type and I select to have the Create form as the default form when creating an item.
    Everything till this point worked well. But when I open the “customIssue” content type , and I re-order the columns and I hide some columns, this was not reflected inside the custom Create form …
    although when using the default content type and the default create form you can control the order of the fields and to specify if certain fields hold be hidden inside the Create form.. so can anyone advice on this please?

    Hi,
    According to your post, my understanding is that you lost the ability to order and hide site columns if i use custom content type with a custom Create Form.
    I try to reproduce the issue, the result is the same as yours.
    As a workaround, if I modify the custom content type form the site setting, and then change the NewForm as the default form, it will change the column orders.
    However, if I use the new created form as the default form, it will remain the original orders.
    I recommend that you modify the custom content type form the site setting, and then reset the NewForm as the default form.
    The result is as below:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support
    ok thanks for the explanation ,, but what if i want to change the order and hidde some fields in the future ,, do i have to chnage the defualt create form again ...

  • How to use a menu model with a dynamic region and a task flow parameter

    I am using JDeveloper/ADF 11.1.2.1
    I have a menu model that changes which task flow is displayed in a given dynamic region using a backing bean. That works fine. I would like to be able to pass parameters to that task flow based on which menu item is clicked. For example: i have a task flow which shows a page where input fields are used to filter a table. Depending on the value of the task flow parameter I want to change which input fields are displayed. So i will have multiple menu items which refer to the same task flow but have a different set of parameters. I have tried using request scope variables and setting them in the backing bean for the dynamic region which works until the query is submitted at which point the request scope has changed and the value is no longer available. I have tried a number of other 'creative' approaches but have not gotten anything to work. Anyone done this before? Or have an idea on how to solve it?

    Frank,
    I did a fair bit of digging based on your suggestions and some things I found in your Oracle Fusion Developer's Guide book and I came up with something that works really well. It is fairly elegant but requires code. It would be nice if something like a setPropertyListener could be rolled into the menu model. That would make my solution completely declarative.
    Here is my solution:
    My task flow requires a the value #{pageFlowScope.type} to be set. My application has a dynamic region that is changed on the fly using a menu model. The region uses a backing bean (mainRegionManagerBean) which is in the viewScope to manage what taskflow is shown in the region. There are multiple menu items in the menu model that point to the same task flow but pass different values to the #{pageFlowScope.type} parameter. So i wired the menu items up to different methods in the mainRegionManagerBean which set the value for me. See the relevant code below.
    I would be very interested in the feedback from someone with more experience than I on my solution. Maybe there is a more elegant way...
    In the backing bean there is a primary method that was created by generating a dynamic region link which sets the task flow id and then other methods which call it and set the relevant parameters. (JSFUtils is a helper class i wrote to centralize some common tasks):
    public String shipmentTraceMasterTaskflow()
    taskFlowId = "/WEB-INF/taskflow/master/shipmentTraceMasterTaskflow.xml#shipmentTraceMasterTaskflow";
    JSFUtils.setValue("pageFlowScope.type", "");
    return null;
    public String shipmentTraceProNumber()
    shipmentTraceMasterTaskflow();
    JSFUtils.setValue("pageFlowScope.type", "pronumber");
    return null;
    public String shipmentTraceBOLNumber()
    shipmentTraceMasterTaskflow();
    JSFUtils.setValue("pageFlowScope.type", "bolnumber");
    return null;
    In the menu model (notice that these reference the different methods from above):
    <itemNode id="itemNode_ProNumberTrace" label="ProNumber Trace" action="#{viewScope.mainRegionManagerBean.shipmentTraceProNumber}" focusViewId=""/>
    <itemNode id="itemNode_BOLNumberTrace" label="BOL Number Trace" action="#{viewScope.mainRegionManagerBean.shipmentTraceBOLNumber}" focusViewId=""/>
    On the page:
    <af:region value="#{bindings.dynamicRegion1.regionModel}" id="r1"/>
    In the pagedef:
    <taskFlow id="dynamicRegion1" taskFlowId="${viewScope.mainRegionManagerBean.dynamicTaskFlowId}" activation="deferred" xmlns="http://xmlns.oracle.com/adf/controller/binding" Refresh="ifNeeded">
    <parameters>
    <parameter id="type" value="#{pageFlowScope.type}"/>
    </parameters>
    </taskFlow>
    Edited by: Adam Stortz on Nov 22, 2011 11:10 AM

  • JTable: Custom Table Model (pII)

    As was explained in pI, I'm creating a custom table model to overcome a few pitfalls I came across using the DefaultTableModel class, such as aligning cells, and getting certain columns to return only numeric type data. However, I've come upon a few roadblocks myself.
    How do I create each of the following methods:
    insertRow(int ow, int column)
    remove row(int row)
    addRow(Object[] rowData)Assuming that I decide to allow the user to add a column to the table, how would I create the methodaddColumn(Object columnName, Object[] columnData)And also, as I'm creating a custom table model, would I need to replicate DefaultTableModel's methods that inform the listeners that a change has been made to the table?
    Thanks!

    Thanks!
    I just got this response. Anyways, I found another solution that was, interestingly, from one of your threads written in 2005.
    This is what I did:
    // Letting the JTable know what each column stores and should return by
       // overloading the getColumnClass() method
       public Class getColumnClass(int column)
            if(recordsTable.getColumnName(column) == "Ranking")
              return Integer.class;
         /* Why do I keep ketting an IllegalArgumentException here? *
           * It keeps saying it cannot format given object as a Number */            
            else if(recordsTable.getColumnName(column) == "Price (�) ")
              return Float.class;
         else
           return getValueAt(0, column).getClass();         
       }However, another problem has arisen.
    The if method for the int column (Ranking column) works okay, and is even right-aligned. The else if arguments for the Price (�) column however is returning an IllegalArgumentException. This I just cannot figure out.
    Here's the code:package Practice;
      import java.awt.BorderLayout;
      import java.awt.Frame;
      import java.awt.Menu;
      import java.awt.MenuBar;
      import java.awt.MenuItem;
      import java.awt.MenuShortcut;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import java.awt.event.KeyEvent; // for MenuItem shortcuts
      import java.awt.event.WindowAdapter;
      import java.awt.event.WindowEvent;
      import java.awt.event.WindowListener;
      import javax.swing.JOptionPane;
      import javax.swing.JScrollPane; // JTable added to it, aiding flexibility
      import javax.swing.JTable; // The personally preferred GUI for this purpose
            // Provides a basic implementation of TableModel
      import javax.swing.table.DefaultTableModel;
              // This class uses Vector to store the rows and columns of data, though
              // programmer will be using LinkedLists
      import java.util.LinkedList;
      // User-defined classes
      import Practice.MusicDatabase;
      public class MusicBank extends Frame implements ActionListener
         MusicDatabase mDBase;
         Frame frame;
         String title = "",      // Frame's title
                file = "";           // pathname of the file to be opened
          // Declaring Menu and MenuItem variables
         Menu recordM; // ...
         // recordM
         MenuItem newRecordR_MI, deleteRecordR_MI;
         // Other irrelevant menus and sub items
        DefaultTableModel recordDetails;
        JTable recordsTable;
        LinkedList musicList;
        public MusicBank()
            musicList = new LinkedList();
            frame = new Frame(title);
            frame.setMenuBar(menuSystem());
            // Should user seek to close window externally
            frame.addWindowListener(new WindowAdapter()
                 public void windowClosing(WindowEvent we)
                     frame.dispose();
                     System.exit(0);
         recordDetails = new DefaultTableModel();
         // Creating the relevant columns
         recordDetails.addColumn("Title");
         recordDetails.addColumn("Identity");
         recordDetails.addColumn("Music Company");
         recordDetails.addColumn("Ranking");
         recordDetails.addColumn("Price (�) ");
         // Ensuring the table has at least one visible record (empty)
         recordDetails.addRow(populateRow("", "", "", 0, 0.00f));
         // Creating the table to display the data files (music record details)
         recordsTable = new JTable(recordDetails)
             // Letting the JTable know what each column stores and should return by
             // overloading the getColumnClass() method
            public Class getColumnClass(int column)
               if(recordsTable.getColumnName(column) == "Ranking")
                   return Integer.class;
                /* Why do I keep ketting an IllegalArgumentException here? *
                 * It keeps saying it cannot format given object as a Number */            
                else if(recordsTable.getColumnName(column) == "Price (�) ")
                    return Float.class;
                else
                    return getValueAt(0, column).getClass();         
      // Creating the menus
      public MenuBar menuSystem()
          MenuBar bar = new MenuBar();
          // Record menu and related items
          recordM = new Menu("Record");
          recordM.setShortcut(new MenuShortcut(KeyEvent.VK_R, false));        
          newRecordR_MI = new MenuItem("New record");
          newRecordR_MI.setShortcut(new MenuShortcut(KeyEvent.VK_N, false));
          deleteRecordR_MI = new MenuItem("Delete record");
          deleteRecordR_MI.setShortcut(new MenuShortcut(KeyEvent.VK_D, false));
           recordM.add(newRecordR_MI);
           recordM.addSeparator();
           recordM.add(deleteRecordR_MI);
            // Enabling menus with functionality
           newRecordR_MI.addActionListener(this);
           deleteRecordR_MI.addActionListener(this);
           // Adding menus and items to menu bar
           bar.add(recordM);
           return bar;        
      public void actionPerformed(ActionEvent ae)
          if(ae.getSource() == newRecordR_MI)
             newRecord();
          else if(ae.getSource() == deleteRecordR_MI)
             deleteRecord();       
      // Object that will be used, in conjunction with MusicDatabase's, to 
      // populate the JTable
      // A record in a JTable is equivalent to an element in a LinkedList
      public Object[] populateRow(String title, String name, String comp, int rank, float price)
          // First, update the LinkedList
          mDBase = new MusicDatabase(title, name, comp, rank, price);
          musicList.add(mDBase);
           // Then, update the table
           // As the parameters of Object tableDetails can only take a String or
           // object, rank and price will have to be cast as a String and later
           // parsed to their original form before use.
           String rankPT = ""+rank, pricePT = ""+price;        
           Object rowDetails[] = {title, name, comp, rankPT, pricePT};
           return rowDetails;
      public static void main(String args[])
          MusicBank app = new MusicBank();
           // Using the platform's L&F (if Win32,  Windows L&F; Mac OS, Mac OS L&F,
           // Sun, CDE/Motif L&F)
           // For more on this, refer to the WinHelp Java tutorial by F. Allimont
           try
               UIManager.getSystemLookAndFeelClassName();
           catch(Exception e)
               JOptionPane.showMessageDialog(app,
                    "Failed to create the Windows Look and Feel for this program",
                    "Look and Feel (L&F) error",
                    JOptionPane.ERROR_MESSAGE);
           app.frame.setSize(500, 500);
           app.frame.setVisible(true);
            // Placing frame in the centre of the screen on-loading
           app.frame.setLocationRelativeTo(null);
      // action methods per menu items
      // Also, why do I keep getting an ArrayIndexOutOfBoundsException
      // here? I do know what this exception is, and how it works, but just cannot
      // understand what is causing it
      public void newRecord()
          // Before adding a new record, check if previous record has complete
          // entries. If not, either display a message (JOptionPane) or disallow
          // request (simply do nothing)        
          // Proceed based on assesment
          if(queryState() == true)
              // Inform user that all entries need to be filled in before a new
              // record can be created
              JOptionPane.showMessageDialog(this, // current frame
                       "There are incomplete cells in the table."+
                       "\nPlease fill these in before proceeding",       // Message to user
                       "Incomplete entries",                                // Title
                       JOptionPane.ERROR_MESSAGE);                           // Relevant icon
          else
               // To ensure that both the linked list & the table are simultaneously
               // updated, JOptionPane's input dialogs are used to temporarily store
               // the data which is then inputted into both (linked list and JTable)
              String titleN, identityN, companyN; int rankN; float priceN;
              titleN = JOptionPane.showInputDialog(this, "Enter song title");
              identityN = JOptionPane.showInputDialog(this,                                      "Enter name of singer/band");
             companyN = JOptionPane.showInputDialog(this,                                 "Enter signed/unsigned company");
             rankN = Integer.parseInt( JOptionPane.showInputDialog(this,
                             "Enter rank (a number)") );
            System.out.println("\n JTable rows = "+recordDetails.getRowCount());
             // Ensuring that the chosen rank is not already entered
             /* Problem lies here */
             for(int row = 1; row <= recordDetails.getRowCount(); ++row)
                 if((recordDetails.getValueAt(row, 4)).equals(""+rankN))
                     rankN = Integer.parseInt( JOptionPane.showInputDialog(this,
                             "That number's already chosen.\nPlease enter a rank ") );
             priceN = Float.parseFloat( JOptionPane.showInputDialog(this,                                 "Finally, enter price �") );
             mDBase = new MusicDatabase(titleN, identityN, companyN, rankN, priceN);
             musicList.add(mDBase);
             recordDetails.addRow(populateRow(titleN, identityN, companyN, rankN,
         priceN));
             System.out.println("JTable rows after creation = "+
                   recordDetails.getRowCount());
         // Enabling the delete record menu item (as necessary)
         if((recordsTable.getRowCount()) > 0)
              deleteRecordR_MI.setEnabled(true);
      } // newRecord()
      public void deleteRecord()
         int selectedRow = recordsTable.getSelectedRow();
         recordDetails.removeRow(selectedRow);
          // Removing the element from the LinkedList's corresponding index
          musicList.remove(selectedRow);
          System.out.println("Existing rows = "+recordsTable.getRowCount());
           // If there are no more rows, disallow user from trying to delete rows
           if(selectedRow <= 0)
              deleteRecordR_MI.setEnabled(false);
      } // deleteRecord()
      // Method to query if all cells have changed their states (empty or not)
      public boolean queryState()
          // Obtaining number of rows
          int rows = recordDetails.getRowCount();
          int columns = recordDetails.getColumnCount();
          boolean isEmpty = false; // cell
          System.out.println("Rows = "+rows);
          System.out.println("Columns = "+columns);
          try{
              // Assessing all cells for complete entries
              // This approach is flexible, rather than hardcoding the rows available,
              // making it more reusable (assuming it will always be 5 columns)
              for (int rowIndex = 0; rowIndex<=rows; ++rowIndex)
                  if((recordDetails.getValueAt(rowIndex, 1)).equals(""))
                 isEmpty = true;
                  else if((recordDetails.getValueAt(rowIndex, 2)).equals(""))
               isEmpty = true;
                  else if((recordDetails.getValueAt(rowIndex, 3)).equals(""))
               isEmpty = true;                
                  else if((recordDetails.getValueAt(rowIndex, 4)).equals("0"))
               isEmpty = true;
                  else if((recordDetails.getValueAt(rowIndex, 5)).equals("0.00"))
               isEmpty = true;
          catch(Exception e)
             System.out.println(e.getMessage());
          return isEmpty;
      Now here is the code for the MusicDatabase class
    package Practice;
    class MusicDatabase
        private String songTitle, identity, musicCompany;
        private int rank;
        private float priceF;
        // Defining the constructor
        public MusicDatabase(String title, String name, String company,                                int rankingInt, float price)
           songTitle = title;
           identity = name;
           musicCompany = company;
           rank = rankingInt;
           priceF = price;
        } // constructor
       // Other methods
    } // class MusicDatabaseSorry, but am not sure if these codes are executable, as where I am (a general library), JVM is not on the machine I am using. (Remember, i don't have ready acess to the Internet, so I could not use my machine, nor the facilities that had the JVM - unavailable to me at the time).
    Thanks!
    Reformer...
    PS I do hope the code pasted was not too much. Kind regards....

  • How to create a custom function module with the records in SAP R/3?

    Hi All,
    How to create a custom function module with the records in SAP R/3? Using RFC Adapter I have to fetch the custom function module records.
    Regards
    Sara

    Hi
    goto se37...here u need to create a function group... then u need to create a function module. inside assign import/export parameters. assign tables/exceptions. activate the same. now write ur code within the function module
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm
    Look at the below SAP HELP links, These links will show you the way to create a Function Module
    http://help.sap.com/saphelp_nw04/helpdata/en/26/64f623fa8911d386e70000e82011b8/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/9f/db98fc35c111d1829f0000e829fbfe/content.htm

  • Unable to get the SharePoint 2013 List names using Client object model for the input URL

    Please can you help with this issue.
    We are not able to get the SharePoint 2013 List names using Client object model for the input URL.
    What we need is to use default credentials to authenticate user to get only those list which he has access to.
    clientContext.Credentials = Net.CredentialCache.DefaultCredentials
    But in this case we are getting error saying ‘The remote server returned an error: (401) Unauthorized.’
    Instead of passing Default Credentials, if we pass the User credentials using:
    clientContext.Credentials = New Net.NetworkCredential("Administrator", "password", "contoso")
    It authenticates the user and works fine. Since we are developing a web part, it would not be possible to pass the user credentials. Also, the sample source code works perfectly fine on the SharePoint 2010 environment. We need to get the same functionality
    working for SharePoint 2013.
    We are also facing the same issue while authenticating PSI(Project Server Interface) Web services for Project Server 2013.
    Can you please let us know how we can overcome the above issue? Please let us know if you need any further information from our end on the same.
    Sample code is here: http://www.projectsolution.com/Data/Support/MS/SharePointTestApplication.zip
    Regards, PJ Mistry (Email: [email protected] | Web: http://www.projectsolution.co.uk | Blog: EPMGuy.com)

    Hi Mistry,
    I sure that CSOM will authenticate without passing the
    "clientContext.Credentials = Net.CredentialCache.DefaultCredentials" by default. It will take the current login user credentials by default. For more details about the CSOM operations refer the below link.
    http://msdn.microsoft.com/en-us/library/office/fp179912.aspx
    -- Vadivelu B Life with SharePoint

  • Using custom tables in jdeveloper

    Hi,
    I've created a custom table using toad. I created the table in applsys and created a synonym to apps. I've also grant all the priveledges to apps as well. However, when I create a query OA to query a standard table eg. PER_ALL_PEOPLE_F, I have no problems however, using the same OA to query my custom table, I get the JBO-25017 Cannot create row for entity error.
    Is someone able to help??

    Why it was required to chnage your EO to abstract class?. May be your custom table doesn;t have the standard WHO columns (created_by, Creation_date etc..), and the EO doesn't compile with out a attribute setter/getter methods for these columns.
    this may be the reason why you changed the class to abstract. But, EO class should not be abstract. Work around is to have empty functions for these standard columns.
    HTH
    Srini

Maybe you are looking for

  • Stream video to my Apple TV from my iPhone 6?

    how can I stream a video from my iPhone 6 to my Apple TV.?

  • Videowall, data wall, multi display controller

    Hi all just wanted to review this item as i have a question.. I purchased the iVw4 Standalone Videowall controller from www.iiview.com i have manage to output my adobe graphical work on four screens each at 19" as this unit can display in various mod

  • LIS reports in BI

    Hi, Are there any LIS reports in the PP/MM/WM area which can be developed and run in BI ? My client wants to start expanding the use of BI. Is it even possible to move LIS reports to BI and if yes which ones would be moved first ? Thanks GS

  • Help- During the syncing proccess, it stops/freezes

    Help- During the syncing process, it stops/freezes on step 5: Waiting for changes to be applied, and nothing happens. This problem just started after the newest system update. Any suggestions on how to get this to work?

  • HTML Snippet and Kryogenix SortTable

    Kryogenix has a great piece of Javascript code that will sort tables on screen by clicking the column heading. You can see it here. http://kryogenix.org/code/browser/sorttable/ Does anyone know how to actually use that JavaScript code in iWeb using t