I am trying to display a few textFields in an AWT applet. The number of textFields I need to set is variable. I want to repaint a portion of an applet (the panel in which these textFields are placed) when a button is clicked.
In the code below, I added a textField array in panel 1(p1), initialized with record size (no_of_rec), which I know at the beginning (no_of_rec = 2 at INDEX = 0).
When I click "Next Item" button, I want to show 4 textFields (no_of_rec = 4 at INDEX = 1), with the values C, D, E, F.
One more click (INDEX = 2) should show one textField only, with the value X.
The codes for the textFields are in a method(addDataPanel), so that I can call it when I click "Next Item" button. A system.out check shows that 4 textFields are created when INDEX = 1, and so on, but with calling repaint() inside the button's actionPerformed method, I am unable to update the panel (p1) dynamically.
When I minimize the window with [-] button, or resize by dragging the applet with mouse, I can see four textFields with the items A, B, E, F. It should have been C, D, E, F. My second click does not change anything.
public class test1020 extends Applet{ int NO_OF_REC = 0; int INDEX = 0; TextField[] txtDataRowDisplay; String[] data; Panel p1; GridBagConstraints c1; Color pnlBgColor = new Color(144, 196, 222);
public void init() { data = getData(INDEX); NO_OF_REC = data.length;
//main Panel Panel pMain = new Panel(); pMain.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); pMain.setBackground(pnlBgColor);
//p0 Panel p0 = new Panel(); p0.setLayout(new GridBagLayout()); GridBagConstraints c0 = new GridBagConstraints(); c0.fill = GridBagConstraints.HORIZONTAL; p0.setBackground(pnlBgColor);
//p1 p1 = new Panel(); p1.setLayout(new GridBagLayout()); c1 = new GridBagConstraints();
I am sorry about the formatting. Probably shouldn't have put tags. Here is another try.
I am trying to display a few textFields in an AWT applet. The number of textFields I need to set is variable. I want to repaint a portion of an applet (the panel in which these textFields are placed) when a button is clicked.
In the code below, I added a textField array in panel 1(p1), initialized with record size (no_of_rec), which I know at the beginning (no_of_rec = 2 at INDEX = 0).
When I click "Next Item" button, I want to show 4 textFields (no_of_rec = 4 at INDEX = 1), with the values C, D, E, F.
One more click (INDEX = 2) should show one textField only, with the value X.
The codes for the textFields are in a method(addDataPanel), so that I can call it when I click "Next Item" button. A system.out check shows that 4 textFields are created when INDEX = 1, and so on, but with calling repaint() inside the button's actionPerformed method, I am unable to update the panel (p1) dynamically.
When I minimize the window with [-] button, or resize by dragging the applet with mouse, I can see four textFields with the items A, B, E, F. It should have been C, D, E, F. My second click does not change anything.