• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help needed in swing

 
Pradeep Kumar
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
I am new to swings but have experience on server side programming. I want to build a small swing application because i dont need J2EE foe s small application. I went through the API and worked on some layout managers. But i am not satisfied with the look and feel of the components on the JFrame. If someone can help me with this it will be of great value. The hicup that i faced is

1. My requirement is to have a panel inside a frame but it should be located at center and should have an offset gap with respect to the outer border of the frame. I tried with the borderlayout but when i add any component to the frame using borderlayout the component occupies the entire screen which is no what i want.



Thanks and Regards,
Pradeep

[ October 10, 2008: Message edited by: Pradeep Kumar ]
[ October 10, 2008: Message edited by: Pradeep Kumar ]
 
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
Originally posted by Pradeep Kumar:

1. My requirement is to have a panel inside a frame but it should be located at center and should have an offset gap with respect to the outer border of the frame.


One way of doing this is by setting a border.
Check out the BorderFactory class, especially BorderFactory#createEmptyBorder()

PS. You need to set the border to your panel.
[ October 10, 2008: Message edited by: Maneesh Godbole ]
 
Pradeep Kumar
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks fo the reply. And what if i want to have some offset between my label component and the border of the panel so that the label does not stick to the edge of the panel. In this case the empty border would not be very much ideal. Can you kindly suggest me how to handle this case.
[ October 10, 2008: Message edited by: Pradeep Kumar ]
 
Campbell Ritchie
Marshal
Posts: 52559
119
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another thing you could try, which works in GridBagLayout and GridBagConstraints, is to put non-zero Insets on your Component.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
> In this case the empty border would not be very much ideal.

it would have helped had you looked up the apidocs for the method given,
before dismissing the ideal solution.
 
Pradeep Kumar
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Micheal,
The intention behind proposing that the empty oder would not be a feasible solution was with repect to it would simply add one more panel just to have a space between the edge and the component which i think is not really necessary.
 
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
When you set any border to a component, it does not "add one more panel". Please read the API carefully.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!