Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

solution please  RSS feed

 
Sivakumar Janardhanan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello every body this is my sample code.


Please you must run this code and give the solution to me.

if you run this code, you will get one window with menu(in my code "Home"). After click the menu item (in my code "login") that rendered another one window ("second window").

now how to add some component in my "second window"?

i tried some trix. but every component align in center only as default while i am running.

so i expect from you the detailed explanation.

please give the sample code.

[EDIT: Added code tags-MG]
[ December 19, 2008: Message edited by: Maneesh Godbole ]
 
Mikko Kohtamäki
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

Through jframe.add(component) the component is beeing added to jframe's content panel with 'null' contraints.

Container container = jframe.getContentPane();
container.setLayout(someLayout);
container.add(someComponent, someConstraints);

Using Layout Managers
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as a side issue, you are likely to get strange painting problems with code like this

JLabel name = new JLabel("user");//swing component
Panel p = new Panel();//awt component
p.add(name);

further reading
http://java.sun.com/products/jfc/tsc/articles/mixing/
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sivakumar,
In future, while posting code, please use code tags.
I have edited your original post for the same. As you can see, the code tags make the code much more readable and easier to understand.
 
Rob Spoor
Sheriff
Posts: 21092
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sivakumar, please Use A Meaningful Subject Line. Everybody posting a new thread wants a solution.

You can use the edit button to change it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!