Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2021 > unrolled thread

radioButton without radio

Started byWenj.Ma@gmail.com.remove-dii-this
First post2011-04-27 15:36 +0000
Last post2011-04-27 15:36 +0000
Articles 15 — 5 participants

Back to article view | Back to comp.lang.java.gui


Contents

  radioButton without radio Wenj.Ma@gmail.com.remove-dii-this - 2011-04-27 15:36 +0000
    Re: radioButton without r "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
      Re: radioButton without r Wenj.Ma@gmail.com.remove-dii-this - 2011-04-27 15:36 +0000
        Re: radioButton without r "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
          Re: radioButton without r Wenj.Ma@gmail.com.remove-dii-this - 2011-04-27 15:36 +0000
    Re: radioButton without r "tar" <tar@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
      Re: radioButton without r Wenj.Ma@gmail.com.remove-dii-this - 2011-04-27 15:36 +0000
        Re: radioButton without r "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
          Re: radioButton without r Wenj.Ma@gmail.com.remove-dii-this - 2011-04-27 15:36 +0000
            Re: radioButton without r "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
              Re: radioButton without r Wenj.Ma@gmail.com.remove-dii-this - 2011-04-27 15:36 +0000
                Re: radioButton without r "Lew" <lew@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
    Re: radioButton without r "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000
      Re: radioButton without r Wenj.Ma@gmail.com.remove-dii-this - 2011-04-27 15:36 +0000
        Re: radioButton without r "Roedy Green" <roedy.green@THRWHITE.remove-dii-this> - 2011-04-27 15:36 +0000

#2021 — radioButton without radio

FromWenj.Ma@gmail.com.remove-dii-this
Date2011-04-27 15:36 +0000
SubjectradioButton without radio
Message-ID<1184258210.682847.275140@g4g2000hsf.googlegroups.com>
  To: comp.lang.java.gui
Hi,

I want to create a group of buttons with radiobutton functionality
(exclusive to each other) but I don't want that radio in front of each
button. I want those buttons look like normal JButton. In addition, I
specify 2 colors for the button when selected and unselected. But I
don't know how to make one button use unselected color when another
button is pressed and this button got unselected by the radio button
logic.

I've add a group of JButton instances to the ButtonGroup and
addActionListener for user mouse press on one button and it got
selected, it runs but when another button is pressed, the previous
selected button still use the SELECT_COLOR, it can't change to
UNSELECT_COLOR.

How to do that?extend the buttonModel or radioButton / toggleButton?

Thanks

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [next] | [standalone]


#2023 — Re: radioButton without r

From"Roedy Green" <roedy.green@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<eqqc93l7vje5q30orauqcg7qgqh17qk049@4ax.com>
In reply to#2021
  To: comp.lang.java.gui
On Thu, 12 Jul 2007 16:36:50 -0000, "Wenj.Ma@gmail.com"
<Wenj.Ma@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>I've add a group of JButton instances to the ButtonGroup and
>addActionListener for user mouse press on one button and it got
>selected, it runs but when another button is pressed, the previous
>selected button still use the SELECT_COLOR, it can't change to
>UNSELECT_COLOR.

Have a look at the source code for Swing  JRadioButton in src.zip.

Also look at the code for JButton.  Possibly you will have to create a
subclass of JRadioButton that has a listener for ButtonGroup events to
do the colour changes.
 
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2024 — Re: radioButton without r

FromWenj.Ma@gmail.com.remove-dii-this
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<1184265402.871077.168320@o61g2000hsh.googlegroups.com>
In reply to#2023
  To: comp.lang.java.gui
Thanks Roedy, I've read the source of JRButton and ButtonGroup, I find
that I can change the uiClassID from "JRadioButtonUI"
to "JButtonUI" to let the RadioButton look like normal JButton. But
I'm not very familiar with define my own event and listener,
like you suggest to add listener for ButtonGroup events. Can you
please brief a little more about what kind of event and event
method I may be used ?
Many thanks.

Ray

