Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Both of your returns are in conditional statements. The compiler requires a guaranteed return value for all possible conditions.

Add a default return value at the end to cover the case of your other conditions not being satisfied.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, you're just putting the text of the selected checkboxes into your array. With a fixed size array though, the filter array will contain nulls in the slots that correspond to the unselected fields.

So if only box "1" and "3" is selected your array will contain ["1",null,"3",null,null...]. That is why I mentioned that you may want to add the fields to another list instead, so you don't have the nulls to mess with.

I can't make more specific suggestions because I don't know how you are actually using that filter against the Excel files.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Basically all you are needing to do is

for(int i=0; i<checkList.size(); i++)                {
    JCheckBox cb = checkList.get(i);
    // if cb.isSelected() add cb.getText() to some list or array
}

I don't think you need to do that in your listener unless you are updating the results immediately as the user checks the boxes. You said your were extracting data from Excel, so I assumed the user made their choices and then hit "Go" or whatever. You can produce the list when they hit "Go".

I would actually recommend adding the field names to another List or Set instead of a fixed size array that will contain some nulls.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Several things here:

String[] filter = null;

You have to actually initialize the array before you can use it,

String[] filter = new String[size]; // proabably same size as number of checkboxes?

Not sure what you are trying to do with this

evt.getActionCommand().equals(checkList)

Comparing a string to an ArrayList?

Also can't figure what Check is here

Check.isSelected()

but you need to get() each checkbox from the checkList in your loop.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You already have a File object from the open dialog, so use file.getPath() instead of file.getName().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Those are the string representations of the components themselves.

You need to use the textfield.getText() or combobox.getSelectedItem() to access the values they contain.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I was doing some reading today as well and saw a reference to another layout GroupLayout?

I would not recommend trying to work with GroupLayout without a GUI designer. It's even more complex than GridBagLayout.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Basically, yes, with some syntax correction. Is your search filter an array or a string that you pass to HSSF?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not following what you mean with arrays and splitting anything. You simply need to supply the full path to the file.

c:/whateverDir/whateverFile.xls
//someNetworkLocation/whateverDir/whateverFile.xls
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That's fine. You'll just need to supply the full path to the resource in that case.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Post the exact error message.

Edit: Nevermind. Check your spelling of JCheckBox.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yeah, that's simply a path error. You'll need to supply a full path to the file unless it's in a sub-directory of your program folder.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you using Java 1.5 or later? Did you add List and ArrayList to your imports?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If the path of the filename cannot be found relative to the directory in which the program is executing, you'll need to provide a more complete path to the file. You didn't post the error message, but it sounds like a FileNotFoundException?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

GridLayout maintains equally sized grid cells along the horizontal and vertical. If you need to vary the size of the cells, you'll need to subdivide your layout into multiple panels with their own groups of controls or use a GridBagLayout.

GridBagLayout is a lot more flexible, but it's also much more complex and comes with a bit of a learning curve.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The way you create the boxes wouldn't change, you'd just need to create a list in your class to hold them

List<JCheckBox> checkList = new ArrayList<JCheckBox>();

and when you're adding them to the form (before/after, doesn't matter), add them to your list as well

checkList.add(checkBox);
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Looks to me like you just want to set the text of your text fields back to zero or empty. You can just call setText(String) on each of them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The state of the flags can be stored in a Map such as

Map<String, Boolean> filterMap = new HashMap<String, Boolean>();

Your listener just needs to set the value for that filter field option to true or false based on whether the box is checked

public void actionPerformed(ActionEvent e) {
        filterMap.put(e.getActionCommand(), ((JCheckBox)e.getSource()).isSelected());
    }

The method that actually builds the actual search string for Excel just needs to iterate the map and add the fields that are set to true. The ones that are false or not in the map at all don't matter.

Alternately, you could just add all of the JCheckBox components themselves to a List as you create them and iterate that list to build your filter string based on isSelected().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Regex.
Edit: Sorry, cross-posted. ^^ What he said.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your listener just needs to call repaint(). That will trigger a call to your paintComponent() method on the event dispatch thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can add a repaint() call right after you update your path.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, that means you haven't put in any code to handle the exceptions from new FileOutputStream . You need to put a try-catch block around that code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

