0

I'm trying to build a java GUI with SWING in Window Builder using Eclipse IDE. What I want to do is to create a long form. I create a JPanel, I can adjust the size of this JPanel in the editing area by dragging the boder of the panel as normal, But the problem I found is that no matter how far I drag down the bottom border, the heigth of this JPanel won't go any further.

I found some answers saying that the edit window of Window Builder won't render any components falling outside of the bounds of the display size. That means in the edit area of Window Builder in Eclipse, I can only create and see a JPanel whose maximum size equals to my display resolution?

That's not very convenient especially when you want to edit GUI in a WYSIWYG way. Then what can we do when people really need a big GUI?

Takarii
  • 1,612
  • 2
  • 18
  • 29
  • *"..especially when you want to edit GUI in a WYSIWYG way."* Developing GUIs that are intended to work across platforms does not work that way. It is closer to say it is WUWIWYG - What **User** Wants Is What **User Gets.** More generally: Java GUIs have to work on different OS', screen size, screen resolution etc. using different PLAFs in different locales. As such, they are not conducive to pixel perfect layout. Instead use layout managers, or [combinations of them](http://stackoverflow.com/a/5630271/418556) along with layout padding and .. – Andrew Thompson Aug 10 '16 at 12:55
  • .. borders for [white space](http://stackoverflow.com/a/17874718/418556). – Andrew Thompson Aug 10 '16 at 12:55
  • BTW - put the panel in a scroll pane. – Andrew Thompson Aug 10 '16 at 12:55
  • At last, I reconsider my gui design. Instead of construting a huge panel, I decide to use a combination of smaller panels or tabs. Thanks for your comments. – Edouard Xu Aug 11 '16 at 13:10

2 Answers2

0

Typically in cases like this we use a JScrollPane with the JPanel inside. You can then make those panels as long/wide as you want, and it will auto generate scroll bars as required. The IDE will let you scroll these bars in the WYSIWYG editor so you can place controls further down.

See the official documentation on how to properly implement them.

Takarii
  • 1,612
  • 2
  • 18
  • 29
0

you can't create a JPanel bigger then the visible area of the screen and be able to see it, what you have to do is to create a JPanel the size you want then put it into a JScrollPane that has scroll bars to display a portion of the component you put inside (JPanel in this case) if you are using an IDE you can create a JScrollPanel and make sure the properties of the scroll bars are not set to NEVER, you can set them to VERTICAL_SCROLLBAR_AS_NEEDED for horizontal scrolling HORIZONTAL_SCROLLBAR_AS_NEEDED for vertical scrolling then create a JPanel and drag it inside the JScrollPanel you created before and finally resize your JPanel by changing the property its size property to the size you want

whyn0t
  • 301
  • 2
  • 14
  • Yes, actually I'm using Eclipse Mars, Windows Builder 1.8.0 plug-in. Putting JPanel into a JscrollPanel seems to be a solution for the run time. While, the problem is in the edit view, the time when you are creating you gui, the scroll bars are there, but could never be dragged, which means you can still only edit a limited area withou scrolling to elsewhere. This is exactly what I run into using Eclipse, I don't know other IDEs, the same thing happens in Netbeans and other IDEs? – Edouard Xu Aug 11 '16 at 12:11
  • IDE help you to build GUIs faster but you should at least know the properties of the components you are using, to configure them properly – whyn0t Aug 11 '16 at 12:16
  • maybe the edit is empty try copy past a long text and see if scrollbars work(they should) – whyn0t Aug 11 '16 at 12:18
  • In my case, it didn't work. I put a JPanel into a JScrollPanel, set the both scroll bar policies to be ...AS_NEEDED, then I put some components that reach out of the bounds of the JPanel, the layout of the JPanel is GroupLayout, I can see the scroll bars show up (If I set the layout of the JPanell to be AbsoluteLayout, there is even no scroll bar shown in the editor). The components can be seen in normal way by scrolling in run time, but in the editor the JPanel just can not be scrolled. – Edouard Xu Aug 11 '16 at 12:38
  • now i see!! :D, you can't use the JScrollPane of the design editor i never thought of that, why don't you divide the components in you GUI into groups and put them into individual panels , design each panel separetely then group them in a JScrollPane – whyn0t Aug 11 '16 at 12:51
  • I can't use the scroll bar of JScrollPanel in editor mode. – Edouard Xu Aug 11 '16 at 12:53
  • Yeah, that's what I'm thinking about. I consider breaking the big design into tabs or panels and then re-organize them. By the way, I found this: https://www.eclipse.org/forums/index.php/t/354403/ It appears to be a OS-related issue. "It is an "uncommon" issue because most folks don't build UIs larger than what can be displayed on the typical screen sizes available to their users." – Edouard Xu Aug 11 '16 at 12:58
  • glad you finally found a solution =] – whyn0t Aug 11 '16 at 13:01