• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question about layout

 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I want to create a GUI like the attachment. Well, I am thinking of using BorderLayout (which I am only familiar with) to do it. But I found it kind of troublesome. I created many pane to draw the GUI, any good idea about how to achieve this?

Thanks.
layout.JPG
[Thumbnail for layout.JPG]
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> Well, I am thinking of using BorderLayout (which I am only familiar with) to do it. But I found it kind of troublesome.

only 2 borderLayout panels are required, so it has to be a lot easier (less troublesome) than a GridBagLayout.

simple demo (titledBorder code only to show where they are)



[edit]
and holdingPanel1 could be the contentPane instead
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow, that is cool, much better than what I did. Thank you Michael very much for the help. I really appreciate it.

Actually I was thinking to use GridBagLayout, which only needs one layer to create this UI, but it looks complicated for me. The reason I want to use it is that I am not sure if I want to update panel 3 which will show a scanned image, do I also need to update holdingPanel 2 which hold panel 3? Thanks.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
> The reason I want to use it is that I am not sure if I want to update panel 3 which will show a scanned image,
> do I also need to update holdingPanel 2 which hold panel 3?

if I'm reading this correctly, all you'd probably need to do is make panel3 a BorderLayout or a Gridlayout(1,1),
then add to panel3 a JLabel to display your image, using label.setIcon(..) to change/update the image.
 
david arnold
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I see. Thanks again for your help, Michael!

Regards.
 
If tomatoes are a fruit, then ketchup must be a jam. Taste this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic