The Artima Developer Community
Sponsored Link

Java Answers Forum
circular buttons

8 replies on 1 page. Most recent reply: Jun 18, 2009 12:46 AM by saksham kum

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 8 replies on 1 page
Tapan kumar Rath

Posts: 18
Nickname: papuni
Registered: Sep, 2005

circular buttons Posted: Dec 9, 2005 12:41 AM
Reply to this message Reply
Advertisement
Hi
I want 20 circular buttons in my application.The buttons would perform different actions.I would like to pass the color and text to be displayed as arguments to the buttons.
Any Ideas.


Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: circular buttons Posted: Dec 9, 2005 2:35 AM
Reply to this message Reply
Swing or a Web App? Radio Buttons or Actual Buttons
like the one you see when you hit Submit?

If a Web App, is it an Applet or would you like
to use the ones supplied with HTML?

Tapan kumar Rath

Posts: 18
Nickname: papuni
Registered: Sep, 2005

Re: circular buttons Posted: Dec 9, 2005 5:04 AM
Reply to this message Reply
I meant Swing Application.

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: circular buttons Posted: Dec 9, 2005 5:17 AM
Reply to this message Reply
Still don't know if you mean RadioButtons or Actual Buttons.
But here is a possiblity:

JButton someButton = new JButton("Button A");
 
public void setButtonColor(Color color){
    someButton.setBackground(color);
}

or with JRadioButtons you will have:
JRadioButton someButton = new JRadioButton("Button A");
public void setButtonColor(Color color){
    someButton.setForeground(color);
    //  or you could also set background
}

Kondwani Mkandawire

Posts: 530
Nickname: spike
Registered: Aug, 2004

Re: circular buttons Posted: Dec 9, 2005 5:20 AM
Reply to this message Reply
Ooops sorry for the text you just write another method
(or may do it in the same method Just add the second
parameter as a String:
public void setText(String text){
   someButton.setText(text);
}

or in the Same Method:
public void setColorAndText(Color color, String text){
someButton.setBackground(color);
someButton.setText(text);
}
[/java]

Tapan kumar Rath

Posts: 18
Nickname: papuni
Registered: Sep, 2005

Re: circular buttons Posted: Dec 9, 2005 8:06 PM
Reply to this message Reply
I don't need radio buttons.It might be regular buttons or something else which looks circular in shape,border is raised, but functions like a button.I have a vogue idea that I would have to draw a circle on a canvas.I would add appropriate event listeners to it to make it work like a button.Finally I would add it to my JFrame.
Or is there any easy way out.

Matthias Neumair

Posts: 660
Nickname: neumi
Registered: Sep, 2003

Re: circular buttons Posted: Dec 12, 2005 12:14 AM
Reply to this message Reply
Create a class wich extends JButton and overwrites the paint-Method.

Tapan kumar Rath

Posts: 18
Nickname: papuni
Registered: Sep, 2005

Re: circular buttons Posted: Dec 20, 2005 12:17 AM
Reply to this message Reply
Thanks Matthias and all who replied.It's working.

saksham kum

Posts: 1
Nickname: sakshamkum
Registered: Jun, 2009

Re: circular buttons Posted: Jun 18, 2009 12:46 AM
Reply to this message Reply
Hi,
I am trying to do the same.
I have read the replies but what exactly to do?

How can I change the shape by overwriting the paint() method?

Flat View: This topic has 8 replies on 1 page
Topic: How to get resultant page in different frame using JSF component Previous Topic   Next Topic Topic: JComboBox Listener problem

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use