How to Make a Text Adventure Game with GUI in Java P3 - Add function to button

preview_player
Показать описание
Playlist:

In this video, we're going to create the gameplay screen with JTextArea and JButton and add a function to the start button so users can move from the title screen to the gameplay screen.

Using:
JFrame
Container
JPanel
JLabel
JButton
JTextArea

ActionListener
ActionCommand

#programming #gamedev #textadventure
Рекомендации по теме
Комментарии
Автор

*Updates*
If you wish to make the "mainTextArea" non-editable, please add this line:


If you wish to wrap lines at word boundaries, please add this line:


If your text doesn't show up unless you resize the window, please try:
Move "window.setVisible(true);" to the bottom of the Game method (right below "con.add(startButtonPanel);")

RyiSnow
Автор

I really like the tutorial it's really helpful!

One thing I did that I would recommend other people is creating a seperate method for the button, so that you don't have to write the same code mulitple times.
Such as:
choiceOne = ChoiceButton();
choiceTwo = ChoiceButton();

public JButton ChoiceButton( ){
JButton button;
button = new JButton();

button.setFont(Font buttonFont);
return button;
}

Saves you some time makes it a little more readable.

gilbertmccray
Автор

watching in 2022; can't believe you dont have more subscribers, feels like i hit gold. thank you so much for all of your tutorials :) i'm creating my own game to put on my resume and these have been very helpful and just in my skill set

cristalc
Автор

This is very good and easy to understand.
just wanted to show a simpler way to implement the single interface ActionListener() using lambda

Instead of creating a whole new inner Class and new object, you can do this:

createGameScreen());

This one line is enough. You don't need the extra inner class or an object of the class.

trulyepic
Автор

Your video is so easy to follow! Thank you for making this.

Firecloak
Автор

Thank you for making these tutorials, I didn't want to take on Java until I found this! This is amazing, tysm for making this.

nyvixal
Автор

This has been very helpful! I hope the next part comes out soon. Thank you!

danivalentine
Автор

This helped me so much in my actual class thank you so much

pinchtulip
Автор

THis Tutorials are so Good :D Thank you so much <3

Joens_Schmidt
Автор

Thank you so much for these tutorials, my friends and I find these videos very interesting and fun.

mothratheresa
Автор

Very nice tutorials dude you diserve more clicks if I compare this to other tutorials =) nice work and keep doing!

pittherichkid
Автор

awesome tutorial so far. can't wait to get till the end!

ankitg
Автор

just wanted to say these tuts are amazing. U have my subscription!

IceWizard
Автор

I enjoy learning and these tutorials are fantastic for learning java swing.

PaperNinjaMan
Автор

This is a great tutorial! I was able follow along easily.

tily
Автор

Thanks a lot for this tutorial! Very well structured and explained.

NormanWill
Автор

Nice tutorial bro keep up the good work!

llackjack
Автор

To save yourself time, you can always just using a * with imports to import entire packages, so java.awt.*, java.awt.event.* and javax.swing.* will import all you need, as far as I know, havent finished the tutorial yet.

isaiah
Автор

Your video series is amazing!
Would it be possible for you to upload the next part this week? I am desperate here! I have a mini-project deadline soon and i don't know how to put the game text onto the screen. :P
Thank you so much.

EpicEditsBySaz
Автор

When i run the program i get the game screen without text when i move the border of the menu one millimeter i see the text, what did i do wrong??

marcelverhagen
join shbcf.ru