Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are no daily limits to the number of simple up/down votes by clicking the arrows, but you can only add reputation to a particular user once per day.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Moving to mySql forum.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

As James said, you can associated various information with the buttons by setting property values on them.

There are also other ways to associate various actions with the buttons, but we can't really give you specific suggestions because you still have never said what you need to do when the button is clicked. All you will say is "I need to know which button is clicked". Well, you've been told the answer to that. Obviously, you need to do something else with that information, but if you won't explain further then no one can help much more.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

MouseEvent.getSource() returns the Object that was clicked. You can cast that to object to JButton.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Then the getSource() method on the mouse event will tell you.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Most likely the loops are unnecessary. Depending on what the OP needs to do when the button is clicked, there are many ways to attach data or specific actions to a button.

More info is needed about the intent of the buttons.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take care to use the correct operator. '==' is for comparison.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Im not a techy, nor do I pretend to be, I really need a kind person who will put the problem into a java application. )

Im a girl in desperation !

You're also a girl violating the forum rule about showing effort if you expect help with homework assigments.

If you can't show that you have made the slightest effort yourself, this thread will be closed. Post code, psuedocode, or at least specific questions that might indicate you are anything other than another lazy student wanting others to do their assignment for them.

Ball is in your court.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look up JFreechart.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Are you running a 64-bit JVM trying to connect to a 32-bit Access installation?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You really only need the "%.2f" part. You can read all about the formatting options here: http://docs.oracle.com/javase/6/docs/api/java/util/Formatter.html#syntax

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can use the String.format() method to apply those formats.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sure, you could probably have thousands without an issue. It depends on how much memory you allow the VM to take and the size of your objects, but 100 certainly won't be a problem.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It sounds to me like he just wants you to save them in memory in an array.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

> Well its just a question
And I just attempted to explain. You didn't bother to answer my questions about the errors you received, so I can't really clarify why you received them.

Majestics commented: Want your autograph +8
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Were you defining those at the class level or in a method? Static declarations like that only apply at the class level.

I'm guessing you got error 2 with statement C? C is not valid syntax.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Say you finish asking a question...

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

The first is standard shortcut syntax for the creation and initialization of an array in the same statement it is declared.

The second is using a static code block to create and initialize.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you wish to access the method without an instance of your WordRepeater class, you will need to declare the tester method 'static'.

public static boolean tester (...
Genericusername commented: Prompt, Helpful, and Concise +1
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You don't need to set the background in paint(). You can set it in the constructor once and it will persist.

You specifically do not want to override the paint() method like that because you are preventing the labels from being rendered at all. In Swing components, you should override paintComponent() if you need to provide custom rendering.

Just remove the paint method declaration altogether and move your background call up to where you are adding the other components and see if that gets you where you want to be.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, as Norm said, you do not need to create those arrays in the method call. I merely did that as a quick example in your other thread. That signature is actually

createCategoryDataset(java.lang.Comparable[] rowKeys, java.lang.Comparable[] columnKeys, double[][] data)

The arrays do not even necessarily have to be String[].

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, you can use this method to create any series and category labels you want

final CategoryDataset dataset = DatasetUtilities.createCategoryDataset(
            new String[]{"a","b","c"}, new String[]{"bob","mary","sue"}, data
        );

That produces data series a,b,c and the domain categories bob,mary,sue along the x-axis.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's your dataset. You have created it with those values (category,value) .

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Your domain axis (x-axis) should display the categories you've supplied. It's not a range of values, it's a discrete set.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look over the APIs for those two classes. There are methods to print new lines.

BufferedWriter is another option.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can use PrintWriter or FileWriter for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can mark a thread solved by clicking the "Mark This Thread As Solved" link at the bottom. Others can still post in the thread.

Only a moderator can actually close a thread.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Yes, if you need to print them then just loop through the collection and print each.

I would point out that printing them to the console doesn't really have anything to do with reading them. I'd make a separate method for output to maintain a separation of responsibilities. readData() should just read data.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

So your console output class has no method to print out an entire ArrayList. You'll need to iterate through the list and print each element then.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You would want to define the list outside of your loop, since you will add to it each line read.

You'd need to clarify "errors" a bit if you want more advice on that one.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"Split" how? If you just need to store each line separately, use an ArrayList.

If you need to further split up multiple words in a line, look at String.split().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What you have written there should read multiple lines just fine, but you're replacing 'words' each time, so it is going to end up null at the end.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Well, I imagine that one of the administrators can help you out with that, but none are online right at the moment. You'll have to hang tight for a bit.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Important to you or the teacher you registered to impersonate?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

There are two pieces to consider with an array: the array object itself and the contents of the array.

Let's look at the one that is just fine:
You declared a variable of type String[] called 'units'

String[] units

and you create it to hold 40 elements

units = new String[40]

and then you initialize the elements themselves to empty strings

units[i] = ""

That is fine and good. One of those steps is missing however for your ingredientName array. That is what I described above in my previous post.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

whitespace? I'm saying you have a variable that you declared but never initialized at all. You've written private String[] ingredientName , but you never sized it. The "," you've used does not make all of your variables share that = new String[40]; (which is one more reason why it's just not a good idea to declare multiple variables on a single line)


You're attempting to access elements of something that is completely null.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You can implement as many interfaces as you like. You could also write a separate inner class for your mouse listener, or you could use an anonymous inner class declaration

preCrypTxt.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseEntered(MouseEvent e) {
        ...
    }
});
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You would use a mouse listener for that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Try getContentPane().setBackground(Color.BLUE);

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

'ingredientName' is still null when you get to that loop.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You have not initialized all of your arrays.

Also, you don't need to use String constructor directly like this new String("") . Just use the literal ""

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Direction is the enumeration class. You need to switch on a variable that holds the direction.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

It's not much shorter, but to specify exactly three digits you can use \d{3} instead of \d\d\d . Not much difference for just three, but 43 would be a different story :).

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Since "\" is itself an escape character in strings, you have to escape them as well "\\".

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

At the bottom of the page, there is a section "Has this thread been answered?" and a link to "Mark this thread as solved". Simply click that link.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Good question. Did it solve the problem? Does the method do what you intend?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Look up the return type of ArrayList.add(). Why are you trying to assign that to your ArrayList variable?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Basically, you just need to set your label background colors when you create and place them in your frame. So in initUI() you can use something similar to the loop you put in the constructor

for(int b1=0;b1<leslignes;b1++){
   for(int b2=0;b2<lescolonnes;b2++){
      JLabel label = new JLabel();
      label.setOpaque(true);
      switch(lamatrice[b1][b2]){
	 case 1: label.setBackground(Color.black);
                 break;
         case 0: label.setBackground(Color.blue);
                 break;
         case -1: label.setBackground(Color.red);
                  break;
      }
      frame.add(label);
   }
}

There is no reason for your class to extend JLabel.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

What is to go in the rectangles? You can place JLabels in a GridLayout and give them a line border if you want a grid of actual components.

Or you can simply override paintComponent() and draw lines on your JPanel.

The Oracle tutorials offer more information about both of those possibilities.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

getLine has a guaranteed return even if the if() statement is false.

getRow() has two returns but one is in if() and the other in for(). You need a return in case those do not execute.