This site requires JavaScript, please enable it in your browser!
Greenfoot back
Alwin_Gerrits
Alwin_Gerrits wrote ...

2014/10/30

centering JOptionPane message

Alwin_Gerrits Alwin_Gerrits

2014/10/30

#
Hey guys, I was doing some programming in my platform game and I noticed text in my JOptionPane would appear only on the left corner of the messageblock. Any chance there's a way to place it in the middle? I'm using this code:
JOptionPane.showMessageDialog(null, "YOU WIN!\nYour score:" + SCORE.score + "\nCurrent 
highscore:" + SCORE.highscore, "CONGRATULATIONS", JOptionPane.PLAIN_MESSAGE);
NikZ NikZ

2014/10/30

#
You could use JFrames, JComponents, and JLabels...
Alwin_Gerrits Alwin_Gerrits

2014/10/31

#
It seems like it's gonna take days for me to figure this out on my own (it's a way to vast quantaty of options and I'm receiving a lot of errors while trying to get it done). Unfortunately I don't have that much time, so for now I guess just putting in some space's is going to do the trick... It may not look so well codewise, but hey it's something....
danpost danpost

2014/10/31

#
You could just use an Actor subclass to create the message -- something like that which is in the Marbles scenario.
Alwin_Gerrits Alwin_Gerrits

2014/10/31

#
True, I think just leaving JOptionPane might be better, but seen I'm using it allthroughout my game I don't think it will look well if I start using a differend looking panel all of the sudden. Thanks though danpost, I'll defiëntly keep it in mind for future projects.
You need to login to post a reply.