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

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

No. No one wants to "fix for you" some code you copied off the internet.

If you post the exact error message, which will include the line on which the error is occurring, perhaps someone will help you solve the issue yourself.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Consider the steps you would go through with a pencil to note the shortest or longest in a series of numbers. You need a place to keep the min/max that you have found so far. Then you simply start going through the list one by one. If you find one shorter/longer, you update your min/max.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

In calculating the average, you sum the elements and then divide by the number of elements. That would imply that division does not occur within the loop.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Sure, just get the graphics context of playerDrawn and draw the rotated version onto that. You could write a small method to do that for you like so

private Image getRotatedInstance(Image img, double theta){
        BufferedImage rotatedImg = new BufferedImage(img.getWidth(this), img.getHeight(this), BufferedImage.TYPE_INT_RGB);
        Graphics2D g2 = (Graphics2D)rotatedImg.getGraphics();
        g2.rotate(theta, img.getWidth(this)/2, img.getHeight(this)/2);
        g2.drawImage(img, 0, 0, this);
        return rotatedImg;
    }

There are some nuances of transformation and rotation that I'll leave for you to study.

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

Once you have a selected File object, you can create an ImageIcon and display it in a JLabel on your frame.

Take a look through this tutorial for more information and some sample code:
http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html

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.

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

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

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

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

You'll need to use a JTextPane if you want to mix text and pictures in the same component:
http://docs.oracle.com/javase/tutorial/uiswing/components/editorpane.html

You can use a JLabel and ImageIcon if you just want to display the picture by itself:
http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html

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

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

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

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

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

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

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

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

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

Assert that the absolute value of the difference is less than your threshold.

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

You're setting winner from the fourth column

int Winner = rs.getInt(4);

but winner is the fifth column your data set. Contrary to most any other indexing in Java, in ResultSet the first column is 1, not 0.

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

This example app from the tutorials seems applicable:
http://xuggle.wordpress.com/2009/01/23/how-to-use-xuggler-to-decode-and-play-video/

They are updating a VideoImage frame with a BufferedImage from the stream. VideoImage just extends JFrame, so you could probably either look at that source or override paintComponent(Graphics) on a JPanel of your own and render the BufferedImage on that panel with drawImage().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Take a closer look at line 56 and note which method you are calling. It may not be the one you want.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Ok, there is no way I'm going to try to trace that mess of meaningless variable names, but I will say that all you need is a List or Set to keep the numbers you have already encountered and the String.replace() method.

In fact, you only need the list if you want to retain a listing of the unique numbers. If you just want to cleanse repetitions, all you need to do is loop forward and remove them.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Did you try it? Did it work?

-==Zero==- commented: Thanks Sir +2
Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

If you have separate panels for each group of controls, you can simply swap those in and out of a target panel that remains in a fixed place in your UI.

To swap them, remove the old panel, add the new, and call targetPanel.revalidate() and targetPanel.repaint().

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

A text editor?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Alright, maybe this will clarify a bit:

1) main method must be wrapped into invokeLater()

For concurrency reasons, GUIs should be created on the event dispatch thread. In your main method, you should create your GUI instance in a small Runnable that can be executed on the dispatch thread

javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                new TableFrame();
            }
        });

3) don't call fireXxxXxx outside AbstractTableModel

Your model should fire those events itself as needed when the data changes.

5) don't create/recreate JTable inside Model,

I don't see where your latest code is doing this, so I'm not sure why that was mentioned.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You are updating your local 'data' array in the frame - not the one in your table model.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I believe he was referring to the removing and recreating all of your components each time instead of merely updating the data they contain. Update the data in your table model. You don't have to throw everything away.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Nope, wouldn't matter. JPanel, JLabel, or even just an extension of JComponent.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

After you get it to compile, consider that the only part of your code that will be different in all of those if-else cases is the check for which color to use.

You don't need to repeat all that code in each case. Just check the current value of 'faren' and set your color.

Also note that Applets don't use a main() method. Just remove that.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Personally, I have no interest in playing with some tutorial to see if I can recreate "nothing happens". Perhaps someone else does. I can cause nothing to happen by just sitting here at my desk; it doesn't really help resolve your issue though.

Post your code and describe what isn't happening.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

"nothing happens" is a bit thin to go on. What jars and what code?

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

I would assume that you would use your "studentmarks" class in your main method, but that's entirely up to you. I assume you have some assignment.

I just told you why it was not running.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

No, I doubt he can because he simply copied and pasted it here from another post he saw elsewhere - which is why I have deleted it.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

Shower, coffee, drive - just another day of work.

Ezzaral 2,714 Posting Sage Team Colleague Featured Poster

You should not override the method isCellEditable on DefaultTableModel
but override it on the JTable itself

And what is your reasoning for that?