Results 1 to 3 of 3
  1. #1
    sysout is offline Member
    Join Date
    Aug 2009
    Posts
    66
    Rep Power
    0

    Default MultiPle JFrame problems

    I had two JFrames (the first one called A.java -> had a JTable on it, and the second one called B.java -> used to add Items to JTable for A.java)

    When I pressed the Add Items (JButton), A.java poped B.java up (using setVisible).
    The problem was, when B.java successfully inputed items to database, A.java didn't want to refresh it's JTable (because of diffrent JFrame)

    A.java pop up B.java, B.java successfully had done it's job, but A.java didn't want to refresh it's JTable because of diffent JFrame.

    ################################################## ###
    Another problem :
    I want to check who is login, so I create a private variable in a class, using a setter and getter on it.
    In another class (another Jframe), I used to call for the last class which contained that private variable, but it seems to be failed to access the value from the last class.

    Any examples solutions for my problem? thanks.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    I had two JFrames...
    The easiest way to solve this is not to use two JFrames but instead have your main window with the JTable be a JFrame and pop up either a JOptionPane or a modal JDialog that requests information from the user. The code calling the option pane or modal dialog will stop processing until the user enters their information into the dialog and closes it. The calling class can then extract this information from the dialog's components (JTextFields or whatever) and use this to update the JTable that it's holding.

    I'm assuming of course that you know how to use table models such as a DefaultTableModel to update your JTable. If not, please read the Sun tutorial on JTables and table models.

    Another problem
    Without code it's impossible to tell why this program is not working.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    26

    Default

    If you are still unsure, why not post some of your code in here and we can take a look at it. It would be most helpful if that code were small, compilable and runnable -- a small self-contained program that demonstrates your problem, otherwise known as an SSCCE.

Similar Threads

  1. Multiple Panels in JFrame or JPanel
    By DavidG24 in forum AWT / Swing
    Replies: 5
    Last Post: 05-16-2009, 01:47 PM
  2. problems with JPanel and JFrame
    By v1nsai in forum New To Java
    Replies: 13
    Last Post: 04-08-2009, 08:49 PM
  3. Replies: 6
    Last Post: 07-28-2008, 07:04 PM
  4. Can't synchronize multiple JPanels in a JFrame
    By vassil_zorev in forum AWT / Swing
    Replies: 0
    Last Post: 12-30-2007, 05:22 PM
  5. problems with jDialog in a JFrame
    By bbq in forum AWT / Swing
    Replies: 1
    Last Post: 07-05-2007, 05:14 AM

Posting Permissions

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