Hosted By

Contact Me

Misc Links

OpenNTF BlogSphere LotusGeek CoComment Custom Button

Ads by Google

Welcome to keithstric.com!

I hope you find this site useful in some way or another. I strive to bring you all sorts of geeky information and solutions to your most frustrating of issues with the occasional rant on whatever topic, technical reviews and weblog. You'll also find many products that I've developed and make available for you to use however you like. So, grab a cup of coffee, sit down and visit for a while.

« Kenny Chesney Concert | Home Page| IBM Joins OpenOffice.org Community »

SnTT: Java Method for building a checkbox dialog

09/10/2007 11:25 AM By Keith Strickland

Like I said earlier, I've been messing with Java more and more here lately, mainly to build graphs using JFree Chart. In just about every statistics report I'm doing I provide a checkbox for the user to select what data they want to display. So, I've built a Java Method/Function whatever you want to call it, that will simplify the task of putting a JCheckboxes in a JPanel with an instruction label and footer text with OK and Cancel buttons (See Screenshot).

constCheckBox-Java.jpg

The idea here is to build an array of strings, determine a window title, label text and if needed footer text and pass that to the method which will then loop through the array and build the JPanel according to the information you pass. you can see the example here. The constCheckBox method will then spit out a dialog which should look something like the one above. One of the stipulations of this thing is that the "chkBoxes" variable (from the sample code) has to be declared as a global variable something like "JCheckBox chkBoxes[];" above the notes main section.

OK, so I can't post the code , it's too big to post all the HTML for the formatting and stuff . So, it's available over in the downloads section

So hopefully this will be of use to someone other than myself. I know I didn't go into much explanation of the actual code I think I mainly posted it as a reference to myself to see how to do this sort of thing in the future as I imagine this kind of functionality is used quite often. I kinda like this Java stuff, it's starting to make more sense .

Keith

Post A Comment

:-D:-o:-p:-(:-):-\:-|:angry::cool::cry::dontknow::emb::hairout::laugh::rolleyes::whew:;-)

Subscribe to keithstric.com

OpenNTF

Disclaimer

The opinions and ideas posted on keithstric.com are not necessarily the opinions and ideas of my employer. The solutions, techniques and code provided here are not guaranteed or warranted in any way and are free for you to use at your own risk.