Be a Supporter!

Making it appear in a window?

  • 382 Views
  • 7 Replies
New Topic Respond to this Topic
sekendis
sekendis
  • Member since: Nov. 23, 2010
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Making it appear in a window? Jan. 18th, 2013 @ 02:46 PM Reply

So, I've got this code, more like a script. It's a random generator for my role-plays. Got it all coded nice and neat runs perfectly....... In command line. How do I make this

<pre>
package role.play.generator;
import java.util.Random;
public class RolePlayGenerator {
public static void main(String[] args) {
Random randomgenerator = new Random();
int hairsel = randomgenerator.nextInt(5);
int clothsel = randomgenerator.nextInt(4);
String[] clothtypes = {"Dress","Skirt","Robe","Pants"};
String[] haircolours = {"Blue", "Red", "Blonde","Black","Purple"};
double height = Math.floor(Math.random()*9+58);
String Haircolour="Hair Colour:"+haircolours[hairsel];
String Clothing="Clothing:"+clothtypes[clothsel];
String Height = "Height:"+height+" Inches";
System.out.println(Height);
System.out.println(Clothing);
System.out.println(Haircolour);
}
}

Output the prints, into a window with a button to run it again?
I'm week in and this is only functional as of yesterday.


Sorry about the formatting fail.

sekendis
sekendis
  • Member since: Nov. 23, 2010
  • Offline.
Forum Stats
Member
Level 03
Blank Slate
Response to Making it appear in a window? Jan. 19th, 2013 @ 12:39 PM Reply

Did a little research going to do some tutorials, maybe repost this thread if I still can't do it.


Sorry about the formatting fail.

Hoeloe
Hoeloe
  • Member since: Apr. 29, 2004
  • Offline.
Forum Stats
Member
Level 37
Game Developer
Response to Making it appear in a window? Jan. 22nd, 2013 @ 09:22 AM Reply

You know what would help?

Telling us what language you're writing this in. That's a fundamental thing we MUST know to be able to help.

You're also giving us a bare minimum of information. Remember, when asking for help, the more information and detail you can give, the better.


Decima: The Last Story of Vald has a Facebook page and a development blog. Give them a look!
------------------------------

BBS Signature
Diki
Diki
  • Member since: Jan. 31, 2004
  • Offline.
Forum Stats
Moderator
Level 13
Programmer
Response to Making it appear in a window? Jan. 22nd, 2013 @ 10:07 AM Reply

At 1/22/13 09:22 AM, Hoeloe wrote: what language you're writing this in.
At 1/18/13 02:46 PM, sekendis wrote: import java.util.Random;

Hmmm

FallingTears
FallingTears
  • Member since: Nov. 28, 2012
  • Offline.
Forum Stats
Member
Level 03
Programmer
Response to Making it appear in a window? Jan. 22nd, 2013 @ 10:10 AM Reply

At 1/22/13 09:22 AM, Hoeloe wrote: You know what would help?

Telling us what language you're writing this in. That's a fundamental thing we MUST know to be able to help.

You're also giving us a bare minimum of information. Remember, when asking for help, the more information and detail you can give, the better.

Actually, it's very clear that he/she is using Java. What would help is if he/she would put the source code in the code tags. You'll find more information about the code tag on the left of the message box.


BBS Signature
kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Making it appear in a window? Jan. 23rd, 2013 @ 01:36 PM Reply

At 1/18/13 02:46 PM, sekendis wrote: So, I've got this code, more like a script. It's a random generator for my role-plays. Got it all coded nice and neat runs perfectly....... In command line. How do I make this

You need to use a framework, I used to use swing, but it's deprecated as shit now. People recommend GWT instead of swing, not sure how it work or how easy/hard it is to setup and use, but you could also check that out I guess.

Also links:
Swing
GWT

VBAssassin
VBAssassin
  • Member since: Jul. 22, 2008
  • Offline.
Forum Stats
Member
Level 01
Blank Slate
Response to Making it appear in a window? Jan. 24th, 2013 @ 02:10 PM Reply

At 1/23/13 01:36 PM, kiwi-kiwi wrote:
At 1/18/13 02:46 PM, sekendis wrote: So, I've got this code, more like a script. It's a random generator for my role-plays. Got it all coded nice and neat runs perfectly....... In command line. How do I make this
You need to use a framework, I used to use swing, but it's deprecated as shit now. People recommend GWT instead of swing, not sure how it work or how easy/hard it is to setup and use, but you could also check that out I guess.

If swing is deprecated... why does GWT to use Swing (look at the components)?
https://developers.google.com/web-toolkit/tools/gwtdesigner/
userinterface/source_view

kiwi-kiwi
kiwi-kiwi
  • Member since: Mar. 6, 2009
  • Offline.
Forum Stats
Member
Level 09
Programmer
Response to Making it appear in a window? Jan. 24th, 2013 @ 02:54 PM Reply

At 1/24/13 02:10 PM, VBAssassin wrote: If swing is deprecated... why does GWT to use Swing (look at the components)?
https://developers.google.com/web-toolkit/tools/gwtdesigner/
userinterface/source_view

Not sure, basically sometime ago java developers decided that SWING should belong in a dark corner where upgrades aren't necessary and was removed from netbeans to be superseded by something else sometime in the future (that was one year ago when I last used java for gui programming link here for a somewhat related discussion)

After snooping around for a while it seems that at the time oracle just released JavaFX 2.0 and was trying to push it as a replacement and I basically fell for the marketing.
@OP use whatever you want then I guess.

Still if you have the time I'd advise you to try out Qt before deciding what you want to pursue in the world of GUI programming.