[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
Java GUI help
Images are sometimes not shown due to bandwidth/network limitations. Refreshing the page usually helps.

You are currently reading a thread in /g/ - Technology

Thread replies: 9
Thread images: 1
File: qqq.png (125 KB, 947x451) Image search: [Google]
qqq.png
125 KB, 947x451
Hello.

I usually don't ask you guys for help but this time I got frustrated because I wasted too much time already and my project due is getting closer and closer.

I have this project to design a small app for online shipping. The problem is I don't know which layouts to use. Grid, Box and Border are not working for me. ( I'm probably doing something wrong). Lets say I want to setSize of my JFrame (which is BorderLayout) to be 500 px width, and all the content ( JPanels with items picture price etc ) to be always the same size, aligned in one row from left to right and if I add more and more JPanels, it will not squeeze them together or float them down to second row but use a scroll bar instead.

Pretty much I want to have a horizontal content pane with scroll bar, one row only, every content not resizable (not affected by LayoutManager).

Thank you guys for help!
>>
>>53847179
What's stopping you from using JavaFX and Scene Builder?

It's superior aesthetically as well.
>>
I'm a beginner, don't know much about GUIs
>>
>>53847278
>Pretty much I want to have a horizontal content pane with scroll bar, one row only, every content not resizable (not affected by LayoutManager).

You literally just described FlowLayout. It arranges all of the components that you add horizontally to each other; they are set to their preferredSize() and don't resize with the panel.

What you want to do is add a ScrollPane. Set the content pane of the ScrollPane to your FlowLayout pane.

And just so you're aware: you CAN mix and match layouts. Once I realized that, everything got a ton easier.
>>
I'm sorry but I'm still kinda lost. Could you post a simple code for it ? I know I sound like a noob but that's my first GUI project.
>>
>>53847917
Here's your code
curl "https://www.google.com/search?q=flowlayout"
>>
>>53847917
JPanel flow = new JPanel(new FlowLayout());
JScrollPane scroller = new JScrollPane(flow);
frame.getContentPane().add(scroller);
>>
Wow thanks, you helped a lot. ;)

OK let's try this. How do I force my FlowLayout to keep all my JPanels in one row? It's obviously checking the width of my JFrame and if 2 JPanels can't fit in JFrame it automatically moves one to the bottom. I want it to be independent and the only thing that changes during resizing my JFrame would be scrollbar.
>>
>>53848013
Thank you kind sir !
Thread replies: 9
Thread images: 1

banner
banner
[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com, send takedown notices to them.
This is a 4chan archive - all of the content originated from them. If you need IP information for a Poster - you need to contact them. This website shows only archived content.