> Have a look at the source code for Swing  JRadioButton in src.zip.
>
> Also look at the code for JButton.  Possibly you will have to create a
> subclass of JRadioButton that has a listener for ButtonGroup events to
> do the colour changes.
>
> --
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2030 — Re: radioButton without r

From"Roedy Green" <roedy.green@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<8jbd93lp0ss2sgf0v1i3k2lea79bkb01ac@4ax.com>
In reply to#2024
  To: comp.lang.java.gui
On Thu, 12 Jul 2007 18:36:42 -0000, "Wenj.Ma@gmail.com"
<Wenj.Ma@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>Thanks Roedy, I've read the source of JRButton and ButtonGroup, I find
>that I can change the uiClassID from "JRadioButtonUI"
>to "JButtonUI" to let the RadioButton look like normal JButton

To learn about the synthetic event approach, see
http://mindprod.com/jgloss/event11.html
Also have a look at the code for JRadioButton to see how the buttons
intercommunicate.


I had not thought of that. Why is that not a suitable solution?
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2031 — Re: radioButton without r

FromWenj.Ma@gmail.com.remove-dii-this
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<1184282810.249555.110770@o61g2000hsh.googlegroups.com>
In reply to#2030
  To: comp.lang.java.gui
On Jul 12, 3:44 pm, Roedy Green <see_webs...@mindprod.com.invalid>
wrote:
>
> I had not thought of that. Why is that not a suitable solution?
> --
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

What do you refer to by "that not a suitable solution"? What's "that"?
As I see it, RadioButtons only intercommunicate when you add them into
one ButtonGroup.
The source code of RButton doesn't show obvious clue for supporting
the inter commu. in its member methods.
All are handled in the ButtonGroup class, the
getSelection(); setSelected(Model,bool) may be responsible.

Ray

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2026 — Re: radioButton without r

From"tar" <tar@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<ymiejjdo385.fsf@sevak.isi.edu>
In reply to#2021
  To: comp.lang.java.gui
"Wenj.Ma@gmail.com" <Wenj.Ma@gmail.com> writes:

> Hi,
> 
> I want to create a group of buttons with radiobutton functionality
> (exclusive to each other) but I don't want that radio in front of each
> button. I want those buttons look like normal JButton.

Of course, the most fundamental question here is why you want to take a
familiar interface that all users understand and replace it with a new
one that works differently than they might expect.  Are you trying to
make your interface harder to use than it has to be?


-- 
Thomas A. Russ,  USC/Information Sciences Institute

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2028 — Re: radioButton without r

FromWenj.Ma@gmail.com.remove-dii-this
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<1184275755.408435.102380@q75g2000hsh.googlegroups.com>
In reply to#2026
  To: comp.lang.java.gui
On Jul 12, 12:02 pm, t...@sevak.isi.edu (Thomas A. Russ) wrote:

> Of course, the most fundamental question here is why you want to take a
> familiar interface that all users understand and replace it with a new
> one that works differently than they might expect.  Are you trying to
> make your interface harder to use than it has to be?
>
> --
> Thomas A. Russ,  USC/Information Sciences Institute

You should never try to guess the customers of a design. You assume
the software is used by public users while
it's always possible that the special user group want some feature
which may against the common
accepting standard. I suggest never try to type such question if you
don't know how to answer my technical question.

I've come up with a solution here.
define my new class:
ChangedRadioButton extends JRadioButton{

in constructor:
public ChangedRadioButton (){
   super();
   setModel(new ChangedRBModel());//force to use new ButtonModel
}

//define an inner class that extends that JToggleButtonModel used by
the JRadioButton
private class ChangedRBModel extends JToggleButtonModel{
   public void setSelected(boolean b){//try to override this method
        ....//copy code from JToggleButtonModel
         if(b)
             ChangedRadioButton.this.setBackground(colorSelected);
         else
             ChangedRadioButton.this.setBackground(colorUnselected);
   }
}

}//ends ChangedRadioButton class

