JTable addColumn into original position

Hi,
I have wriiten a generic dialog box to allow a user to select the visible columns in a JTable.
Basically a TableColumnModel is passed to the routine to dynamically create a grid of JCheckBox's using the info from getHeaderValue().
I create a list of TableColumn's that are in the TableColumnModel so that I can add a removed column back in again.
My problem is that I cannot add the columns into the required locations.
In the code below:
tcm = TableColumnModel
tc = TableColumn
col = original position of table column
public void setColumnStatus(int col, boolean status)
if (col > -1 && col <= columnNames.length)
int index = col > tcm.getColumnCount() ? tcm.getColumnCount() : col ;
if (status)
tcm.addColumn(tc[col]);
System.err.println("New Column Index :" + tcm.getColumnIndex(tc[col].getIdentifier()));
System.err.println("Original Column Index :" + col);
tcm.moveColumn(tcm.getColumnIndex(tc[col].getIdentifier()), index);
else
tcm.removeColumn(tc[col]);
If I have approached this in the wrong way, I would appreciate some pointers in the right direction.
Things would be so much easier if they would have implemented an isVisible for TableColumnModel.
Regards
Chris

I can't think of a reference that would be appropriate since I made the solution up during a few quiet minutes.
I suppose the closest analogy I can imagine at the moment is that of a SortableTableModel (stay with me for this). The sortable table model wraps a table model and reorders its rows without changing the underlying model. This has proven quite effective in the past and is quite easy to use. You're right, though, the concept can be quite confusing.
Think of the table model being transformed by the sortable table model like this:
ORIGINAL TABLE MODEL     SORTABLE TABLE MODEL
1. goodbye               3. adios
2. see ya                1. goodbye
3. adios                 2. see ya
4. ta ta                 4. ta taAll the sortable table model does is maintain a mapping from its row numbers to the wrapped model's row numbers (ie, row 1 is actually row 3)
I'll post the complete code at the end so that you can have a good look at it.
What I'm suggesting is that something similar can be done for the table column model but rather than "reordering" them we actually add/remove them. But not actually add/remove them, just wrap them in something that makes them appear to be added/removed.
If you'd like me to go further into this then I'd be happy to give it a go.
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;
import javax.swing.event.TableModelListener;
import javax.swing.event.TableModelEvent;
import java.util.Comparator;
import java.util.ArrayList;
import java.util.TreeSet;
import java.util.Iterator;
import java.util.HashMap;
* Wrapper for a table model that provides the ability to sort the rows by the values in a particular column.
* @author Kevin Seal
public class SortableTableModel extends AbstractTableModel implements TableModelListener
     protected TableModel tableModel;
     protected int[] sortableColumns;
     protected HashMap comparatorMap;
     private int sortColumn;
     private boolean sortAscending;
     private Comparator comparator;
     private int[] fromModelRow;
     private int[] toModelRow;
     private class ComparableValue implements Comparable
          private Object value;
          private int row;
          private ComparableValue(Object value, int row)
               this.value = value;
               this.row = row;
          private int getRow()
               return row;
          private Object getValue()
               return value;
          public int compareTo(Object obj)
               ComparableValue c = (ComparableValue)obj;
               int i;
               if(comparator == null)
                    if(value == null)
                    i = (c.getValue() == null)?0:-1;
                    else
                         i = ((Comparable)value).compareTo(c.getValue());
               else
                    i = comparator.compare(value, c.getValue());
               if(i == 0)
                    i = c.getRow() - row;
               return sortAscending?i:-i;
     public SortableTableModel(TableModel tableModel, int[] sortableColumns)
          super();
          this.tableModel = tableModel;
             this.sortableColumns = new int[sortableColumns.length];
          System.arraycopy(sortableColumns, 0, this.sortableColumns, 0, sortableColumns.length);
          comparatorMap = new HashMap();
          sortColumn = -1;
          // If the underlying data changes - we wanna know about it!!
          tableModel.addTableModelListener(this);
     public void setComparator(int column, Comparator comparator)
          if(!isColumnSortable(column))
               throw new IllegalArgumentException("Cannot set the Comparator for a column that isn't sortable");
          comparatorMap.put(new Integer(column), comparator);
     public int getRowCount()
          return tableModel.getRowCount();
     public int getColumnCount()
          return tableModel.getColumnCount();
     public boolean isColumnSortable(int column)
          for(int idx = 0; idx < sortableColumns.length; idx++)
               if(sortableColumns[idx] == column)
                    return true;
          return false;
     public void setSorting(int sortColumn, boolean sortAscending)
          if(!isColumnSortable(sortColumn))
               throw new IllegalArgumentException("Cannot sort by unsortable column: " + sortColumn);
          this.sortColumn = sortColumn;
          this.sortAscending = sortAscending;
          comparator = (Comparator)comparatorMap.get(new Integer(sortColumn));
          calculateSorting();
          fireTableDataChanged();
     public void clearSorting()
          sortColumn = -1;
          calculateSorting();
          fireTableDataChanged();
     public int getSortColumn()
          return sortColumn;
     public boolean isSortAscending()
          return sortAscending;
     protected void calculateSorting()
          if(sortColumn < 0)
               toModelRow = null;
               fromModelRow = null;
               return;
          ArrayList columnValues = new ArrayList(tableModel.getRowCount());
          for(int row = 0; row < tableModel.getRowCount(); row++)
               columnValues.add(new ComparableValue(tableModel.getValueAt(row, sortColumn), row));
          TreeSet sortedSet = new TreeSet(columnValues);
          toModelRow = new int[sortedSet.size()];
          fromModelRow = new int[sortedSet.size()];
          int idx = 0;
          int row;
          for(Iterator i = sortedSet.iterator(); i.hasNext(); )
               row = ((ComparableValue)i.next()).getRow();
               toModelRow[idx] = row;
               fromModelRow[row] = idx;
               idx++;
     public int convertToModelRow(int row)
          if((toModelRow == null) || (row >= toModelRow.length))
               return row;
          return toModelRow[row];
     public int convertFromModelRow(int row)
          if((fromModelRow == null) || (row >= fromModelRow.length))
               return row;
          return fromModelRow[row];
     public Object getValueAt(int row, int column)
          return tableModel.getValueAt(convertToModelRow(row), column);
     public void setValueAt(Object value, int row, int column)
          tableModel.setValueAt(value, convertToModelRow(row), column);
     public String getColumnName(int column)
          return tableModel.getColumnName(column);
     public Class getColumnClass(int column)
          return tableModel.getColumnClass(column);
     public boolean isCellEditable(int row, int column)
          return tableModel.isCellEditable(convertToModelRow(row), column);
     public void tableChanged(TableModelEvent e)
          calculateSorting();
          // Since this class is essentially a proxy for the table model we propogate the change of data to
          // all of our registered listeners
          // For now we tell them that all data has changed
          // (the mapping between changes in the underlying model and the sorted view should be implemented later)
          fireTableDataChanged();
}

