Results 1 to 10 of 10
Thread: JButton into an Array
- 03-11-2012, 04:40 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
JButton into an Array
So i'm hoping this isn't to aggravating of a question, i can honestly say i'm not great at Java but i'm trying to learn.
Basically i need to make an Array of objects, and i need to enter objects into this array via a JButton.
I have this as a Class
class Application extends CardDeck {
public Application (String Name, int average, String first, String second, String third){
t1 = Name;
t2 = Average;
dataList.setSelectedIndex(0) = first;
dataList.setSelectedIndex(1) = second;
dataList.setSelectedIndex(2) = third;
Which im not sure is correct and i have
Application Apps[] = new Application[99];
for (int i = 0; i < Apps.length; i++);
if (event.getSource() == b1)
Apps[i] = new Application();
String[] data = {};
to create the objects and put them into the array, im not sure what is missing or if everything is in the right order any help at all would be MASSIVELY appreciated.
Every time i try to compile i get this error
"Error: constructor Application in class Application cannot be applied to given types;
required: java.lang.String,int,java.lang.String,java.lang.St ring,java.lang.String
found: no arguments
reason: actual and formal argument lists differ in length"
I have tried everything i know and looked through about 6 Java website as well as 2 textbooks and i honestly cant figure out how to do this properly.
I dont know it will help but here is a picture of the Applet
imgur: the simple image sharer
Each object needs to contain name, average and 3 universities that are chosen in the JList.
Thank you for taking the time to read my post!
- 03-11-2012, 05:13 AM #2
Re: JButton into an Array
I should think that's pretty self-explanatory. You're trying to use a constructor "new Application()" but the only constructor in the Application class requires 4 String parameters.Java Code:constructor Application in class Application cannot be applied to given types; required: java.lang.String,int,java.lang.String,java.lang.St ring,java.lang.String found: no arguments
dbWhy do they call it rush hour when nothing moves? - Robin Williams
-
Re: JButton into an Array
Your error message is telling you what's wrong, and so in the future you'll want to try to understand it as best you can since it is often quite helpful. Your Application constructor is written to accept several parameters and you're trying to call it with none. So you'll need to figure out the best way to fix this.
Edit: Hey Darryl! And goodnight!
- 03-11-2012, 05:47 AM #4
Re: JButton into an Array
Ah, it's time for the day shift on the other side of the globe!
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 03-11-2012, 06:56 PM #5
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
-
Re: JButton into an Array
- 03-11-2012, 07:10 PM #7
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
-
Re: JButton into an Array
- 03-11-2012, 07:22 PM #9
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
-
Re: JButton into an Array
Again, we cannot help given the limited information that you've posted so far. Please when post your questions, assume that we don't have your requirement instructions nor your current code sitting in front of us, and assume that we don't have crystal balls and can't read minds.
Similar Threads
-
ActionListener for JButton after changing Button to JButton
By ravi.joshi53 in forum Java AppletsReplies: 2Last Post: 10-07-2011, 07:35 AM -
Error in writing JButton Array of objects into File
By justbeller in forum AWT / SwingReplies: 3Last Post: 06-08-2011, 11:06 PM -
jbutton
By Patea2000 in forum NetBeansReplies: 1Last Post: 03-16-2011, 08:56 AM -
Persistence causing problems with JButton 2D Array
By easyp in forum New To JavaReplies: 2Last Post: 04-21-2010, 06:34 PM -
JButton help :)
By yasmin k in forum AWT / SwingReplies: 7Last Post: 11-12-2009, 09:53 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks