This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Layout problem using AWT Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Layout problem using AWT" Watch "Layout problem using AWT" New topic
Author

Layout problem using AWT

Naresh Talluri
Ranch Hand

Joined: Oct 12, 2007
Posts: 115
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.




[Thumbnail for output.jpg]

Naresh Talluri
Ranch Hand

Joined: Oct 12, 2007
Posts: 115
Can anyone please let me know any solutions..
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19552
    
  16

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):


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
 
subject: Layout problem using AWT
 
Similar Threads
problem in running AWT programs!!
gui
Focussing a TextField
doLayout()
Can't get an ActionListener to change a JLabel text