One option would be to use a single listener for all of the check boxes to toggle values in a HashMap<String,Boolean> when they are checked/unchecked. You can then build your Excel filter criteria from the "true" values in that map.

class FilterCheckAction extends AbstractAction{
            public void actionPerformed(ActionEvent e) {
                filterMap.put(e.getActionCommand(), ((JCheckBox)e.getSource()).isSelected());
            }
        }
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Please post the entire error. The stack trace is much more useful than "an error".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No. If you're too lazy to Google such a basic concept, why should someone else put forth the time to spoonfeed it to you?

If you have acutal questions, after putting in the slightest effort yourself, post them here with whatever code you have started with.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I already have code of my own to write here at work. Give it a go and if you have more questions post them here with your code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In your listener, you can get a reference to the clicked object with e.getSource() , which you can then cast to JCheckBox . You can toggle your variable values based on JCheckBox.isSelected() .

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Lucky guess I suppose ;)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I guess that would depend on what the error was...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Oh, you got the hard one. The easier one asks what color his brown horse was...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Use an ActionListener instead of ChangeListener for your buttons. You can pass the color you wish to change to as a parameter to your setSampleColor() method. Set the panel background to that color before repaint.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Both download and open just fine for me.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Make sure the name of your file is "NestedNumber.java".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look through the methods on the Character class as well. You may find something useful.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You don't necessarily need to create a new InputMap, you could use the existing for the component. Either way, you need to map the actions for those events now. That is what the action map is for. So for your "UP" action mapping you would have something like the following

board.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke((KeyEvent.VK_UP), 0, false), "UP");
board.getActionMap().put("UP",
     new AbstractAction() {
        public void actionPerformed(ActionEvent e) {
                // Whatever you need to do on UP
                System.out.println("UP");
            }
        });
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You didn't provide CollegeMember with a zero-argument constructor, which your Lecturer constructors are trying to call implicitly.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're trying to access the third element of array[] and it doesn't have that many elements. Don't do that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

i just don't know how to use color constructor

Just remove this line

public void Color(int r,int g,int b);

and this line

c = Color.magenta;

Your initial declaration is just fine.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can read some explanation about the R class in this tutorial for Hello World on Android.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Just below the text "Has this thread been answered?" there is a link to "Mark this Thread as Solved".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Moving to JavaScript.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This was already answered in the OP's other thread for the same question but he chose to ignore the answers:
http://www.daniweb.com/software-development/java/threads/384210/1654757#post1654757

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Actually, on line 93 you are declaring a new variable "stkBean" which immediately goes out of scope in your loop.

StkBean stkBean = new StkBean();

Remove the declaration from that and just assign the new instance to your class-level stkBean reference.

Your current code is still using the single instance of stkBean that you initialized at declaration.

Alternately, you could move line 93 up to the beginning of the loop and do away with the class-level variable altogether. You don't have any use for stkBean other than adding to the arraylist.

while (results.next() )
            {
                StkBean stkBean = new StkBean();   
                //myList.add((results.getString(1)).trim() );
                stkBean.setStkSymbol(results.getString((1)).trim () );                
                stkBean.setCompanyName(results.getString((2)).trim() );
                stkList.add(stkBean);
             
            }//end do-while

Edit: Also, you may want to either override toString() in your StkBean class or print one of the properties like getCompanyName() in your option list output.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you creating a new StkBean each iteration of your loop to add to the array list?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You don't want to create a new Date to compare to "d". You want to use the current instance value.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, you declared the variable on line 27, but you haven't actually initialized it prior to using it. You still have to create an instance of new StkBean() before you can assign any values to it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I don't see where you have initialized "stkBean" prior to that line.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm not really certain what the question even is. It just sounded vaguely like he was asking for some kind of installer.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could use IzPack to create an installer for your program.