Similar Messages

  • Cut/paste text in a new TextFrame, and place it on the text original position

    With this script, the pagraphs with style "_DESTACADOS" are cut and paste in a new TextFrame, but place them in to first page. I need place it on the text original position...
    var myDocument = app.activeDocument;
    var myRegExp = ".+";
    app.findGrepPreferences = NothingEnum.nothing;
    app.changeGrepPreferences = NothingEnum.nothing;
    app.findGrepPreferences.appliedParagraphStyle = "_DESTACADOS";
    app.findGrepPreferences.findWhat = myRegExp;
    var myFoundItems = myDocument.findGrep(true);
    if(myFoundItems.length != 0){
          for(var myCounter = 0; myCounter < myFoundItems.length; myCounter ++){
              myFoundItem = myFoundItems[myCounter];
              myX1 = myFoundItem.characters.item(0).horizontalOffset;
              myY1 = myFoundItem.characters.item(0).baseline;
              myX2 = myX1 + 50;
              myY2 = myY1 + 50;
                app.selection = myFoundItem;
                    app.cut();
                myTextFrame = myDocument.textFrames.add();
                myTextFrame.geometricBounds = [myY1, myX1, myY2, myX2];
                app.selection = myTextFrame.insertionPoints[0];
                    app.paste(); // Pega el texto del caso encontrado
                myTextFrame.applyObjectStyle(app.activeDocument.objectStyles.item("_Destacados"), true);           
                myTextFrame.fit(FitOptions.FRAME_TO_CONTENT);
    THANKS...

    Hi Marcos Suárez,
                 If you've xml for the indesign document, u can use the following.
    myElement.placeIntoInlineFrame(["8p","6p1"]);
    I hope this code is useful in ur script.
    #include "glue code.jsx"
    var doc = app.activeDocument;
    var myRuleSet = new Array ( new idd)
              with(doc)
                        var elements = xmlElements;
                        __processRuleSet(elements.item(0), myRuleSet)
    function idd()
        var newstyle=doc.objectStyles.add("ObjectStyle1");
        newstyle.appliedParagraphStyle="Ap3";
        newstyle.strokeColor="None";
        newstyle.fillColor="None";
              this.name = "idd"
              this.xpath = "//title/p2"                    //set this xpath value to the xmltree element which u want to set into frame.
              this.apply = function(myElement, myRuleProcessor)
            var txt=myElement.placeIntoInlineFrame(["8p","6p1"]);
            txt.fit(FitOptions.frameToContent);
            txt.applyObjectStyle(newstyle, true);
      return true;
    This will create a textframe around the selected content which u want to do so...
    For more info, refer XMLElement.placeIntoInlineFrame() in Object Model Viewer....
    With Regards,
    Vel.

  • Loading JPEGs into set position on stage

    Hi All,
    I have made a flash movie as seen at
    http://www.coffeemamma.com.au
    and would
    like to change the following:
    I'd like to generate three random numbers from 1 to 5
    inclusive but I want
    to ensure that each number is different - e.g. 2, 4, 1 (not
    2, 4, 2). I know
    how to generate ONE random number, but I'm stuck on comparing
    them to see
    whether they are the same (and if they are, then generate new
    numbers until
    they are unique).
    With the three numbers I would like to load images based on
    those numbers -
    e.g. '_image_2.jpg' then '_image_4.jpg' then '_image_1.jpg'.
    This part is
    fine IF I can generate the numbers.
    I'd also like to have the images come to the front when they
    are hovered
    over with the mouse and then to go 'back' to their original
    position when
    the mouse moves away. This I'm completely stuck on.
    I'd also like to be able to put the newly loaded images into
    certain
    positions (as per the example) rather than only loaded to
    (0,0) coordinates.
    I also want to be able to have the images masked as they come
    in (as per the
    example) in order to avoid white corners on the top images.
    I also have a page as per
    http://www.wasabi.org.au/wodonga.shtml
    which has
    some of the functions I want to use, but I can't seem to get
    some of the
    functions working in my new movie...
    Many thanks,
    Bruce

    var arr:Array = new Array();
    var nextX:Number=whatever;  // assign these 4 numbers
    var nextY:Number =whateverelse;
    var gapX:uint = xx;
    var gapY:uint =yy;
    for(var i:int = 0; i<4; i++){
        var life_mc:Life = new Life();
        arr.push(life_mc);
        stage.addChild(life_mc);
       life_mc.x = nextX;
      life_mc.y=nextY;
    nextX += gapX*(i%2);
    nextY += gapY*Math.floor(i/2);

  • Set origin (position) of vi in subpanel

    Hello,
    I have a problem I don't seem to find the solution for.
    I have two vi's. A first vi which has a subpanel, and a second vi which is displayed in the subpanel of the first vi.
    I don't have a problem displaying the second vi but I cannot seem to control the origin of the front panel of the second vi.
    If I try to set the FP.Origin property of the second vi I get the following error message
         "LabVIEW:  This property is read only while the VI is in a subpanel."
    Why do I need this behaviour?
    This is a big project with several developers working on it. The individual developers do not have alot of LV knowledge. They can only make changes to the vi's displayed inside the subpanels. It happens frequently that they change something inside the vi (second vi) and they forget to position the front panel back to position 0,0.
    When this subvi is then loaded into the subpanel of the main vi, the controls are shifted ... because the vi was not exactly saved in position 0,0.
    Preferably I would like to control the origin position when displaying this vi inside the subpanel. Is there a way how this can be accomplished?
    Thanks in advance for all the help!

    Set the origin before you load it into the subpanel?
    Ton
    Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
    Nederlandse LabVIEW user groep www.lvug.nl
    My LabVIEW Ideas
    LabVIEW, programming like it should be!

  • Keep Original Position Numbers in Purchase Order Creation

    Hi community, i'm trying to solve the following problem in purchase order creation using BAPI_PO_CREATE1:
    I'm loading a file with several order numbers and positions to be created in R/3. This file has a structure similar to:
    OrderNumber;PositionNumber;Material;Quantity;Unit;.......
    The purchase order is created successfully, but i need to keep original position numbers in the order. i.e:
    Supposing this input file:
    1900;08;993322;10.00;KG.....
    1900;13;994455;12.00;KG.....
    the positions in purchase order are created as
    00010
    00020
    But i need positions to be created as:
    00008
    00013
    Any ideas?????
    Thanks you for your cooperation
    Leonardo

    Hi Leonardo,
       I doubt if that is possible.
    You can have the configuration set up to set the Item Number Interval to  step size like 5,10,15 etc,
    based on this value, your line item number will be
    5,10,15,20...
    10,20,30,40..
    15,30,45,60
    etc.
    to set this value, you should go to SPRO.
    Material Management->Purchase Order->Define Document Types
    Regards,
    Ravi Kanth Talagana

  • How can I keep apps in the order I prefer?  I've rearranged via iTunes but every time I power cycle the phone, the apps go back to their original positions...

    How can I keep apps in the order I prefer?  I've rearranged via iTunes but every time I power cycle the phone, the apps go back to their original positions...

    Hi kelori617,
    If you are having issues organizing the Apps on your iPhone via iTunes, you may want to double-check the steps in the following article and make sure you are syncing any changes to your device:
    iTunes 11 for Mac: Sync and organize iOS apps
    http://support.apple.com/kb/PH12115
    iTunes 11 for Windows: Sync and organize iOS apps
    http://support.apple.com/kb/PH12315
    If all of the steps are correct and the changes still aren't being retained when you restart your iPhone, you may want to make sure your data is backed up, then try restoring your iPhone to factory settings, restore your data from the backup, then test to see if you can organize your apps via iTunes:
    Use iTunes to restore your iOS device to factory settings
    http://support.apple.com/kb/HT1414
    Regards,
    - Brenden

  • How to write the JTables Content into the CSV File.

    Hi Friends
    I managed to write the Database records into the CSV Files. Now i would like to add the JTables contend into the CSV Files.
    I just add the Code which Used to write the Database records into the CSV Files.
    void exportApi()throws Exception
              try
                   PrintWriter writing= new PrintWriter(new FileWriter("Report.csv"));
                   System.out.println("Connected");
                   stexport=conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
                   rsexport=stexport.executeQuery("Select * from IssuedBook ");
                   ResultSetMetaData md = rsexport.getMetaData();
                   int columns = md.getColumnCount();
                   String fieldNames[]={"No","Name","Author","Date","Id","Issued","Return"};
                   //write fields names
                   String rec = "";
                   for (int i=0; i < fieldNames.length; i++)
                        rec +='\"'+fieldNames[i]+'\"';
                        rec+=",";
                   if (rec.endsWith(",")) rec=rec.substring(0, (rec.length()-1));
                   writing.println(rec);
                   //write values from result set to file
                    rsexport.beforeFirst();
                   while(rsexport.next())
                        rec = "";
                         for (int i=1; i < (columns+1); i++)
                             try
                                    rec +="\""+rsexport.getString(i)+"\",";
                                    rec +="\""+rsexport.getInt(i)+"\",";
                             catch(SQLException sqle)
                                  // I would add this System.out.println("Exception in retrieval in for loop:\n"+sqle);
                         if (rec.endsWith(",")) rec=rec.substring(0,(rec.length()-1));
                        writing.println(rec);
                   writing.close();
         }With this Same code how to Write the JTable content into the CSV Files.
    Please tell me how to implement this.
    Thank you for your Service
    Jofin

    Hi Friends
    I just modified my code and tried according to your suggestion. But here it does not print the records inside CSV File. But when i use ResultSet it prints the Records inside the CSV. Now i want to Display only the JTable content.
    I am posting my code here. Please run this code and find the Report.csv file in your current Directory. and please help me to come out of this Problem.
    import javax.swing.*;
    import java.util.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.table.*;
    public class Exporting extends JDialog implements ActionListener
         private JRadioButton rby,rbn,rbr,rbnore,rbnorest;
         private ButtonGroup bg;
         private JPanel exportpanel;
         private JButton btnExpots;
         FileReader reading=null;
         FileWriter writing=null;
         JTable table;
         JScrollPane scroll;
         public Exporting()throws Exception
              setSize(550,450);
              setTitle("Export Results");
              this.setLocation(100,100);
              String Heading[]={"BOOK ID","NAME","AUTHOR","PRICE"};
              String records[][]={{"B0201","JAVA PROGRAMING","JAMES","1234.00"},
                               {"B0202","SERVLET PROGRAMING","GOSLIN","1425.00"},
                               {"B0203","PHP DEVELOPMENT","SUNITHA","123"},
                               {"B0204","PRIAM","SELVI","1354"},
                               {"B0205","JAVA PROGRAMING","JAMES","1234.00"},
                               {"B0206","SERVLET PROGRAMING","GOSLIN","1425.00"},
                               {"B0207","PHP DEVELOPMENT","SUNITHA","123"},
                               {"B0208","PRIAM","SELVI","1354"}};
              btnExpots= new JButton("Export");
              btnExpots.addActionListener(this);
              btnExpots.setBounds(140,200,60,25);
              table = new JTable();
              scroll=new JScrollPane(table);
              ((DefaultTableModel)table.getModel()).setDataVector(records,Heading);
              System.out.println(table.getModel());
              exportpanel= new JPanel();
              exportpanel.add(btnExpots,BorderLayout.SOUTH);
              exportpanel.add(scroll);
              getContentPane().add(exportpanel);
              setVisible(true);
          public void actionPerformed(ActionEvent ae)
              Object obj=ae.getSource();
              try {
              PrintWriter writing= new PrintWriter(new FileWriter("Report.csv"));
              if(obj==btnExpots)
                   for(int row=0;row<table.getRowCount();++row)
                             for(int col=0;col<table.getColumnCount();++col)
                                  Object ob=table.getValueAt(row,col);
                                  //exportApi(ob);
                                  System.out.println(ob);
                                  System.out.println("Connected");
                                  String fieldNames[]={"BOOK ID","NAME","AUTHOR","PRICE"};
                                  String rec = "";
                                  for (int i=0; i <fieldNames.length; i++)
                                       rec +='\"'+fieldNames[i]+'\"';
                                       rec+=",";
                                  if (rec.endsWith(",")) rec=rec.substring(0, (rec.length()-1));
                                  writing.println(rec);
                                  //write values from result set to file
                                   rec +="\""+ob+"\",";     
                                   if (rec.endsWith(",")) rec=rec.substring(0,(rec.length()-1));
                                   writing.println(rec);
                                   writing.close();
         catch(Exception ex)
              ex.printStackTrace();
         public static void main(String arg[]) throws Exception
              Exporting ex= new Exporting();
    }Could anyone Please modify my code and help me out.
    Thank you for your service
    Cheers
    Jofin

  • After editing a photo in another program, the photos return to the library at the end of the grid panel instead of at their original loacation.  How do I avoid this or alternatively, is there a quick way of moving them back to their original position inst

    After editing a photo in another program, the photos return to the library at the end of the grid panel instead of at their original loacation.  How do I avoid this or alternatively, is there a quick way of moving them back to their original position instead of clicking and dragging them?

    Sort your photos by File Name or Capture Date
    Use View->Sort

  • Return the cursor to original position in ABAP List

    There is an interactive List report, clicking on the lines in the main report leads to a secondary report and clicking on the line in secondary report gives a pop up screen. Depnding upon the selection made in pop up screen the data in the seconary report is changed and it again displays the secondary report with the changes but now the cursor is at the line 1 of the seconary report.
    I am unable to set the cursor to the original position in the seconary screen from where the pop up screen was called.
    I have tried to position the curosr using SET CURSOR but it does not help are there any other techniques for setting the curosr or what could have gone in my report which is not allowing me to position the curosr correctly.

    HI Mike
    Thanks for the reply. When I apply the logic to reposition the cursor in the scale range event only one cursor is moving to the zoomed in position. The other cursor remains out of  graph scale. I tried to repeat the same logc but it didn't work.  Could you please tell me how to get the 2nd cursor also in to the scale range. Sorry i'm fairly new to labview. I have attached the pic of what I tried.  Thankyou in advance
    Regards
    Pratheek
    Attachments:
    Capture.PNG ‏18 KB

  • Java.io.NotSerializableException when overwrite the JTable data into .txt file

    hi everyone
    this is my first time to get help from sun forums
    i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
    At the beginning, the code will be generate successfully and the jtable will be showing out with the data that been save in the studio1.txt previously,
    but after i edit the data at the JTable, and when i trying to click the save button, the error had been showing out and i cannot succeed to save the JTable with the latest data.
    After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
    I hope i can get any solution at here and this will be very useful for me.
    the following is my code...some of it i create it with the GUI netbean
    but i dunno how to attach my .txt file with this forum
    did anyone need the .txt file?
    this is the code that suspect maybe some error here
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String filename = "studio1.txt";
              try {
                  FileOutputStream fos = new FileOutputStream(new File(filename));
                  ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(jTable2);
                   oos.close();
              catch(IOException e) {
                   System.out.println("Problem creating table file: " + e);
                   return;
              System.out.println("JTable correctly saved to file " + filename);
    }the full code will be at the next msg

    this is the part 1 of the code
    this is the full code...i had /*....*/ some of it to make it easier for reading
    package gui;
    import javax.swing.*;
    import java.io.*;
    public class timetables extends javax.swing.JFrame {
        public timetables() {
            initComponents();
        @SuppressWarnings("unchecked")
        private void initComponents() {
            jDialog1 = new javax.swing.JDialog();
            buttonGroup1 = new javax.swing.ButtonGroup();
            buttonGroup2 = new javax.swing.ButtonGroup();
            buttonGroup3 = new javax.swing.ButtonGroup();
            buttonGroup4 = new javax.swing.ButtonGroup();
            jTextField1 = new javax.swing.JTextField();
            jLayeredPane1 = new javax.swing.JLayeredPane();
            jLabel6 = new javax.swing.JLabel();
            jTabbedPane1 = new javax.swing.JTabbedPane();
            jScrollPane3 = new javax.swing.JScrollPane();
            jTable2 = new javax.swing.JTable();
            jScrollPane4 = new javax.swing.JScrollPane();
            jTable3 = new javax.swing.JTable();
            jButton1 = new javax.swing.JButton();
            jButton2 = new javax.swing.JButton();
    /*       org.jdesktop.layout.GroupLayout jDialog1Layout = new org.jdesktop.layout.GroupLayout(jDialog1.getContentPane());
            jDialog1.getContentPane().setLayout(jDialog1Layout);
            jDialog1Layout.setHorizontalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 400, Short.MAX_VALUE)
            jDialog1Layout.setVerticalGroup(
                jDialog1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jLayeredPane1.add(jLabel6, javax.swing.JLayeredPane.DEFAULT_LAYER);
            String filename1 = "studio1.txt";
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable2 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   jTable3 = (JTable) ois.readObject();
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
            jTable2.setRowHeight(20);
            jTable3.setRowHeight(20);
            jScrollPane3.setViewportView(jTable2);
            jScrollPane4.setViewportView(jTable3);
            jTable2.getColumnModel().getColumn(4).setResizable(false);
            jTable3.getColumnModel().getColumn(4).setResizable(false);
            jTabbedPane1.addTab("STUDIO 1", jScrollPane3);
            jTabbedPane1.addTab("STUDIO 2", jScrollPane4);
            jTextField1.setText("again n again");
            jLabel6.setText("jLabel5");
            jLabel6.setBounds(0, 0, -1, -1);
            jButton2.setText("jButton2");
            jButton1.setText("jButton1");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
          

  • Java.io.NotSerializableException when overwrite the JTable data into .txt

    hi everyone
    i had java.io.NotSerializableException: java.lang.reflect.Constructor error when overwrite the JTable data into .txt file.
    At the beginning, the code will be generate successfully and the jtable
    will be showing out with the data that been save in the studio1.txt
    previously,
    but after i edit the data at the JTable, and when i trying to click the
    save button, the error had been showing out and i cannot succeed to
    save the JTable with the latest data.
    After this error, the code can't be run again and i had to copy the studio1.txt again to let the code run 1 more time.
    I hope i can get any solution at here and this will be very useful for me.
    but i dunno how to attach my .txt file with this forum
    did anyone need the .txt file?
    the following is my suspect code
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    String filename1 = "studio1.txt";
              try {
                  FileOutputStream fos = new FileOutputStream(new File(filename1));
                  ObjectOutputStream oos = new ObjectOutputStream(fos);
                   oos.writeObject(jTable2.getModel());
                   oos.flush();
                   oos.close();
                   fos.close();
              catch(IOException e) {
                   System.out.println("Problem creating table file: " + e);
                            e.printStackTrace();
                   return;
              System.out.println("JTable correctly saved to file " + filename1);
    }this is the reading code
    String filename1="studio1.txt";
            try {
                   ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filename1));
                   TableModel model = (TableModel)ois.readObject();
                    jTable3.setModel(model);
                   System.out.println("reading for " + filename1);
              catch(Exception e) {
                   System.out.println("Problem reading back table from file: " + filename1);
                   return;
              }Edited by: Taufulou on Jan 8, 2009 11:43 PM
    Edited by: Taufulou on Jan 8, 2009 11:44 PM
    Edited by: Taufulou on Jan 8, 2009 11:45 PM

    is this the code u mean?
    i had put this code inside it but the problem still remain the same
    if (jTable2.isEditing()) {
                jTable2.getCellEditor().stopCellEditing();
            }i had found a new thing that when i just double click the cell without change any data inside the table
    and click the button "Save". the same exception which is
    java.io.NotSerializableException: java.lang.reflect.Constructor
    will come out again.

  • Turn a single jtable cell into 2 swing component

    Hi, i'm trying to turn a jtable cell into two components, a jlabel and a jtextarea with the label on top of the textarea. Is that possible?
    I can write my own renderer and editor and turn a cell into a combobox or textarea. But is it possible to put two renderers in a single cell?
    thanks

    A JPanel IS-A Component so you could follow the procedure outlined in Sun's Tutorial and create a JPanel subclass that implements TableCellRenderer. For an editor the tutorial recommends subclassing AbstractCellEditor and implementing getTableCellEditorComponent() to return the panel containing your stuff.
    I haven't done this, but it seems worth a try. If you get stuck the best (most knowledgable, quickest) help is to be had from the [Swing forum|http://forum.java.sun.com/forum.jspa?forumID=57].
    Edited by: pbrockway2 on Jul 10, 2008 12:04 PM

  • I scanned a black & white negative. Can I turn it into a positive in PS?

    I scanned a black & white negative. Can I turn it into a positive in PhotoShop?

    Check System Preferences>Accessibility and make sure 'invert colours' isn't ticked under 'Display'.

  • In the viewer going to vertical scrolling bar I get a jump to original position...

    Scenario:
    In the viewer I'm working with the mouse vertical scrolling for searching some scenes, then I go to vertical the scrolling bar of the window to scroll in bigger steps... well, the viewer jumps to the previous position.. so I have to start my searching again.... and every time I go the vertical scrolling bar I get this jump to the original position... Very annoying....

    Do a malware check with some malware scanning programs.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br />
    <br />
    * http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    * http://www.superantispyware.com/ - SuperAntispyware
    * http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    * http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    * http://www.lavasoft.com/products/ad_aware_free.php - Ad-Aware Free
    See also:
    * "Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Edge Animate origin won't transform, keeps snapping back to original position.

    I am working with an Animate composition in Edge Animate CC on a mac.  When I try to transform the origin and select an item, select the transform tool and drag the origin it keeps snapping back to its original position.  I have tried turning off snaps and changing the origin in the properties panel but it snaps right back no matter how I try to change it.  It is as if it's locked in place.  Any ideas on why it won't change?  The items are not grouped and it is a problem will all of the individual elements that I have tried to change.  Thanks in advance for any advice.

    Thank you.  I have shut it down and restarted the Mac and still have the problem.  I am recreating the animation now in case the file was somehow corrupted.  Even with the new file, I am getting an error that Animate encountered a problem and that I should save and restart Animate.  I think I will uninstall and try reinstalling Animate.  Do I have anything to lose by trying that since it looks like I need to recreate anyway?  Thanks again for your help!

Maybe you are looking for