Update jtable from other window

Hi !
I have a jtable in window #1.
When choose row I opened window #2.
In window #2 I update sme details and want the
table in window #1 to update.
How can I do it ?
Thank you for your help

hi,
1. In Win2 make a 'linked' object-variable to Win1, like:
puplic javax.swing.JFrame Win2 extends JFrame{
   //* as type the class of your own win1! not a common window (javax.swing.JFrame)!
   private Win1 myWin1 = null;
   public Win2(Win1 parWin1){ window javax.swing.
      this.myWin1 = parWin1
}2. Make a public getter-methode for your JTable in Win1
puplic javax.swing.JFrame Win1 extends JFrame{
   private javax.swing.JTable myTable1 = null;
   public javax.swing.JTable getJTable(){
      return this.myTable1;
}3. call your win2 with the new constructor
   Win2 myWin2 = new Win2(this);
   myWin2.show();4. Now you can work in Win2 with your JTable with
   ... this.myWin1.getTable1.....cu
Oliver SCORP
ps: normally you don't have to update your JTable - you have to do this with the (Data) Model of your JTable

Similar Messages

  • Updating JTable From List

    hi all
    i am having trouble updating a jtable from a list.
    the table is declared as follows
    //TableTracks.java
    String[] columnNames = {"Track Number",
      "Mute",
      "File/Track Name",
      "Number of Loops",
    Object[][] data = {
    {"1", "0", "", "1" , },
    {"2", "0", "", "1" , },
    {"3", "0", "", "1" , },
    {"4", "0", "", "1" , },
    {"5", "0", "", "1" , },
    {"6", "0", "", "1" , },
    {"7", "0", "", "1" , },
    {"8", "0", "", "1" , },
         final JTable table = new JTable(data, columnNames);I would like to select a value in a List by using the arrow keys, then when pressing enter key the selected List value appears in a cell in the table.
    The list works fine for me, i get a Listvalue string from the following method
    //Part of FileList.java
    //tableTracks class constructor
    TableTracks tableTrack = new TableTracks();
    public void keyReleased(KeyEvent e) {
    switch(e.getKeyCode()) {
    case KeyEvent.VK_ENTER:
       value = jlst.getSelectedValue().toString();;
       if (value.endsWith(".wav"))
       iNameLen = value.length();
       value = value.substring(iEntryType,iNameLen);
       System.out.println("sending..... " + value);
       tableTrack.insertValue(value);
       break;
    }So far so good! in the above i call the insertValue method and below is that method
    //TableTracks.java
    void insertValue(String file)
      System.out.println("insertVal: " + file);
       table.setValueAt(file, 3, 3 );
    }in both of the system.out.println statements in the above 2 methods, the correct value is displayed. But it simply will not display the vlaue in the table.
    Before i added the List option to my program, i had it working by allowing the user to select a file name using a FileChooser. With this method, the table.setValue worked fine. But now, it will not.
    Any help or suggestions would be very greatly appreciated.
    cheers
    RC

    You probably defined the "table" variable twice. Once as a class variable and once as a local variable and your "insertValue" method is referring to the wrong variable and therefore updating the wrong table.

  • How to update jTable from user input?

    I create one jTable with 2 rows and 3 columns. the jtable colums contains deviceIP and Status. I am getting device IP from user input through jTextfield. so, when user enter IP and click add button, it must added in the jTable rows one by one.
    how can I add it by user enter the IP. Also, I want to update the status column value by "UP" or "DOWN" by just getting string value from other function.
    but, my problem is i need to update the correct IP status value to correct column (ie., I want to put IP 1(row 1) status to column 1 in status column list.
    I don't know about jTable .
    If any one have any examples please give me.

    use
    ((DefaultTableModel)jTable.getModel()).addRow(Object[]);
    Object[] is the array of row data values you want to insert;

  • Update Jtable from access database

    as the title suggests help me guys... till now i have a database and some contents in it.. when the application starts the table is filled with contents of the database.. now whenever i add or remove a row in the databse i want to show it in the table... i have a Vector called dbData with the present contents of the database.. i want to update jtable with contents of dbData.... how to do it??

    the best things i can see to do is
    JTable table = new Jtable(.....); // this was ur table before;
    deleteRow(table); // you deleted the row
    // now you have a vector containing all the data for the rows;
    // but you need a vector containing the columns for the rows too
    //so now you do
    table = new JTable(dbData,columnnames);
    repaint();dbData must be a vector of vectors;
    dbData.elementAt(1) return a vector with all the data for row one
    so dbData.elementAt(1).elementAt(1) will be the data for row 1 column 1
    // dbData will be the data still remaining in the table
    or instead of the above you could use a nested for loop and set each element one at a time
    Object temp;
    int numberofRows = dbData.elementCount();
    int numberofColumns = db.elementAt(0).elementCount();
    for(int row = 0; row < numberofColumns;row++)
    for( int column = 0; column < numberofRows; column++)
      temp = dbData.elementAt(row).elementAt(column);
      table.setValueAt(temp,row,column);
    }

  • Build 9879 - Need to restart Win 10 if remotely logged on from other windows machine

    Hi,
    Installed Win 10 32 bit Build 9879. I remotely logon to the Win 10 machine without any problem from my laptop. The problem comes when I try log in from Win 10 machine itself (i.e. which has Win 10 installed). No password screen... only black screen
    with a mouse.
    Work around is to do remote log on to Win 10 and restart the system.
    Is anyone faced similar problem ? How to resolve it ?
    Thanks,
    Mukul

    Hi Mukul,
    It sounds like you have a log on issue, right?
    Based on my understanding, when the Windows 10 9879 starts, you can remotely login from other PCs, but you have a native login issue.
    If I misunderstand your meaning, please feel free to let me know about it.
    If there is no password screen, I would suspect this is a corrupted installation. You can remotely launch the system recovery to perform a Refresh:
    Alex Zhao
    TechNet Community Support

  • Update JTable from String[][]

    Hello everyone, I have a JTable with a slightly customized DefaultTableModel shown below:
    DefaultTableModel tableModel = new DefaultTableModel(rowData, columnNames){
         private static final long serialVersionUID = 8655602888381735851L;
         @Override
             public boolean isCellEditable(int row, int column)
                         return false;
              };rowData is a String[][] of my data. When a user clicks a button, they add a row of data to the String[][]. I am wondering how I can update the JTable to reflect this change in the String[][]. Thanks!

    The problem with that is that I'm going to be performing various searches through the data, and those searches are performed on a TreeMap.
    rowData gets its data from the TreeMap, and is then displayedThe active verb does not describe the situation accurately: according to your code, rowdata is merely built from the TreeMap instance, and stuffed into a DefaultTableModel for display.
    When the user adds data, they add it to the TreeMap so that it can be searched.
    I can easily convert the data from the TreeMap to the String[][], but I don't know how to "redraw" the table with the new data.I assume the data is too big to repeat the process each time the user adds a row (build the new String[][], wrap it into a new DefaultTableModel instance and set the instance as the table's model).
    Another way is to duplicate the structure: when the user adds a row, add it into the searchable collection, and into the table model. But this costs twice the memory, and, again, I assume your data set is too large.
    A third, probably more elegant way is to build your own TableModel implementation: it could store a reference to the TreeMap instance, and an array converting the table's row index values to the tree's key value. That way the table model can be described in the active mode:
    "the JTable asks the model for cell values, and the model asks the tree for the corresponding data" :o)

  • Updating JTable from data from resultset

    I have an athletics database, where the user updates an event and round e.g. 100M run Round 1. I then have a query which returns the 3 fastest times from each round for whatever event.
    Now on my JTable gui, the user chooses what event and round to update through 2 JCombo boxes, one for events, one for rounds. Now if the user chooses the round name final, i need the JTable to update the table with the three fastest times from rounds 1, 2 and 3.
    Whats the best way to do this? I was thinking putting all the different result sets into an array, and then through an if loop have somthing like
    if(roundType.equals (final))then in the body of this loop, create an instance of my JTable setting the rows for each column the the resultset data.
    Is this the right approach or any other advise?
    cheers

    You probably defined the "table" variable twice. Once as a class variable and once as a local variable and your "insertValue" method is referring to the wrong variable and therefore updating the wrong table.

  • Update JTable from a JDialog

    I'm wanting to update a JTable I have on a JFrame. This JFrame has a button on it which opens a JDialog box which populates a database. The main JFrame's JTable (ReceivedTable) holds this information. When a user inputs some more information and closes the dialog, I'd like to update the JTable in the main JFrame, but am not sure how to go about doing this. Can someone give me an idea to work from.
    Thanks.

    G'day mate,
    Make an extension of JDialog like so:
    //import appropriate classes here
    public class MyDialog extends JDialog implements ActionListener {
         //you would have some text fields or such here
         public MyDialog(Frame parent, String name) {
              super(parent, name, true);
              JPanel cp = (JPanel)getContentPane();
              //cp.add(fields here!);
              JButton submit = new JButton("Submit");
              submit.addActionListener(this);
              cp.add(submit);
         public void actionPerformed(ActionEvent ae) {
              Vector data = new Vector();
              //populate 2d data vector with data for the table
              Vector column_names = new Vector();
              //names for your table columns
              ((DefaultTableModel)((JFrame)getOwner()).getTable().getModel()).setDataVector(data, column_names);
              dispose();
    Note: In your JFrame you will need to define a method getTable().
    I think that should work for you... Obviously you'll have to add in a lot of code yourself, but that should be a reasonable skeleton.
    Good luck,
    Muel.

  • Cannot see file and folders copied from other windows 8

    Hi everyone,
    The problem is the next:
    I have new PC for that i was asked to setup and install software, i perform on it clean windows 8 install, it have single HDD 1TB that was partitioned by regular windows setup option to system drive C: 100GB and all left space was partitioned as drive D:
    After setup finish i only boot to system to check that everything is OK and without to make ANY change to windows shut it down.
    I physically disconnect HDD from new PC and connect it via standard USB 3 docking device to my own PC that also run windows 8 i can see the new connected HDD with all partitions without any problem! Than i create on second partition on new drive folder and
    copy there some files, after copy finished i disconnect the drive in safe way by performing "eject" option in windows.
    i connect new drive back to new pc, boot to windows and access the second partition and it ... empty, no folder or files on drive, it also show like no space was used !!!
    MOST IMPORTANT ! - Why it don't looks like security or permission or even hardware problem - NO any major security changes was performed on my own (old) PC, but most important fact when i connect other hdd to same dock station and create folder and copy some
    files and then connect it to NEW PC - problem does not exist !!! i can see and access without any problem the folder and files on both PC's !
    I also tried:
    to reinstall windows on new pc
    to create or delete partition after setup in both PC's
    to check folder and drive permissions and adding "everyone" with "full control"
    to turn on "show hidden files and folders" and "system files" too
    to copy or create new different type files
    Interesting - if i create a folder in NEW PC i can see this folder on OLD PC and copy files to it, but whet i connect drive back to NEW PC it sometimes show the folder have those files and even use the appropriate space and programs even try to open those files
    without any security warnings but it cannot be open properly because files looks corrupted !
    Thanks for any help !

    Hi,
    According to your description, I don't think this is system problem. More like HDD or its interface problem.
    Have you tried to reconnect your new HDD to your own computer again after you copy some file to it but couldn't find anything on new computer. If there is problem in new PC, how about your own PC?
    Please have a try, If there was any progress, feel free let us know.
    Roger Lu
    TechNet Community Support

  • If I have multiple tabs, the history is not for each tab, so if I drop down it shows history from other windows too, possibly eliminating all history for the current window. How do I get each tab separate?

    The drop down list when the History menu option is clicked, has only provided history information for the tab currently being used. (You could go to all history of course and it was cumulative). It is now showing cumulative history for all tabs including for other Firefox windows if I have more than one copy running.
    Is there an option to separate the histories for each tab again?
    I do not know if this is because of Windows 7. This computer is new as my previous one was stolen and they no longer sell XP versions or Vista versions.
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.8) Gecko/20100722 Firefox/3.6.8
    Windows 7 build 7600 - all updates current.
    My e-mail is [email protected]

    I use that add-on. Works great.

  • Updating JTable From Database

    Hi,
    I am new to Swing and I was wondering if anyone could help me with the following problem.
    I have a tablemodel which extends AbstractTableModel which is used to create my JTable. The data to display in the table is got from a SELECT statement from the database, this works fine.
    The problem is that I have a rollback button which rollbacks any data changed in the database. I then have to do another SELECT statement from the database to populate the table again.
    Is there anyway to do this other than calling the Select function?
    Any Help or Ideas would be greatly appreciated.
    Thanks in advance
    Frank

    Thanks for replying ceccs,
    I did try this by creating a backup vector of the database table. But everytime I changed the data in the Jtable this changed the backup one.
    I haven't got a clue as to why this is happening

  • IPad is not updating photos from other devices

    Hi, My iPad mini used to recieve photos taken from our other devices (iPhones and iPad), recently I stopped recieving updated photos on the mini. I have checked all the settings and everything seems to be on order. Any suggestions? Thanks

    Hi, Snowy03.  
    Thank you for visiting Apple Support Communities.  
    I understand that photos are not updating on your iPad mini using Photo Stream.  Here is a troubleshooting article that may help resolve this issue.  
    Get help using My Photo Stream
    http://support.apple.com/en-us/HT203511
    -Jason H.  

  • Safari window filled squares with a piece of images from other windows

    All the latest updates.

    Please read this whole message before doing anything. This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it. Step 1 The purpose of this step is to determine whether the problem is localized to your user account. Enable guest logins* and log in as Guest. For instructions, launch the System Preferences application, select Help from the menu bar, and enter “Set up guest users” (without the quotes) in the search box. Don't use the Safari-only “Guest User” login created by “Find My Mac.” While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin. Test while logged in as Guest. Same problem(s)? After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it. *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing. Step 2 The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login. Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows: 
    Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
    When you see the gray Apple logo, release the shift key.
    If you are prompted to log in, type your password, and then hold down the shift key again as you click Log in.
     Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs. The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. *Note: If FileVault is enabled, or if a firmware password is set, you can’t boot in safe mode. Test while in safe mode. Same problem(s)? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of steps 1 and 2.

  • How do I adjust the size of the window so I can drop videos from other windows? I am trying to decide if I am going to buy this application but there are too many problems already.

    I am trying out the Premiere Elements but I am not sure I will want to continue to use it. First problem:
    How do I get the window to go to a smaller size? I click on the box on the upper right corner but it still covers the whole computer screen and I cannot grab it and move it either. What is going on? I have an HP computer.
    Thanks for any help out there.

    popsierose
    I am assuming that you are on Windows 7, 8, or 8.1 64 bit.
    Not sure if there is another way, but the way that works for me
    a. right click the computer taskbar, and click on Cascade Windows
    b. in the Premiere Elements Expert workspace, go the the bottom right edge of the workspace view, place the mouse cursor at that point until its tip has a diagonal icon, and then drag upward right to left diagonally to give some view of the desktop where I have the file for the drag and drop into Premiere Elements....then drag and drop the supported file into the Timeline or Project Assets or a drag and drop location.
    Please let us know if that worked for you.
    Thank you.
    ATR

  • JDialog grabs focus from other Windows apps

    Help,
    I have a Swing V1.3.1 program that pops up a notification in a JDialog when it receives some information. The JDialog has two JButtons, one to dismiss (setVisible(false)) and another to do ordinary button stuff. The problem is that under MS Windows2000, if the user is in another application, e.g. Outlook, when the JDialog is made visible Outlook looses focus to the JDialog. All I want is for the JDialog to appear, not to receive focus, since the user is doing something else in another application. Is there some way for the JDialog to "setVisible" yet leave "focus" where ever it currently is, i.e. another application?
    Respectfully,
    John Alfredo

    I'm not too familiar with trying to prevent focus, I usually want it the other way around, but to take a stab at it and hopefully help you or give you some ideas to try:
    What about adding a FocusListener to the JDialog and when it tried to get focus then just deny it somehow. Of course, I'm not sure how the program will know when you are not interested in it except that maybe if you have a JFrame or other component that will initiate this JDialog you can use the FocusListener to check that the parent, i.e. the frame, has or had focus, and if so, give the JDialog focus. I am of course assuming that the frame would not have focus if you are using another program at that time but I can't be sure.
    addFocusListener:
    public void addFocusListener(FocusListener l)Adds the specified focus listener to receive focus events from this component when this component gains input focus. If l is null, no exception is thrown and no action is performed.
    Parameters:
    l - the focus listener.
    Since:
    JDK1.1
    See Also:
    FocusEvent, FocusListener, removeFocusListener(java.awt.event.FocusListener)
    Hope that helps!

Maybe you are looking for

  • Insert data into oracle based on sql server data(here sql server acting as source to oracle and destination to oracle)

    Source is Oralce. Destination is SQL Server. Requirement - I have to fetch sql server server data (empid's) based emp table  and send this as input data to oracle to fetch and empid's are common. I cannot use merge or loopkup or for each as oracle ha

  • How do you know if 3rd party software is trustworthy?

    http://mizage.com/divvy/ was recommended to me. It allows you to size and arrange all the open windows so that they use all the space on the desktop efficiently. How do I know that it is trustworthy? Just because it works well and is recommended does

  • Connecting my hbogot rhough apple tv

    I am trying to authorize hbogo on my apple tv, when I log into hbogo.com on my computer it then has me login to my fios account. I then go to devices and try to add the apple tv, it has a small window pop up thats authorizing through verizon, then it

  • After install, get grey screen then immediate powerdown

    The computer started out as a 350MHz G4 AGP (Sawtooth). It now has a 1GHz Sonnet CPU. It has 1 Gb of RAM and plenty of hard disk. The display is an Apple 20" flat panel. Installed Leopard, upgrading from 10.4.10. On boot, the screen goes grey for abo

  • Where can I download LabView 5.0?

    Im trying find LabView 5.0 Demo to download. I dont want others versions just this one. Anyone can help me please? TIA Sent via Deja.com http://www.deja.com/ Before you buy.