[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
Create a Default
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: 13
Thread images: 1
File: Java.png (221 KB, 1600x1280) Image search: [Google]
Java.png
221 KB, 1600x1280
Hey, im programming java and one thing that im so tired is to do in every program a menu with switch and that stuff is any way possible to create a default menu that whenever i call it, it would make me a menu?
Thank you
>>
I'm assuming that you just want a panel with two radio buttons acting as a switch.

Also assuming you're using Swing, but the principals apply for both JavaFX and AWT as well.

Just create a new class, let's call it SwitchView, and then have it extend JPanel.
In the constructor you will setup the layout of the components defined as private-final class variables.
Ensure that you make a getter for any usable components.
Ensure that you set the ActionHandler of any usable components to the new SwitchController class.

In the constructor of the SwitchController class, you'll take in the JFrame param, call the SwitchView constructor, assign the SwitchView as a class variable, add tge SwitchView to the JFrame, have SwitchController implement ActionL8stener, and handle action events.

Basically.
>>
>>51246913
Thank you for your reply but im still in console of java... i want to create a default class
>>
>>51247032
Ah, so you want to create some sort of text-based menu for the console to display?

You wouldn't need a class for that IMHO, just create a method that prints out the menu and have a little Scanner to handle the user input.
>>
>>51247421
And it is possible to create a default method?
>>
>>51247471
Yeah, just hang around in this thread for a little bit. I'll try to write up an example for you.
>>
>too retarded for java
Is such a thing even possible?
>>
>>51247486
Thank you so much!! I use intellij Idea if that information is usefull to u
>>
>>51247515
Ohhhhhh yeahhh. You'd be surprised to see how many people I had to tutor back when we had to learn it.
>>
>>51247486
btw have skype?
>>
>>51247570
Yup, I'll include my username somewhere in the little file I'm writing up so it's not directly posted on here.

About halfway done.
>>
This paste expires in an hour.

http://pastebin.com/hUddD84i
>>
>>51247713
Thank you so much!! :)
Thread replies: 13
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.