Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (407)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Strings into buttons ???  (Read 1596 times)
0 Members and 1 Guest are viewing this topic.
Offline 666DemonThe

Junior Newbie





« Posted 2012-04-14 11:44:08 »

can someone tell me how to make string button ?
i have tried  Sad  but it is not working  Huh  please help
Offline _Al3x

JGO Coder


Medals: 7
Projects: 1


Indie Games FTW!


« Reply #1 - Posted 2012-04-14 16:41:46 »

Hello and welcome to JGO Smiley !

Are you working in Java2D?
Did you implemented a button? How?
Are you using Swing?

As you can imagine, there are thousands of ways to do anything, you need to narrow us the posibilities. Please provide more info, because it's just imposible to help you out from what you said Sad

Offline 666DemonThe

Junior Newbie





« Reply #2 - Posted 2012-04-14 16:44:59 »

Do you know What strings are ?
if you do i joust want to make a string to be a button ?
can yo help me ?
Games published by our own members! Check 'em out!
Try the Free Demo of Titan Attacks
Offline ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #3 - Posted 2012-04-14 16:48:50 »

Your question is extremely vague. Are you using Swing?

Offline Fokusas

Senior Member


Medals: 3
Projects: 1



« Reply #4 - Posted 2012-04-14 16:55:56 »

I think he doesn't know what is swing  Grin. What I have read i understood that he may just render string on screen and want that it would work like button (be clickable and so on)  Smiley
Offline _Al3x

JGO Coder


Medals: 7
Projects: 1


Indie Games FTW!


« Reply #5 - Posted 2012-04-14 16:59:17 »

I do know what strings are my friend Smiley

Maybe you want to make a link in the forum?

Like this one

By the way, is it too difficult to give us more info?

Is your game 2d or 3d? What libraries are you working on?

Offline ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #6 - Posted 2012-04-14 17:14:52 »

Maybe he wants to make a button on a string:


Grin

Offline _Al3x

JGO Coder


Medals: 7
Projects: 1


Indie Games FTW!


« Reply #7 - Posted 2012-04-14 17:18:34 »

You're RIGHT!

It's the string INTO the button! I mean, multiple buttons!

Jokes apart, please don't take us wrong, we really want to help you! But we need more info to help you out, that's all friend Smiley

Offline ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #8 - Posted 2012-04-14 17:29:23 »

Yup, this is how you put strings into buttons:

Offline Fokusas

Senior Member


Medals: 3
Projects: 1



« Reply #9 - Posted 2012-04-14 17:37:10 »

Yup, this is how you put strings into buttons:

I like where this thread go  Grin Grin Grin Grin Grin Grin Grin Grin Grin Grin Grin  Smiley Cheesy Grin Grin Grin Grin Grin Grin
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #10 - Posted 2012-04-14 17:40:11 »

In all seriousness, I am poking fun because the OP asked super vague questions, doubted our knowledge of strings, and has yet to reply. I am smelling either a troll or a super n00by n00b.

Offline _Al3x

JGO Coder


Medals: 7
Projects: 1


Indie Games FTW!


« Reply #11 - Posted 2012-04-14 17:47:30 »

Let's be nice with super n00by noobs, because all have been one when we first started Smiley

By the way, threds into buttons anyone?

Offline 666DemonThe

Junior Newbie





« Reply #12 - Posted 2012-04-14 22:53:57 »

If you dont wont to help me thx a lot

did you played minicraft ?
not minecraft
minicraft
that kind of button or
joust img button !
Offline _Al3x

JGO Coder


Medals: 7
Projects: 1


Indie Games FTW!


« Reply #13 - Posted 2012-04-14 23:16:30 »

Yey! more info!

Do you use the mouse to press the button? Or the keyboard? Smiley

If you use the mouse, you need a mouse listener and in the onClick event check the coordinates and see if they are within the button.

If you use the keyboard, the approach is different, you could do some kind of variable that holds which button is "active" and the arrows will cycle between each of them, then, in the keyboard listener, check if the Enter key is pressed and activate the button that is active.

Did this help a bit? We can move forward now we have more info Cheesy

By the way, check at my game:

Although it uses the mouse (that isn't drawn in the screenshot >_<), is this what you aim to do?

Offline ra4king

JGO Kernel


Medals: 264
Projects: 2


I'm the King!


« Reply #14 - Posted 2012-04-14 23:21:45 »

There was no use of the mouse in Minicraft at all. You just want buttons that you can hit 'ENTER' on? If so, then simply have a variable that contains the currently highlighted String, and update it when a key is pressed.

EDIT:
Do you use the mouse to press the button? Or the keyboard? Smiley

If you use the mouse, you need a mouse listener and in the onClick event check the coordinates and see if they are within the button.
Minicraft uses the keyboard. And it's mouseClicked not onClick Tongue

Offline ReBirth
« Reply #15 - Posted 2012-04-15 05:13:57 »

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
String[] MENUS = {"NEW GAME", "EXIT"};
...
//on your keyPressed method
if (e == KeyEvent.UP) index++;
else if (e == KeyEvent.DOWN) index--;
else if (e == KeyEvent.SPACE){
    if (index == 1) newGame();
    else if (index == 2) System.exit(0);
}
//on your draw
for (int i=0; i<MENUS.length; i++){
   g.setColor(Color.white);
   if (i == index) g.setColor(Color.yellow);
   g.drawString(MENUS[i], x, y, null);
}

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (98 views)
2013-05-17 21:29:12

alaslipknot (106 views)
2013-05-16 21:24:48

gouessej (136 views)
2013-05-16 00:53:38

gouessej (131 views)
2013-05-16 00:17:58

theagentd (143 views)
2013-05-15 15:01:13

theagentd (129 views)
2013-05-15 15:00:54

StreetDoggy (172 views)
2013-05-14 15:56:26

kutucuk (194 views)
2013-05-12 17:10:36

kutucuk (196 views)
2013-05-12 15:36:09

UnluckyDevil (202 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.087 seconds with 21 queries.