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

Yes, that was the intention for the small custom class I mentioned above, in case I wasn't very clear.

class PaintShape{
   Shape shape;
   Color color;
... // etc
}

and a list of those

LinkedList<PaintShape> shapeList = new LinkedList<PaintShape>();
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You could make your own PaintShape class that contains a Shape reference and those two properties. You can pass all of the info through the constructor and access it as you loop through your shapes in the paintComponent() method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look at lines 24 and 25, then consider what will happen with those values in your loop condition on line 27.

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

Close. You need to call the methods on your variable 'myCircle' instead of the class. You should set the radius on your circle variable too. You do not need a separate radius property for the Cylinder.

The basic idea is to let the circle variable handle all of the data and methods that you were previously inheriting. If you need to get that data, you simply ask the circle for it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

To use composition in Cylinder, you would add a Circle instance variable instead of extending Circle. When you need any circle info, you make the calls on your circle reference instead of inherited methods. So for example, where are calling findArea() in the findVolumne() method, you would instead call circle.findArea() .

You may need to expose new method on the Cylinder class to set properties of the circle.

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

Ask this guy what he found with Google: http://www.daniweb.com/software-development/java/threads/395869/1698277#post1698277

After that, post your code and ask specific questions about what you are having difficulties with.

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

It might help if you noted which line was 75 in your file, since you only posted 38 lines of code.

diafol commented: ha ha ha +14
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

As I said in my previous post: mind the scope of your "listener" variable. The one that you are creating on line 50 is only in scope in that method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Check the scope of your 'listener' variable where you are initializing it. Your listener is not being called at all.

After that is corrected, you need to figure out how to specify the color, because there is no Color constructor for the name of the color.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Another alternate would be to drop the if() statements altogether and give the color information to your listener object when you create it:

private class ColorListener implements ActionListener {
        private Color color;

        public ColorListener(Color color) {
            this.color = color;
        }

        public void actionPerformed(ActionEvent e) {
            colorPanel.setBackground(color);
        }
    }

adding to the buttons like so

redButton.addActionListener(new ColorListener(Color.RED));
        greenButton.addActionListener(new ColorListener(Color.GREEN));
        blueButton.addActionListener(new ColorListener(Color.BLUE));
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Lucky guess I suppose ;)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It depends on the database that you are using. Different databases have different ways of dealing with auto-incremented keys like that.

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

3 separate threads for this single question merged. Apologies for some slight discontinuity, but if ERINY hadn't decided to string this out so much it would be more linear.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I'm with James. I hate the first method.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to have a guaranteed return value. Currently all of your returns are dependent on one of the if() clauses being true. If none of them end up true, there is no final return.

If you put a default return at the end of the method, you will make the compiler happy that all of the cases are covered.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Which part is confusing you? What have you tried? What have you thought about trying?

From the forum rules:
Do provide evidence of having done some work yourself if posting questions from school or work assignments

Simply dumping your assignment here is not evidence of effort.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

That was not my question.

How many times will your current code execute if the user enters 1.

Trace that value through your code.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

How many times will your input do-while loop execute if selection is 1?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's fairly easy to trace manually. Run through it assuming an entry of 1.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look at where your while() condition is located. Now trace through what your program will do if input is 1-6.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

MySql is a database, not a user interface. A drop-down box is an interface component.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You're going to have to show more effort than that if you expect any help.

Ask specific questions about the parts you are struggling with.

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

You could use the Graphics2D.scale() method, which scales the entire graphics transform or you can just add a scale multiplier to all of the dimensions of your drawn objects. You'll probably want to use a float for the scaling factor.

I'd also recommend using a JPanel and overriding paintComponent() for your drawing. Painting directly to the JFrame with getGraphics() is too transient. You'll lose your graphics any time the system needs to re-render a portion of the window, such as resizing, etc.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Add e.printStackTrace(); in your catch block, so you can see more details of the error.

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

It's a British thing ;)

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, the only relevant part you have is

import java.io.*;

in = new BufferedReader(new FileReader(new File(filename)));

These may help:
ReadLinesFromFile
Regex tutorial

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, the method will operate on whatever data array you have passed it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

This forum is for helping those who have questions. It's not a code-on-demand service. If you have specific questions or a css you need help with, post them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Nope. Re-read your notes. You've been told exactly what data the class will hold. It's trivial to at least start a skeletal attempt with that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You need to check equality with "==". "=" is for assignment.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

NormR1 and Stultuske have it spot on.

Closing this thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should make a Fibonacci series generator. It will definitely get you noticed.

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");
            }
        });