[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 >Swing I have a 600x600 panel and I want a jframe
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: 19
Thread images: 3
File: java.png (7 KB, 259x259) Image search: [Google]
java.png
7 KB, 259x259
>Java
>Swing
I have a 600x600 panel and I want a jframe to show exactly the entire panel, how?

Currently im just setting the preferred size of the jframe to a height of 620 but there has to be a better way, right?
>>
It's been so long since I've done swing but surely a panel can't be resized? It'll resize to the size of whatever contents you have in it. So whatever is in the panel, adjust your JFrame to the size you need I guess
>>
fuck off to stack overflow and google
>>
File: 1422465590251.jpg (25 KB, 228x221) Image search: [Google]
1422465590251.jpg
25 KB, 228x221
>>54858704
>being this mad
>>
>>54858892
>trying to counter troll

you literally need help with a basic java concept.. like literally give up on programming if you come HERE for help
>>
>>54859173
>still being that angry
Take a chill pill
>>
>>54858128
netbeans do that shit easily, just use an IDE
>>
>>54859247
>still being this retarded
>>
File: 1464606602660.png (568 KB, 600x580) Image search: [Google]
1464606602660.png
568 KB, 600x580
>>54859371
I sure got you to spend your entire evening focusing on my thread ;^)
>>
The jframe resolution is manually set I dont understand your question?

Whenbyou define your jframe you just want to define
 
JFrame frame = new JFrame()
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(600,600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);


Then you add your panel with

frame.add(panel)


If you need more than one panel, learn how to use gridbaglayout

Also, next time you havea question abouta swing or any java component, google "oracle documentation jframe" or whatever it is you need
The best thing about java is the insanely well organized and accessible documentation
>>
>>54858128
pack()
Also JAVA SUCKS
>>
>swing

don't.

There is a time and a place to use java libraries and swing is not a time or place to use ever.
>>
>>54859868
I think OP is doing exactly this, and that's what his problem is.

If your panel is 600x600 it's actually the window including the window chrome that gets 600x600, while the actual panel is missing the border dimensions.
>>
>>54861178
what's with you guys and forgetting PACK()?

The pack method sizes the frame so that all its contents are at or above their preferred sizes. An alternative to pack is to establish a frame size explicitly by calling setSize or setBounds (which also sets the frame location). In general, using pack is preferable to calling setSize, since pack leaves the frame layout manager in charge of the frame size, and layout managers are good at adjusting to platform dependencies and other factors that affect component size.

From Java tutorial
>>
>>54858128
Why Swing? Why not JavaFX?
>>
>>54861594
Even oracle has given up on javaFX at this point.
>>
>>54861621
FX was supposed to replace Swing.
>>
>>54861713
>supposed to
Too bad it failed. Most people still use swing. Hell, even oracle's certification exam requires you to build server gui in swing.
>>
>>54861409
I left Java a long time ago. The money was not worth it. So tell that to OP not me.

Fuck a shit up your ass and choke on dicks Java and Swing.
Thread replies: 19
Thread images: 3

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.