Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Creating Text Fields, Labels & Input Boxes on GUI  RSS feed

 
Damien O Sullivan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I'm just wondering could anyone recommend any good tutorials or any good online sources that could help me understand how to create text fields, labels and input boxes on a GUI, we haven't covered these in class as of yet, but I want my project to stand out so I'd like to know how to build a GUI now.

Thanks in advance.
 
Knute Snortum
Sheriff
Posts: 3559
86
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to wait. There are two ways of doing GUI (at least) in Java now, Swing and JavaFX. I'd hate for you to learn the "wrong" one for your class. Swing is older but more prevalent. Oracle has a good tutorial on it, as it does on most things Java.
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you seen this?
 
Damien O Sullivan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Have you seen this?


That link shows you how to start working with Swing using NetBeans, I'm using jGrasp though. Does that matter or should I try and use another tutorial?
 
Campbell Ritchie
Sheriff
Posts: 53779
128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only a small part of that tutorial uses NetBeans.
No, you should not use NetBeans at this stage. Write all your code by hand.
 
Damien O Sullivan
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So far I have this




But I want to be able to change what the label says using a random number, I can generate the random number in another example I have but I can't seem to implement it in this code.

In my other example, the random number is generated in the main method, but this example only calls a method.

How should I go about being able to change the text of the label?

 
Carey Brown
Saloon Keeper
Posts: 2540
33
Eclipse IDE Firefox Browser Java MySQL Database VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Create a new method:


Change your main() method:
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!