The important difference here is that ProdArray is an array reference. ProdArray[0] is an element of that array. It is those elements that you wish to call methods on.
Look at line 89 in the code you posted above. See the difference in syntax?
The important difference here is that ProdArray is an array reference. ProdArray[0] is an element of that array. It is those elements that you wish to call methods on.
Look at line 89 in the code you posted above. See the difference in syntax?
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.
There is a difference between calling a method on an array and calling a method on an element of the array.
ProdArray is just an array.
Take another look at the calls in those error messages. Does your ProdArray have a getFee() method?
I wasn't taking it in offense, I just don't know which part you feel needs to be done differently. From what I could tell looking over it, the code that you linked to does the exact same that my method does, but mine just returns a rotated image, where yours is a component that displays the image.
The rotation part seems identical. Did I miss something there?
The method I posted does virtually the same operations as those in the paintComponent() method of the class you linked to. I'm not sure which other difficulties you mean?
The infographic looks like useless promotional propaganda to me. Only half of it's visible and I see no source cited.
Are you at all affiliated with that facebook group?
Why are you trying to load 'image' twice? You shouldn't need the ImageIO.read() at all. The ImageIcon should suffice.
You also do not need to create a new label if you already have one placed in your UI. Just call label.setIcon() to set the new image.
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.
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.
You can use Graphics2D.rotate() method to rotate the current graphics context.
Tutorial: Transforming Shapes, Text, and Images
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.
No, you can't reference an image you haven't created yet. You must swap those two lines. This is remedial language usage.
Check the constructors for ImageIcon. You need to either use the string file path which you can get with file.getPath()
or a URL object, which can be obtained from a File with the toURL()
method
Yes, somewhat. You can go ahead and put a JLabel in your UI to hold the image and when you want to set or update it, you can call setIcon() to specify the new image icon.
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
Have you looked into the error Invalid object name 'tCandidate'.
Is it a valid object?
Perhaps you should read the following rule from our forum rules and revise your post accordingly:
Do provide evidence of having done some work yourself if posting questions from assignments.
As is often the case, the Oracle tutorials have you covered:
http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html
Banned and banned, thanks.
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.
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.
Thank you. Banned.
Thanks. Handled.
"=<" is not a valid operator.
Also, all for() loops must have three sections ( ; ; ) even if one is not used
Post the code that you have started with.
Post specific questions about what you are struggling with and what you have tried or even thought about trying.
Simply posting the assignment is not sufficient demonstration of effort. No one here is going to simply do the assignment for you. You must put forth some effort to solve it. People may offer some guidance, but they will not do the work for you.
You were already advised in your other thread about this to look at regex. I don't see any regex or mention of it here.
Post your code and specific questions. The forum rules state that you must show some effort if you wish to get help with homework.
You can't prevent the element from being empty. If you don't select all of the check boxes you are going to have blanks in the array. You could certainly pre-fill the array with empty strings so they weren't actually null, but why not just use an ArrayList or some other collection of variable size to hold just the fields that you want to extract?
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.
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.
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.
You already have a File object from the open dialog, so use file.getPath() instead of file.getName().
Then start a thread of your own with an actual question instead of hijacking someone else's old thread.
Closed.
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.
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.
Basically, yes, with some syntax correction. Is your search filter an array or a string that you pass to HSSF?
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
Yep, those are definitely spammers.
Edit: were spammers ;)
That's fine. You'll just need to supply the full path to the resource in that case.
Post the exact error message.
Edit: Nevermind. Check your spelling of JCheckBox.
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.
Are you using Java 1.5 or later? Did you add List and ArrayList to your imports?
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?
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.
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);
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.
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