Jtable's tablecell editing problem

there are some jcomponets in a jframe(jtable, jtextfield, jbutton, eg.), i edit in a tablecell in the jtable first, then i click another tablecell , when the first tablecell's value i just edited has committed; but when i click on jtextfield (another jcomponent different from jtable ) instead of another tablecell , the editted value in the first tablecell isn't commited.
how can i do if i want to commit the value in the first tablecell when i click on a jtextfield?

i have found the answer ,
table.putClientProperty("terminateEditOnFocusLost", Boolean.TRUE);

Similar Messages

  • Pls Help :JTable Double Value Editing Problem

    hi friends
    as i am new to swings and Jtable pls help me if u can.
    in the code copied below when i start putting value into the Double column of JTable
    a ( .0 ) is appended at the end which is undesirable it should be like that only when the value is
    something like 22.99 and also i want to limit the double value's fractional part to be limited to 2 digits only.
    if this can be done in my Table model itself so that it will work everywhere i use this model
    Pls tell me what exactly do i need, a custom Cell Editor or Cell Renderer. and whether can i do it in the
    Table Model Defination class or whether i can only do it on the Jtable only.
    guys its so confusing.pls help
    if anyone can send a sample code for achieving this it would be of great help
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.table.*;
    import java.text.*;
    public class TableProcessing extends JFrame implements TableModelListener
        JTable table;
        public TableProcessing()
            String[] columnNames = {"Item", "Quantity", "Price", "Cost"};
            Object[][] data =
                {"Bread", new Integer(1), new Double(1.11), new Double(1.11)},
                {"Milk", new Integer(1), new Double(2.22), new Double(2.22)},
                {"Tea", new Integer(1), new Double(3.33), new Double(3.33)},
                {"Cofee", new Integer(1), new Double(4.44), new Double(4.44)}
            DefaultTableModel model = new DefaultTableModel(data, columnNames);
            model.addTableModelListener( this );
            table = new JTable( model )
                //  Returning the Class of each column will allow different
                //  renderers to be used based on Class
                public Class getColumnClass(int column)
                    return getValueAt(0, column).getClass();
                //  The Cost is not editable
                public boolean isCellEditable(int row, int column)
                    if (column == 3)
                        return false;
                    else
                        return true;
            table.setPreferredScrollableViewportSize(table.getPreferredSize());
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
         *  The cost is recalculated whenever the quantity or price is changed
        public void tableChanged(TableModelEvent e)
            if (e.getType() == TableModelEvent.UPDATE)
                int row = e.getFirstRow();
                int column = e.getColumn();
                if (column == 1 || column == 2)
                    int    quantity = ((Integer)table.getValueAt(row, 1)).intValue();
                    double price = ((Double)table.getValueAt(row, 2)).doubleValue();
                    Double value = new Double(quantity * price);
                    table.setValueAt(value, row, 3);
        public static void main(String[] args)
            TableProcessing frame = new TableProcessing();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }thank in advance
    jags

    No.
    But further to this try:
    public class MyCustomRenderer  extends javax.swing.table.DefaultTableCellRenderer
              private java.text.DecimalFormat FORMAT_DOUBLE;
              public MyCustomRenderer()
                      FORMAT_DOUBLE = new java.text.DecimalFormat("#, ##0.00");
              public java.awt.Component getTableCellRendererComponent(javax.swing.JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
                        //NB! you could also set foreground/background here to indicate positive/negative values...
                        if(value.getClass().equals(Double.class))//is this a double?
                                double d = ((Double)value).doubleValue();
                                d = (Double.isNaN(d)||Double.isInfinity(d))?0:d;
                                this.setText(FORMAT_DOUBLE.format(d));
                        else//not a double so let's toString() it...
                               this.setText(""+value);
    }then, using code pasted above, specify a new instance of this class as the default renderer in your
    table.....
    :)

  • Need help serializing an AbstractTableModel for a JTable with cell editing.

    Fun times are ahead. Here we go!
    I have a JTable that contains data I'd like to serialize out to a file to be restored and viewed later.
    So I tried saving the AbstractTableModel subclass out to a file. Whenever I do this, I get the following error message:
    java.io.NotSerializableException: javax.swing.JTable$CellEditorRemover
    Now I know for fact that serializing an AbstractTableModel that was installed in a JTable without cell editing works just fine (my old code did exactly that). As a result, I think that the code that handles events in the AbstractTableModel contains references back out to the JTable, which causes the JTable to be saved no matter what (even though I'm just interested in saving the TableModel only). It causes a bigger file than normal, but file size is not an issue. The only issue I have is that CellEditorRemover (an undocumented inner class of JTable), which is automatically installed for JTables with editable cells, is not serializable.
    This leads to the following questions:
    1. Is there a way to avoid serialization/deserialization of the CellEditorRemover inner class of JTable?
    2. Is there a way to save an AbstractTableModel without saving all of the event listeners associated with it?
    I think an answer to either of these questions would go a long way towards solving my problem. Otherwise, I'll resign myself to weeping silently in the corner of my office.
    Thanks!

    I would suggest that if you can you only save the
    data... but i would do this by using the
    externalizable interface.
    What you will need to do is have the
    writeExternal(ObjectOutputStream out) and
    readExternal(ObjectOutputStream out) methods in your
    class. These will be responsiable for saving the
    data.
    Here's an example of what you can do in these
    methods... this is just a little tidbit from a program
    i've written.public void writeExternal(ObjectOutput out) throws
    IOException {
              out.writeInt(size);
              out.writeObject(drawName);
              out.writeInt(playersLength);
    for(int i = 0; i < playersLength; i++)
    ) out.writeObject(players);
              out.writeInt(seedsLength);
    for(int i = 0; i < seedsLength; i++)
    ) out.writeObject(seeds[i]);
              out.writeInt(drawLength);
    for(int i = 0; i < drawLength; i++)
    ) out.writeObject(draw[i]);
    public void readExternal(ObjectInput in) throws
    IOException, ClassNotFoundException {
              size = in.readInt();
              drawName = (String)in.readObject();
              playersLength = in.readInt();
    for(int i = 0; i < playersLength; i++) players[i] =
    = (String)in.readObject();
              seedsLength = in.readInt();
    for(int i = 0; i < seedsLength; i++) seeds[i] =
    = (String)in.readObject();
              drawLength = in.readInt();
    for(int i = 0; i < drawLength; i++) draw[i] =
    = (String)in.readObject();
    You can now use your class as you would a Serializable
    class, but it will only save the data
    Hope this helped
    webaf409java
    I forgot to add some critical information in my original post. My apologies. :(
    I've thought about using Externalizable, but am hesitant to use it because the application would no longer be able to read in files using the old save format (ie, AbstractTableModels for JTables without CellEditorRemovers ).  I want to preserve the ability to read the old saved AbstractTableModel formats if possible. 
    Do you know of a way to revert to the default deserialization mechanism from readExternal?  This way, during deserialization, I could do a quick test on the object being read and have the ability to default to the regular deserialization mechanism if the object is of the old type or continue with the new Externalizable stuff if the object is one of the new type.  Maintaining file compatibility is key.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • FocusLost event for JTable during cell editing

    When a cell in a JTable is getting edited, how can I get notified of the focusLost event? I added the focus listener using JTable.addFocusListener, but the focusLost of the listener is not called when a cell inside the table is getting edited (it works fine otherwise). I am aware of the client property terminateEditOnFocusLost to solve this problem in 1.4 but I can't use it since I am still on 1.3.1_04.
    Suggestions welcome.

    http://forum.java.sun.com/thread.jsp?forum=57&thread=431440

  • Font / text edit problem in photoshop CS6

    Hi there,
    I have a strange text edit problem in Photoshop CS6 running on Mavericks.
    Every time I use the text-tool in PS, write a sentence, mark it and change something like color, font size etc., the marked text vanishes.
    I have to "undo" the last step and the changed text appears again.
    Every time!
    I have a clean installed CS6 with no plugins and no other than system fonts installed.
    Everything on a new Mac Pro with OS X 10.9.5
    Any clues? Thanks.

    Do you have the latest updates for photoshop cs6?
    You can use Help>Updates from within photoshop cs6 to check if there are any available.
    Also, if you go to Help>System Info from within photoshop cs6, you can see the Photoshop Version in the top line.
    You should be on version 13.0.6
    See if turning off Dictation solves the issue.
    Go to System Preferences ---> Dictation and Speech -----> select OFF radio button .

  • Launch and edit problem from Dreamweaver to Fireworks

    > This message is in MIME format. Since your mail reader
    does not understand
    this format, some or all of this message may not be legible.
    --B_3266405159_588474
    Content-type: text/plain;
    charset="ISO-8859-1"
    Content-transfer-encoding: 8bit
    Hi
    Not sure if this is a Fireworks or Dreamweaver problem but
    here goes.
    I¹ve created a graphic in Fireworks CS3 on the Mac and
    Exported the HTML and
    related images. I open the HTML file in Dreamweaver CS3, all
    fine so far.
    Then I highlight the table and click the ŒEdit in
    Fireworks¹ button and it
    throws up a warning dialogue saying ŒCannot launch and
    edit. The Fireworks
    table could not be found in the HTML. Please export from
    Fireworks and
    re-import the HTML into Dreamweaver.¹
    What?!!
    I¹ve only just exported it from Fireworks! It¹s
    even got the Fireworks table
    code in the Code section, so what¹s going here?
    Has anyone else had this?
    Gaz
    --B_3266405159_588474
    Content-type: text/html;
    charset="ISO-8859-1"
    Content-transfer-encoding: quoted-printable
    <HTML>
    <HEAD>
    <TITLE>Launch and edit problem from Dreamweaver to
    Fireworks</TITLE>
    </HEAD>
    <BODY>
    <FONT FACE=3D"Verdana, Helvetica, Arial"><SPAN
    STYLE=3D'font-size:12.0px'>Hi<BR=
    >
    Not sure if this is a Fireworks or Dreamweaver problem but
    here goes.<BR>
    I&#8217;ve created a graphic in Fireworks CS3 on the Mac
    and Exported the H=
    TML and related images. I open the HTML file in Dreamweaver
    CS3, all fine so=
    far. Then I highlight the table and click the
    &#8216;Edit in Fireworks&#821=
    7; button and it throws up a warning dialogue saying
    &#8216;Cannot launch an=
    d edit. The Fireworks table could not be found in the HTML.
    Please export fr=
    om Fireworks and re-import the HTML into
    Dreamweaver.&#8217;<BR>
    What?!!<BR>
    I&#8217;ve only just exported it from Fireworks!
    It&#8217;s even got the Fi=
    reworks table code in the Code section, so what&#8217;s
    going here?<BR>
    <BR>
    Has anyone else had this?<BR>
    <BR>
    Gaz</SPAN></FONT>
    </BODY>
    </HTML>
    --B_3266405159_588474--

    > This message is in MIME format. Since your mail reader
    does not understand
    this format, some or all of this message may not be legible.
    --B_3266407908_747577
    Content-type: text/plain;
    charset="ISO-8859-1"
    Content-transfer-encoding: 8bit
    When you export the sliced graphics from Fireworks it places
    them into a
    table. In my instance the code says...
    <!-- fwtable fwsrc="Brands.png" fwpage="Page 1"
    fwbase="Brands.jpg"
    fwstyle="Dreamweaver" fwdocid = "325827661" fwnested="0"
    -->
    So it recognises Fireworks was the the graphics app and jumps
    back to it
    when you want to edit the image. Fireworks then displays (or
    should) a
    ŒDone¹ button over the window. You do your alts and
    press Done to update the
    HTML and graphics back in Dreamweaver automatically.
    That¹s the only table I was referring to Murray.
    On 4/7/07 3:02 pm, in article
    [email protected], "Murray
    *ACE*" <[email protected]> wrote:
    > Why would you be wanting to edit the table in a graphics
    editor, instead of
    > an HTML editor?
    --B_3266407908_747577
    Content-type: text/html;
    charset="ISO-8859-1"
    Content-transfer-encoding: quoted-printable
    <HTML>
    <HEAD>
    <TITLE>Re: Launch and edit problem from Dreamweaver to
    Fireworks</TITLE>
    </HEAD>
    <BODY>
    <FONT FACE=3D"Verdana, Helvetica, Arial"><SPAN
    STYLE=3D'font-size:12.0px'>When =
    you export the sliced graphics from Fireworks it places them
    into a table. I=
    n my instance the code says...<BR>
    <BR>
    &lt;!-- fwtable fwsrc=3D&quot;Brands.png&quot;
    fwpage=3D&quot;Page 1&quot; fwba=
    se=3D&quot;Brands.jpg&quot;
    fwstyle=3D&quot;Dreamweaver&quot; fwdocid =3D &quot;32=
    5827661&quot; fwnested=3D&quot;0&quot;
    --&gt;<BR>
    <BR>
    So it recognises Fireworks was the the graphics app and jumps
    back to it wh=
    en you want to edit the image. Fireworks then displays (or
    should) a &#8216;=
    Done&#8217; button over the window. You do your alts and
    press Done to updat=
    e the HTML and graphics back in Dreamweaver
    automatically.<BR>
    That&#8217;s the only table I was referring to
    Murray.<BR>
    <BR>
    On 4/7/07 3:02 pm, in article
    [email protected], &quot;Murr=
    ay *ACE*&quot;
    &lt;[email protected]&gt; wrote:<BR>
    <BR>
    <FONT COLOR=3D"#0000FF">&gt; Why would you be
    wanting to edit the table in a =
    graphics editor, instead of <BR>
    &gt; an HTML editor?<BR>
    </FONT></SPAN></FONT>
    </BODY>
    </HTML>
    --B_3266407908_747577--

  • Premiere Pro 7.1 serious Multicam Editing problems

    Hello, I am posting here because the bug report I filed one week ago to Adobe didn't give a result -no response at all from the bug department.
    I have two serious Multicam Editing Problems.
    PC Configuration: Core i7950, Asus P6TD Deluxe, 12GB DDR3 1600MHZ, Quadro K4000, SSD for the system, Seagate Constellation 7200rpm for video editing.
    1. When multicam mode is on at the program monitor, I press play and the program doesn't respond at all. The timeline plays till the end and the program just doesn't let you do anything but wait until playback of the whole timeline is over. Then the program works again (no "not responding" message in Windows).
    2. Sometimes the waveform doesn't even appear at the multicam audio clip. I read in other forums that this problem is found specifically at Premiere Pro version 7.1 (October release).
    I would be grateful with your help.
    Thank you,
    Stavros Symeonidis

    The media is always a combination of HD .MOV (dSLR footage and .MTS (from my Sony Vg-30). However, I also tested it with .mpeg files created by "match sequence settings". GPU acceleration is always on, as I use nVidia Quadro K4000 with the latest drivers (331.82).
    I always create the multicam sequences manually and the problem occurs with any amount of camera angles.
    The problem was not solved by reinstaling Windows (7 and 8). In general, I have no other issue with my PC system, except from this specific one.
    It doesn't appear always, however it will definitely happen if you press twice or three times the letter L, to fast forward the preview of your Multicam Sequence.
    I remind you that this only happens when multicam monitor is toggled at the program monitor.
    Did all these help at all to even reproduce this situation?
    Thank you,
    Stavros Symeonidis

  • FC studio2 editing problems with western digital my book home for mac

    hi--bought a 1TB WD my book home for mac coupla years ago because it seemed like a good deal for so much space, and provided and eSATA hookup, too. Worked ok for a while. Now, with a growing Motion project that I bring into FC for overall color/levels/export adjustments, I'm getting a long-term beachball every time I try to do anything with it. Just did a complete reinstall of FC studio (after running Techtool pro 5 rebuild and optimizing files and volume), trashed the project and recreated it incase the file itself was corrupted, but the beachball keeps showing up once i try to get past a particular edit and play the file through -- something I haven't had problems with before. Have read this harddrive is a real POS/PIA for many because of its internal "sleep" setting and other weaknesses, and am thinking of cracking the drive out of its case and putting it into a plain eSATA/FireWire enclosure. Anybody else tried this or heard of it working? Money's a big issue right now (too many slow/no pay clients), so can't just run out and get a new drive and transfer w/out trying cheaper route first. Would appreciate feedback, cuz this is makin' me lose what little hair i got left!
    Message was edited by: jayvee56
    Message was edited by: jayvee56

    My question says: "Final Cut Studio 2 editing problems"; I formatted the drive for the mac when i bought it: journaled HFS+, Apple Partition Map; 2 partitions (and connected via eSATA); which has been working fine as is up till now. The sequence and settings are those in which I've worked on many projects for years with no problems up until now. I am also completely up-to-date with all my app and system updates. I did begin to wonder after posting if the reinstall might be the source of my problems, but it was the interminable beachball waits that prompted the reinstall in the first place.

  • JTable question (last edit before close problem)

    Hello all,
    I have a simple looking problem. It's a JTable inside a dialog, but I can't get exactly the behaviour I want, that is, when the user edits a cell and, without pressing enter or selecting another cell, clicks "OK" (and the dialog hides) the editing should end and the value that was entered to get to the model.
    If I show the dialog again, the editing of the cell is still there, and the value is not updated (neither of course shown with a cell renderer)
    How could I finish programmatically the editing of a cell, and the result be the same as the user pressed enter or so?
    Very very much thank u

    It seems I posted this too early, sorry!
    I found an answer in
    http://forum.java.sun.com/thread.jsp?forum=57&thread=204066

  • JTable  Edit Problem

    Hi All
    I dont want user to Edit the JTable..
    How to do this ?
    Thx in Advance
    Vipin

    you need to provide a readonly TableModel (isCellEditable has to return false)
    Check this:
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html#data
    Torsten

  • Set JTable to non editable

    Hello,
    I have a one column JTable that I would like not to be editable. How do I set the table not be editable? I am not using a table model. Would that be a problem?
    I am using the folllwing code:
    Vector rows =  new Vector(0);        //create a vector for the rows 
        //add a vector within a vector       
        for(int i = 0; i < 10; i++)       
            //create a new vector and add the values to the vector           
            Vector oneRow = new Vector(0);   
            //fill one row           
            oneRow.add("Row Input"));   
            //add the new vector to the outer vector           
            rows.add(oneRow);       
        }   //add the header to the byte column      
        Vector cols = new Vector(0);       
        cols.add("Values");       
        //create a JTable with one col and rows the size of the byte array       
        JTable myTable = new JTable(rows, cols);

    look at DefaultTableModel it has a isCellEditable(int rowl, int col)
    method which you can override for your own needs.

  • JTable focus w/ editable headers

    I have three JTables which act as a core, a row header, and a column header, like a spreadsheet. All tables have mutiple columns/row, and all of the cells are editable. I want one cell among all three tables to be selected/editable at one time. I have tried two separate approches.
    1. on focusLost, clear the selection and stopCellEditing.
    2. on focusGained, clear the selections and stopCellEditing in all the other tables.
    The focusLost solution fails because when you are editing a cell and click outside of the table, the focus doesn't get lost.
    The focusGained solution fails because when stopCellEditing is called, that cell regains focus. Now the very cell which I didn't want to have focus has it again.
    I've been working on this for much too long (was up 'til 5am) and am completely stalled. Any ideas?

    Well I've tried something similar to that, but the "cleanup" is where things really mess up. Say every time I get a focusGain event, I store the table it happened in. The next I get one, just check to see if they're the same value and if not unset the others right? Well unfortunately it doesn't work.
    Say I'm editing (with cursor, ie the value hasn't been saved) in table 2. Now I click on table 1. Table 1 tells the other tables to clearSelection() and stopCellEditing() (to save the value which hadn't been). However, as soon as table 2 gets the call to stopCellEditing, it takes back the focus. Like this
    1. Double click table 2; editing
    2. Single click table 1
    3. Table 1 gets focusGained, tells other tables to clear
    4. Table 2 calls stopCellEditing on itself
    Then, because of the stopCellEditing,
    5. Table 1 gets focusLost
    6. Table 2 gets focusGained
    ... but we should be in table 1!!
    If JTable didn't have a bug, then after step 2 table 2 should get a focusLost event, but it doesn't. The more I think about this problem the more I get stuck. Any brainstorming is appreciated!

  • Making JTable rows not editable

    i need to make a jtables rows and columns to not be editable, but i also need it to be able to be selectable. i know one way to do it is to extend defaulttablemodel and overwrite the iscelleditable method, but the problem is that i'm already extending jframe. is there any other way to do this keeping jframe extended, because i need it to be extended?
    thanks for the help

    JTable table = new JTable(..){
      public boolean isCellEditable(int row, int column){
        return false;
    };

  • MDI JTable Overlap Area Repaint Problem

    Hi all,
    I have a problem for my application in MDI mode.
    I open many windows (JInternalFrame contain JTable) under JDesktopPane. Some of the windows are overlapping and when they receive update in the table, it seems repaint all of the overlapping windows, not only itself. This make my application performance become poor, slow respond for drap & drop an existing window or open a new window.
    To prove this, i make a simple example for open many simple table and have a thread to update the table's value for every 200 mill second. After i open about 20 windows, the performance become poor again.
    If anyone face the same problem with me and any suggestions to solve the problem ?
    Please help !!!!!
    Following are my sources:
    public class TestMDI extends JFrame {
        private static final long serialVersionUID = 1L;
        private JPanel contentPanel;
        private JDesktopPane desktopPane;
        private JMenuBar menuBar;
        private List<TestPanel> allScreens = new ArrayList<TestPanel>();
        private List<JDialog> freeFloatDialogs = new ArrayList<JDialog>();
        private List<JInternalFrame> mdiInternalFrm = new ArrayList<JInternalFrame>();
        int x = 0;
        int y = 0;
        int index = 0;
        private static int MDI_MODE = 0;
        private static int FREE_FLOAT_MODE = 1;
        private int windowMode = MDI_MODE;
        public TestMDI() {
            init();
        public static void main(String[] args) {
            new TestMDI().show();
        public void init() {
            contentPanel = new JPanel();
            desktopPane = new JDesktopPane();
            desktopPane.setDragMode(JDesktopPane.LIVE_DRAG_MODE);
            desktopPane.setFocusTraversalKeysEnabled(false);
            desktopPane.setFocusTraversalPolicyProvider(false);
            desktopPane.setBorder(null);
            desktopPane.setIgnoreRepaint(true);
            desktopPane.setPreferredSize(new Dimension(1000, 800));
            this.setSize(new Dimension(1000, 800));
            menuBar = new JMenuBar();
            JMenu menu1 = new JMenu("Test");
            JMenuItem menuItem1 = new JMenuItem("Open Lable Screen");
            menuItem1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    for (int i = 1; i < 4; i++) {
                        final TestJLableScreen screen = new TestJLableScreen("Screen  " + (allScreens.size() + 1));
                        screen.startTime();
                        if (windowMode == MDI_MODE) {
                            JInternalFrame frame = createInternalFram(screen);
                            desktopPane.add(frame);
                            mdiInternalFrm.add(frame);
                            if (allScreens.size() * 60 + 100 < 1000) {
                                x = allScreens.size() * 60;
                                y = 60;
                            } else {
                                x = 60 * index;
                                y = 120;
                                index++;
                            frame.setLocation(x, y);
                            frame.setVisible(true);
                        } else {
                            JDialog dialog = createJDialog(screen);
                            freeFloatDialogs.add(dialog);
                            if (i * 60 + 100 < 1000) {
                                x = i * 60;
                                y = 60;
                            } else {
                                x = 60 * index;
                                y = 120;
                                index++;
                            dialog.setLocation(x, y);
                            dialog.setVisible(true);
                        allScreens.add(screen);
            JMenuItem menuItem2 = new JMenuItem("Open Table Screen");
            menuItem2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    for (int i = 1; i < 4; i++) {
                        TestTableScreen screen = new TestTableScreen("Screen  " + (allScreens.size() + 1));
                        screen.startTime();
                        if (windowMode == MDI_MODE) {
                            JInternalFrame frame = createInternalFram(screen);
                            desktopPane.add(frame);
                            mdiInternalFrm.add(frame);
                            if (allScreens.size() * 60 + 100 < 1000) {
                                x = allScreens.size() * 60;
                                y = 60;
                            } else {
                                x = 60 * index;
                                y = 120;
                                index++;
                            frame.setLocation(x, y);
                            frame.setVisible(true);
                        } else {
                            JDialog dialog = createJDialog(screen);
                            freeFloatDialogs.add(dialog);
                            if (i * 60 + 100 < 1000) {
                                x = i * 60;
                                y = 60;
                            } else {
                                x = 60 * index;
                                y = 120;
                                index++;
                            dialog.setLocation(x, y);
                            dialog.setVisible(true);
                        allScreens.add(screen);
            menu1.add(menuItem1);
            menu1.add(menuItem2);
            this.setJMenuBar(menuBar);
            this.getJMenuBar().add(menu1);
            this.getJMenuBar().add(createSwitchMenu());
            this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            this.add(desktopPane);
            desktopPane.setDesktopManager(null);
        public JInternalFrame createInternalFram(final TestPanel panel) {
            final CustomeInternalFrame internalFrame = new CustomeInternalFrame(panel.getTitle(), true, true, true, true) {
                public void doDefaultCloseAction() {
                    super.doDefaultCloseAction();
                    allScreens.remove(panel);
            internalFrame.setPanel(panel);
            // internalFrame.setOpaque(false);
            internalFrame.setSize(new Dimension(1010, 445));
            internalFrame.add(panel);
            internalFrame.setFocusTraversalKeysEnabled(false);
            internalFrame.setFocusTraversalPolicyProvider(false);
            desktopPane.getDesktopManager();
            // internalFrame.setFocusTraversalKeysEnabled(false);
            internalFrame.setIgnoreRepaint(true);
            return internalFrame;
        public JDialog createJDialog(final TestPanel panel) {
            JDialog dialog = new JDialog(this, panel.getTitle());
            dialog.setSize(new Dimension(1010, 445));
            dialog.add(panel);
            dialog.addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    allScreens.remove(panel);
            return dialog;
        public JMenu createSwitchMenu() {
            JMenu menu = new JMenu("Test2");
            JMenuItem menuItem1 = new JMenuItem("Switch FreeFloat");
            menuItem1.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    windowMode = FREE_FLOAT_MODE;
                    for (JInternalFrame frm : mdiInternalFrm) {
                        frm.setVisible(false);
                        frm.dispose();
                        frm = null;
                    mdiInternalFrm.clear();
                    remove(desktopPane);
                    desktopPane.removeAll();
    //                revalidate();
                    repaint();
                    add(contentPanel);
                    index = 0;
                    for (JDialog dialog : freeFloatDialogs) {
                        dialog.setVisible(false);
                        dialog.dispose();
                        dialog = null;
                    freeFloatDialogs.clear();
                    for (int i = 0; i < allScreens.size(); i++) {
                        JDialog dialog = createJDialog(allScreens.get(i));
                        freeFloatDialogs.add(dialog);
                        if (i * 60 + 100 < 1000) {
                            x = i * 60;
                            y = 60;
                        } else {
                            x = 60 * index;
                            y = 120;
                            index++;
                        dialog.setLocation(x, y);
                        dialog.setVisible(true);
            JMenuItem menuItem2 = new JMenuItem("Switch MDI");
            menuItem2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    windowMode = MDI_MODE;
                    remove(contentPanel);
                    add(desktopPane);
                    for (int i = 0; i < freeFloatDialogs.size(); i++) {
                        freeFloatDialogs.get(i).setVisible(false);
                        freeFloatDialogs.get(i).dispose();
                    freeFloatDialogs.clear();
    //                revalidate();
                    repaint();
                    for (JInternalFrame frm : mdiInternalFrm) {
                        frm.setVisible(false);
                        frm.dispose();
                        frm = null;
                    mdiInternalFrm.clear();
                    index = 0;
                    for (int i = 0; i < allScreens.size(); i++) {
                        JInternalFrame frame = createInternalFram(allScreens.get(i));
                        desktopPane.add(frame);
                        mdiInternalFrm.add(frame);
                        if (i * 60 + 100 < 1000) {
                            x = i * 60;
                            y = 60;
                        } else {
                            x = 60 * index;
                            y = 120;
                            index++;
                        frame.setLocation(x, y);
                        frame.setVisible(true);
            menu.add(menuItem1);
            menu.add(menuItem2);
            return menu;
    public class TestTableScreen extends TestPanel {
        private static final long serialVersionUID = 1L;
        JTable testTable = new JTable();
        MyTableModel tableModel1 = new MyTableModel(1);
        private boolean notRepaint = false;
        int start = 0;
        JScrollPane scrollPane = new JScrollPane();
        private Timer timmer = new Timer(200, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Random indexRandom = new Random();
                final int index = indexRandom.nextInt(50);
                Random valRandom = new Random();
                final int val = valRandom.nextInt(600);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        notRepaint = false;
                        TestTableScreen.this.update(index + "|" + val);
        public TestTableScreen(String title) {
            this.title = title;
            init();
            tableModel1.setTabelName(title);
        public void startTime() {
            timmer.start();
        public String getTitle() {
            return title;
        public void update(String updateStr) {
            String[] val = updateStr.split("\\|");
            if (val.length == 2) {
                int index = Integer.valueOf(val[0]);
                List vals = tableModel1.getVector();
                if (vals.size() > index) {
                    vals.set(index, val[1]);
    //                 tableModel1.fireTableRowsUpdated(index, index);
                } else {
                    vals.add(val[1]);
    //                 tableModel1.fireTableRowsUpdated(vals.size() - 1, vals.size() - 1);
                tableModel1.fireTableDataChanged();
        public TableModel getTableModel() {
            return tableModel1;
        public void init() {
            testTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
            testTable.setRowSelectionAllowed(true);
            this.testTable.setModel(tableModel1);
            int[] width = { 160, 80, 45, 98, 60, 88, 87, 88, 80, 70, 88, 80, 75, 87, 87, 41, 88, 82, 75, 68, 69 };
            TableColumnModel columnModel = testTable.getColumnModel();
            for (int i = 0; i < width.length; i++) {
                columnModel.getColumn(i).setPreferredWidth(width[i]);
            testTable.setRowHeight(20);
            tableModel1.fireTableDataChanged();
            this.setLayout(new BorderLayout());
            TableColumnModel columnMode2 = testTable.getColumnModel();
            int[] width2 = { 200 };
            for (int i = 0; i < width2.length; i++) {
                columnMode2.getColumn(i).setPreferredWidth(width2[i]);
            scrollPane.getViewport().add(testTable);
            scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
            this.add(scrollPane, BorderLayout.CENTER);
        class MyTableModel extends DefaultTableModel {
            public List list = new ArrayList();
            String titles[] = new String[] { "袨怓1", "袨怓2", "袨怓3", "袨怓4", "袨怓5", "袨怓6", "袨怓7", "袨怓8", "袨怓9", "袨怓10", "袨怓11",
                    "袨怓12", "袨怓13", "袨怓14", "袨怓15", "袨怓16", "袨怓17", "袨怓18", "袨怓19", "袨怓20", "袨怓21" };
            String tabelName = "";
            int type_head = 0;
            int type_data = 1;
            int type = 1;
            public MyTableModel(int type) {
                super();
                this.type = type;
                for (int i = 0; i < 50; i++) {
                    list.add(i);
            public void setTabelName(String name) {
                this.tabelName = name;
            public int getRowCount() {
                if (list != null) {
                    return list.size();
                return 0;
            public List getVector() {
                return list;
            public int getColumnCount() {
                if (type == 0) {
                    return 1;
                } else {
                    return titles.length;
            public String getColumnName(int c) {
                if (type == 0) {
                    return "head";
                } else {
                    return titles[c];
            public boolean isCellEditable(int nRow, int nCol) {
                return false;
            public Object getValueAt(int r, int c) {
                if (list.size() == 0) {
                    return null;
                switch (c) {
                default:
                    if (type == 0) {
                        return r + " " + c + "  test ";
                    } else {
                        return list.get(r) + "   " + c;
        public boolean isNotRepaint() {
            return notRepaint;
        public void setNotRepaint(boolean notRepaint) {
            this.notRepaint = notRepaint;
    public class TestPanel extends JPanel {
        protected String title = "";
        protected boolean needRepaint = false;
        protected boolean isFirstOpen = true;
        public String getTitle() {
            return title;
        public void setNeedRepaint(boolean flag) {
            this.needRepaint = flag;
        public boolean isNeedRepaint() {
            return needRepaint;
        public boolean isFirstOpen() {
            return isFirstOpen;
        public void setFirstOpen(boolean isFirstOpen) {
            this.isFirstOpen = isFirstOpen;
    public class TestJLableScreen extends TestPanel {
        private static final long serialVersionUID = 1L;
        private JLabel[] allLables = new JLabel[20];
        private Timer timmer = new Timer(20, new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Random indexRandom = new Random();
                final int index = indexRandom.nextInt(10);
                Random valRandom = new Random();
                final int val = valRandom.nextInt(600);
                SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                        TestJLableScreen.this.setNeedRepaint(true);
                        TestJLableScreen.this.update(index + "|" + val);
        public TestJLableScreen(String title) {
            this.title = title;
            init();
        public void startTime() {
            timmer.start();
        public String getTitle() {
            return title;
        public void update(String updateStr) {
            String[] val = updateStr.split("\\|");
            if (val.length == 2) {
                int index = Integer.valueOf(val[0]);
                allLables[index * 2 + 1].setText(val[1]);
        public void init() {
            this.setLayout(new GridLayout(10, 2));
            boolean flag = true;
            for (int i = 0; i < allLables.length; i++) {
                allLables[i] = new JLabel() {
                    // public void setText(String text) {
                    // super.setText(text);
                    // // System.out.println("  setText " + getTitle() + "   ; " + this.getName());
                    public void paint(Graphics g) {
                        super.paint(g);
                        // System.out.println("  paint " + getTitle() + "   ; " + this.getName());
                    // public void repaint() {
                    // super.repaint();
                    // System.out.println("  repaint " + getTitle() + "   ; " + this.getName());
                allLables[i].setName("" + i);
                if (i % 2 == 0) {
                    allLables[i].setText("Name " + i + "  : ");
                } else {
                    allLables[i].setOpaque(true);
                    if (flag) {
                        allLables[i].setBackground(Color.YELLOW);
                        flag = false;
                    } else {
                        allLables[i].setBackground(Color.CYAN);
                        flag = true;
                    allLables[i].setText(i * 8 + "");
            for (int i = 0; i < allLables.length; i++) {
                this.add(allLables[i]);
    public class CustomeInternalFrame extends JInternalFrame {
        protected TestPanel panel;
        public CustomeInternalFrame() {
            this("", false, false, false, false);
        public CustomeInternalFrame(String title) {
            this(title, false, false, false, false);
        public CustomeInternalFrame(String title, boolean resizable) {
            this(title, resizable, false, false, false);
        public CustomeInternalFrame(String title, boolean resizable, boolean closable) {
            this(title, resizable, closable, false, false);
        public CustomeInternalFrame(String title, boolean resizable, boolean closable, boolean maximizable) {
            this(title, resizable, closable, maximizable, false);
        public CustomeInternalFrame(String title, boolean resizable, boolean closable, boolean maximizable,
                boolean iconifiable) {
            super(title, resizable, closable, maximizable, iconifiable);
        public TestPanel getPanel() {
            return panel;
        public void setPanel(TestPanel panel) {
            this.panel = panel;

    i had the same problem with buttons and it seemed that i overlayed my button with something else...
    so check that out first do you put something on that excact place???
    other problem i had was the VAJ one --> VisualAge for Java (terrible program)
    it does strange tricks even when you don't use the drawing tool...
    dunno 2 thoughts i had... check it out...
    SeJo

  • Editing problems with iTunes 64-bit in Vista

    Hello!
    Just bot a new computer with Win Vista 64-bit and had to install new iTunes 64-bit.
    It's somewhat slow when switching between Windows and iTunes.
    Also, what happened to the "quick" edit feature?
    As in.... highlight song, hit F2 or just click ONCE with left mouse button and you can EDIT the song title, artist, etc...
    It's NO longer available!
    What happened to it?
    I'm RE-importing my HUGE collection of playlists and backed up library and songs, which is all MESSED up and.... I have to spend TONS of time now EDITING the title info!!!
    Anyone have problems or any solutions to this "editing" snafu????
    Thank you!

    Responding to own post.... Found answer!
    Must set permissions!
    Highlight iTunes folder..
    Right click..
    Properties..
    Securities tab...
    Click on EVERY group/user names..
    Allow..
    Full control..
    OK!
    Saved!
    Darn Windows Vista!
    Screwing up the file/folder permissions due to the hated UAC feature!

Maybe you are looking for

  • Cgicmd.dat in formsweb.cfg?

    Hi, in my formsweb.cfg i have two alias that point to two different database. I have only one cgicmd.dat and don't want to change code of forms for invoking reports. I can put two different cgicmd.dat for pointing the two database ? Thanks. Best rega

  • How to override runtime parameters of Java programs in web browser windows?

    Hi Oracle forumers, There's a Java based program that is accessed through a web browser. The program somehow sets its own runtime parameters. However, those parameters don't always work well for running the program on every computer. Is there a way t

  • Resubmission Feature in B2B

    Please find the Resubmission Feature in B2B available in. http://rameshnittursblog.blogspot.com/2007/12/resubmission-feature-in-b2b.html Rgds,Ramesh

  • HT5622 How do I get iOS 5 loaded onto my iPad?

    I need help understanding how I get iOS 5 and load it onto my ipad

  • Why Ad Hoc certificate doesn't renew?

    If I click to renew Button, after the Pending state, I receive an Expired status on this Ad Hoc provisioning certificate. It seems that I can't produce and renew any Ad Hoc Certificate. Do you know why? Thanks nick