This works because I guess when one radioButton of a group get
selected, rest buttons will call their ButtonModel.setSelected(false),
so the setBackground(color) line is called also.
However, if you try to add simple ActionListner or ItemListener, they
will listen to user input.
They won't get executed if another button in the group get selected
which require the previous selected button on which these Listener is
added get unselected.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2032 — Re: radioButton without r

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<7516b01a11372@uwe>
In reply to#2028
  To: comp.lang.java.gui
Wenj.Ma@gmail.com wrote:
>> Of course, the most fundamental question here is why you want to take a
>> familiar interface that all users understand and replace it with a new
..
>You should never try to guess the customers of a design. 

That would not be necessary if you had mentioned the 
user base in your initial post in this discussion forum.

>...You assume
>the software is used by public users while
>it's always possible that the special ...

'Special'?  What are they, autistic?

>...user group want some feature
>which may against the common
>accepting standard. ..

Note that users, 'special' or otherwise, have been known
for there "wouldn't it be a good idea if.." solutions that,
when they see them implemented, realise how unworkable/
ugly/trite they are.

>...I suggest never try to type such question if you
>don't know how to answer my technical question.

I suggest you never approach this discussion forum 
as if it were a help desk.  FTR - the technical goal is 
every bit up for discussion - always.  As well as (AFAIC)
the morality of the goal (but that is another story).

>I've come up with a solution here.

'This weeks' solution?  ;-)

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200707/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2042 — Re: radioButton without r

FromWenj.Ma@gmail.com.remove-dii-this
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<1184361712.586484.63790@q75g2000hsh.googlegroups.com>
In reply to#2032
  To: comp.lang.java.gui
On Jul 12, 6:54 pm, "Andrew Thompson" <u32984@uwe> wrote:

> I suggest you never approach this discussion forum
> as if it were a help desk.  FTR - the technical goal is
> every bit up for discussion - always.  As well as (AFAIC)
> the morality of the goal (but that is another story).
>
> >I've come up with a solution here.
>
> 'This weeks' solution?  ;-)
>
It is like a help desk, isn't it? All kinds of people ask and answer,
you have to prepare answer for hurried answer seeker without
questioning a lot.
If it's a more prefessional consulting desk, I won't spend time listen
to people questioning my purpose.

A day or week solution is better than nothing or trying to brag about
your ego trip of design to the customer and to force them follow
yours,yea : P

-Ray

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2046 — Re: radioButton without r

From"Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<75240d56e4e73@uwe>
In reply to#2042
  To: comp.lang.java.gui
Wenj.Ma@gmail.com wrote:
>> I suggest you never approach this discussion forum
>> as if it were a help desk.  FTR - the technical goal is
>[quoted text clipped - 4 lines]
>>
>> 'This weeks' solution?  ;-)
>
>It is like a help desk, isn't it? All kinds of people ask and answer,
>you have to prepare answer for hurried answer seeker without
>questioning a lot.

It is also 'like a help desk' in the same way it is 'like a book',
all three contain words.  OTOH It is neither a book nor a help 
desk, it is a discussion forum.  That a great deal of 'help' is 
dispensed here, freely, is simply a happy side effect.

Note how your eventual solution involved JToggleButton.
I doubt you would have arrived at that solution without the 
initial challenge.

And as an aside..
>If it's a more prefessional consulting desk, ..

It is a discussion forum - like I said.

>...I won't spend time listen
>to people questioning my purpose.

Fine.  When your paying, you can take that immature 
attitude, and end up paying twice as much (when the 
first "don't question my requirement" solution is rejected 
by the users.)  I'm sure some of those who run the 
commercial help desks & consultancise would love that 
type of customer.  Lots of return business!

OTOH - when your *not* paying, what should motivate
us to.. *spend* *time* *listenning* *to* *you* telling us 
details are *none* of our *business*?

>A day or week solution is better than nothing or trying to brag about
>your ego trip of design to the customer and to force them follow
>yours,yea : P

I do not unserstand why you are suddenly beating 
yourself up - but then - I do not understand that 
sentence, or your generally defensive attitude.

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200707/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2062 — Re: radioButton without r

