Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Layout problem using AWT

 
Naresh Talluri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

I have small problem with AWT while arranging buttons.
I want to arrange one text field in one line , and next all lines will be followed by buttons like calculator.
I can able to show buttons as i like but text field is not showing appropriately.

here is my code :



Here is the whole class, if you want you can execute directly, and am attaching output of the program as well.
could you please let me know how can i achieve,
I really appriciate if anyone have any solutions.


output.jpg
[Thumbnail for output.jpg]
 
Naresh Talluri
Ranch Hand
Posts: 115
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone please let me know any solutions..
 
Rob Spoor
Sheriff
Pie
Posts: 20608
63
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
PatienceIsAVirtue.

On line 28 you add textpanel. A Frame uses a BorderLayout by default. You omit the constraints so that means you add textpanel to the center. On line 29 you then add panel - again to the center. This overwrites textpanel, effectively removing it from the frame.

Specify the constraints when adding textpanel (and preferably, panel as well):
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic