0

I have a text field set to size 100x400 (it's under icons and f(x) = ... text)

1

and if i resize my window even by 1px when the applet is already running then it's changing to this:

2

code for textfield:

TextField textFieldA = new TextField("7.5", 35);
...
add(aa);
add(textFieldA);
aa.setLocation(920, 600);
textFieldA.setBounds((int)(920 + aa.getWidth() + 10),595,150,30);

aa is the image with "a = "

Asalas77
  • 249
  • 5
  • 13
  • Are you using any layout? – Mubin Apr 23 '14 at 14:38
  • no, i'm not. i just set positions for everything in pixels – Asalas77 Apr 23 '14 at 14:46
  • I would suggest to use layout. Absolute positioning can lead to problems when the applet/frame size is altered. Also, troubleshooting will be difficult with absolute positioning unless we know the positioning used for all the controls. – Mubin Apr 23 '14 at 14:49
  • @Mubin is there any way to lock the window at its current size? – Asalas77 Apr 23 '14 at 14:52
  • Applet is NOT a subclass of Frame and hence not a top-level window. It is a specialized subclass of Panel, and hence the size of the applet cannot be controlled except by the tag when embedded in a HTML. However, you can write your application as a Frame-based app and write an applet that uses an instance of that frame. – Mubin Apr 23 '14 at 14:57
  • Java GUIs might have to work on a number of platforms, on different screen resolutions & using different PLAFs. As such they are not conducive to exact placement of components. To organize the components for a robust GUI, instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556), along with layout padding & borders for [white space](http://stackoverflow.com/q/17874717/418556). – Andrew Thompson Apr 24 '14 at 07:56

0 Answers0