The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Using repaint() in JFrame

Posted by Arun J Martin on July 23, 2001 at 2:25 PM

Hi,
I have a class MainClass which has got 2 JTabbedPanes which are 2 JPanels ie P1,P2.
In P1,I get some user values thru some JTextFields and insert into the database. Then next Panel P2 is used for modifiying the P1's values.
In P2,the values are retreived from the database and put in a JComboBox which is used for further manipulation.
The problem is that whenever I insert values into P1,the new values don't get immediately updated in P2. I have to quit the application and run the application once again. This defeats the very purpose of my app. I want that P2 should reflect my new values immediately when they are inserted into database thru P1.

The outline pgm code
-------------------

public class MainClass extends JFrame implements ChangeListener
{
JTabbed tp;

MainClass()
{
// Declare 2 Tabbed Panes.
tp.add(p1,new p1());
tp.add(p2,new p2());
// add Listener
// add tabbedpane to the container.
}

// Listener method
{
if (selected index = 0)
new p1();
if (selected index = 1)
new p2();
}

public static void main()
{
}

} // end of MainClass

class p1 extends JPanel implements ActionListener
{
JTextField tf1;
JTextField tf2;

JButton submit;

p1()
{
// declare the textfields,button and add to the
content pane
// add Action Listener
}

actionperformed()
{
// get the text field value
// insert into the database
}
} // end of class p1

class p2 extends JPanel implements ActionListener
{
JComboBox jcbox tf;
JTextField tf1;
JButton submit;

p2()
{
// get the values from the database
// put into the combobox.
// the pblm ie the latest values are not being displayed
}

actionperformed()
{
// get the values from the combo box for processing
}
} // end of class p2

with warm regards,
Arun.






Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us