FromWenj.Ma@gmail.com.remove-dii-this
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<1184456119.632744.227820@x35g2000prf.googlegroups.com>
In reply to#2046
  To: comp.lang.java.gui
On Jul 13, 8:25 pm, "Andrew Thompson" <u32984@uwe> wrote:

> Fine.  When your paying, you can take that immature
> attitude, and end up paying twice as much

Does it make any difference that I tell you "My customer is such such
and I'm requested for an unusual design... " or "I just want a design
that's unusual", if the turn-out is you know nothing about how to
answer it?

>I do not understand that
> sentence, or your generally defensive attitude.

As I indicate repeatedly, this's exactly my customer's require and has
proved effective. Trying to persuade them to use standard LaF is
beating yourself up. Or maybe not for generally quisitive and wordy
person.

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2063 — Re: radioButton without r

From"Lew" <lew@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<WM-dnWVdop8x5gTbnZ2dnUVZ_hninZ2d@comcast.com>
In reply to#2062
  To: comp.lang.java.gui
Wenj.Ma@gmail.com wrote:
> On Jul 13, 8:25 pm, "Andrew Thompson" <u32984@uwe> wrote:
> 
>> Fine.  When your paying, you can take that immature
>> attitude, and end up paying twice as much
> 
> Does it make any difference that I tell you "My customer is such such
> and I'm requested for an unusual design... " or "I just want a design
> that's unusual", if the turn-out is you know nothing about how to
> answer it?
> 
>> I do not understand that
>> sentence, or your generally defensive attitude.
> 
> As I indicate repeatedly, this's exactly my customer's require and has
> proved effective. Trying to persuade them to use standard LaF is
> beating yourself up. Or maybe not for generally quisitive [sic] and wordy
> person.

Gee, whillikers, Wenj, take a chill pill.  This is a discussion group and 
we're not in your customer's pay.  You introduce a topic, we discuss it. 
Sometimes we ask questions.  We aren't limited to the narrow view that your 
customer demands.  That's Usenet.  If you don't like it, this is the wrong 
forum for you.

-- 
Lew

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2033 — Re: radioButton without r

From"Roedy Green" <roedy.green@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<lgod93d1rp0mjns58pi7t3458l6k21qa6t@4ax.com>
In reply to#2021
  To: comp.lang.java.gui
On Thu, 12 Jul 2007 16:36:50 -0000, "Wenj.Ma@gmail.com"
<Wenj.Ma@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>
>I want to create a group of buttons with radiobutton functionality

Have you considered a set of JToggleButtons and a ButtonGroup?
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2034 — Re: radioButton without r

FromWenj.Ma@gmail.com.remove-dii-this
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<1184332417.696506.284890@w3g2000hsg.googlegroups.com>
In reply to#2033
  To: comp.lang.java.gui

> >I want to create a group of buttons with radiobutton functionality
>
> Have you considered a set of JToggleButtons and a ButtonGroup?
> --
> Roedy Green Canadian Mind Products
> The Java Glossaryhttp://mindprod.com

The reason I don't use JToggleButton is that the toggle has two states
and associate with two appearances.
When click and selected, it's hightlighted, second click will
disselect and unhighlight. But our need is when
click it's always selected, acting like a normal button.

Ray

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [next] | [standalone]


#2036 — Re: radioButton without r

From"Roedy Green" <roedy.green@THRWHITE.remove-dii-this>
Date2011-04-27 15:36 +0000
SubjectRe: radioButton without r
Message-ID<249f93pfa6p6st935v1ar6lnln476qe969@4ax.com>
In reply to#2034
  To: comp.lang.java.gui
On Fri, 13 Jul 2007 13:13:37 -0000, "Wenj.Ma@gmail.com"
<Wenj.Ma@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>The reason I don't use JToggleButton is that the toggle has two states
>and associate with two appearances.
>When click and selected, it's hightlighted, second click will
>disselect and unhighlight. But our need is when
>click it's always selected, acting like a normal button.

You can provide almost a dozen variant icons to use to represent a
button to indicate its state.  That might be helpful.  I have not
followed exactly how this system is supposed to behave.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.java.gui


csiph-web