#how do you call a method from a different class

14 messages · Page 1 of 1 (latest)

deft arrow
#

i have made a class called msuictes and when it is compiled it plays music. i need help making the music play when the main class is compiled

near templeBOT
#

This post has been reserved for your question.

Hey @deft arrow! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

remote lion
#

what exactly is the problem

deft arrow
#

basically the class play music works and plays music when it compiled but i need it to play music when the main class is compiled

#

the class music tes is supposed to hold the background music for my game

#

and i think i need to call the method from musictes in the main?

remote lion
#

What have you tried so far?

#

What UI framework are you using?

#

Swing? JavaFX?

deft arrow
#

JavaFX

remote lion
placid sluice
#

just put in the main class:
MusicClass musicClass = new MusicClass();
or whatever u named it
and then musicClass.play();

#

whatever the method is called