File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Adding a scroll bar to main window after initial design with Netbeans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Adding a scroll bar to main window after initial design with Netbeans" Watch "Adding a scroll bar to main window after initial design with Netbeans" New topic
Author

Adding a scroll bar to main window after initial design with Netbeans

Gary Fletcher
Ranch Hand

Joined: Nov 12, 2013
Posts: 36
I am trying to create a file merge application and have created the initial front-end design using Netbeans with a Group Layout Manager.

The app starts with extended state as MAXIMIZED_BOTH and when I "Restore Down" the window goes to these preferred sizeds as expected, but I realise that I need a scroll basr on the driving window.

Is there a way to just add a scroll bar to the main JFrame using Netbeans or will I need to create a new ScrollPane and add all the components?

Not sure if the code is needed as its Netbeans generated, but can if it makes it easier.

Thanks.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
NetBeans generated code often doesn't make things easier

I think you will probably have to use a scroll pane. You appear to know about scroll panes already.
Gary Fletcher
Ranch Hand

Joined: Nov 12, 2013
Posts: 36
Hi Campbell

Netbeans does make it difficult to change code. Best way I've found is just to copy and paste into a new project in Eclipse, the Eclipse SWING IDE is pretty bad BTW.

I could do this but I was hoping that there would be a way to do it via the IDE, but not able to find a JFrame property that will allow this, so was/am hoping that an expert could let me know if possible.

Any ideas/solutions?

Thanks
Piet Souris
Ranch Hand

Joined: Mar 08, 2009
Posts: 525
    
    8
In the NetBeans GUI designer, you can directly drag a JScrollPane into your frame,
and into your JScrollPane, you can add a JPanel, for instance. To see the scroll bars
in action, give that JPanel a PrefferedSize that's bigger than that of the scrollpanel, and
press the "preview design" button to see it all.

What I do, if I use this GUI designer, is to create a JPanel in my frame, of about the
right size.
Then, in my own code, I would create the JScrollPane(contents) the size of the JPanel,
and add it to that JPanel. Advantages are that you have complete control over
where your scrollpane appears in your frame, and have full control over that scrollpane.

That will give you the best of both world.

Greetz,
Piet
Gary Fletcher
Ranch Hand

Joined: Nov 12, 2013
Posts: 36
Thanks Piet...sounds like a plan.
Gary Fletcher
Ranch Hand

Joined: Nov 12, 2013
Posts: 36
Ah...so as I suspected...there is no drag an drop to make existing frame scrollable, just have to add from scratch. Must say that the Swing is very bloated and over complex. Not very good at all. Netbeans is about the best way to use it, not sure about FX, but hopefully wont be as complex for no reason. C# is soooo much easier and better for UI design.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding a scroll bar to main window after initial design with Netbeans