Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (536)
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 3058 times)
0 Members and 1 Guest are viewing this topic.
Offline 666DemonThe

Senior 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

Senior Member


Medals: 7


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

Senior 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!
Legends of Yore - The Casual Retro Roguelike
Online ra4king

JGO Kernel


Medals: 341
Projects: 2
Exp: 5 years


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

Senior Member


Medals: 7


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?

Online ra4king

JGO Kernel


Medals: 341
Projects: 2
Exp: 5 years


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

Senior Member


Medals: 7


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

Online ra4king

JGO Kernel


Medals: 341
Projects: 2
Exp: 5 years


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
Online ra4king

JGO Kernel


Medals: 341
Projects: 2
Exp: 5 years


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

Senior Member


Medals: 7


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

Senior 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

Senior Member


Medals: 7


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?

Online ra4king

JGO Kernel


Medals: 341
Projects: 2
Exp: 5 years


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.

 

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

The first screenshot will be displayed as a thumbnail.

CogWheelz (11 views)
2014-07-30 21:08:39

Riven (21 views)
2014-07-29 18:09:19

Riven (14 views)
2014-07-29 18:08:52

Dwinin (12 views)
2014-07-29 10:59:34

E.R. Fleming (32 views)
2014-07-29 03:07:13

E.R. Fleming (12 views)
2014-07-29 03:06:25

pw (42 views)
2014-07-24 01:59:36

Riven (42 views)
2014-07-23 21:16:32

Riven (29 views)
2014-07-23 21:07:15

Riven (30 views)
2014-07-23 20:56:16
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
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!