File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to check all check boxes at a click of a button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to check all check boxes at a click of a button" Watch "How to check all check boxes at a click of a button" New topic
Author

How to check all check boxes at a click of a button

Muhammad Salman
Greenhorn

Joined: Apr 11, 2012
Posts: 7
I am new to Swing, UI and MVC
I have created a code based on MVC. Now my problem is that that in the controller part i have an actioneventlistener which listens to different button clicks. Out of all those buttons i have "select all" and "de-select all". In my view i have a table, one of the column of that table contains "check boxes". Now, when i click the "select-all" button i want to check all the check boxes and with "de-select all" i want to uncheck all of them.

Below is my code which is not working. Please tell me what am i doing wrong here. Also, if someone knows a more elagent way please share. Thanks

In my view

Table Model


A Views Action Listener



Main Controller

Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
problem solving 101:

create a single column table to display checkBoxes (text optional)
add another button to the frame to "select-all"
add your attempt to the button's listener, and if it doesn't work,
you have a very small program to post here - one that has no
dependant classes we don't have.
Muhammad Salman
Greenhorn

Joined: Apr 11, 2012
Posts: 7
Michael Dunn wrote:problem solving 101:

create a single column table to display checkBoxes (text optional)
add another button to the frame to "select-all"
add your attempt to the button's listener, and if it doesn't work,
you have a very small program to post here - one that has no
dependant classes we don't have.


Ya, i understand the program looks quite huge but i have pasted it just for the sake of completeness and the problem i am facing has nothing to do with the whole code i have pasted. I will draw directions to where my program flows and where it does not do where i expect it do something.

So starting from :
1, CustomerSelectorUIListener, the actionEvent.equals( "selectAllButton" ) trigers controller.checkButtonControl(true)
2, In the Controller i have checkButtonControl (Boolean checkAll) which calls selectUI.PopulateAndShow(store, checkAll)

Now, in my View, CustomerSelectorDialogUI class a PopulateAndShow function is called and here things go wrong. So, this function looks something like. Please see the comment in the code (after the tModel= new TableModel(data))


m Korbel
Ranch Hand

Joined: Jun 19, 2012
Posts: 156
Crossposted
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
Thanks, another added to personal ignore list.
Muhammad Salman
Greenhorn

Joined: Apr 11, 2012
Posts: 7
Michael Dunn wrote:Thanks, another added to personal ignore list.


Ya, ya this is also a no-go area for you :P

Bytheway, whats so wrong with cross posting. If you guys here gurantee me results then i wouldnt cross post. DO YOU / CAN YOU ??
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10523
    
    9

Muhammad Salman wrote:
Michael Dunn wrote:Thanks, another added to personal ignore list.


Ya, ya this is also a no-go area for you :P

Bytheway, whats so wrong with cross posting. If you guys here gurantee me results then i wouldnt cross post. DO YOU / CAN YOU ??


Please KeepItDown
You can refer to https://www.coderanch.com/how-to/java/BeForthrightWhenCrossPostingToOtherSites to understand what we expect when you cross post.
 
Don't get me started about those stupid light bulbs.
 
subject: How to check all check boxes at a click of a button