GUi File error

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 2001 Views - Last Post: 17 June 2008 - 09:47 AM Rate Topic: -----

#1 deepacc   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-May 08

GUi File error

Posted 13 June 2008 - 07:55 AM

Below is my GUi code for an inventory project, My teacher review and instist the code works but I get 2 errors when i complie it can anyone help.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.*;
 
public class Inventorytest4 extends JFrame
{
 
 //Define private variables of type JLabel to hold the data for display
 private JLabel label1, label2, label3, label4, label5;
 
	// set up GUI
	public Inventorytest4 ()
	{
 
	super( "Inventory of DVD Movies" );
 
	// get content pane and set its layout
	Container container = getContentPane();
	   container.setLayout( new FlowLayout() );
 

  //create an array of products
  Movie[] Movies = new Movie[4];
 
  //populate the array
  Movies[0] = new Movie("111", "Superman", 11, 12.99, "PG");
  Movies[1] = new Movie("222", "Batman Returns", 9, 11.99, "PG 13");
  Movies[2] = new Movie("333", "Madagascar", 10, 10.99, "G");
  Movies[3] = new Movie("444", "Cars", 15, 13.99, "G");
 
  //initiate decimal format object
  NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
  DecimalFormat Currency = new DecimalFormat("#0.00");
 
  //print the inventory information
  label1 = new JLabel("<html><font size=+1>Non sorted Movies inventory</html>");
  container.add( label1 );
 
  for(int i = 0; i < Movies.length; i++)
  {
   Movie aDVD = Movies;
 
  label2 = new JLabel("DVD Name: " + aDVD.getName() +
  "| Rating: " + aDVD.getRating() +
  "| Item #: " + aDVD.getNum() +
  "| Number in stock: " + aDVD.getStock() +
  "| Price: $" + Currency.format(aDVD.getPrice()) +
  "| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
  "| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
  container.add(label2);
  }
 

  //sorting the array
  Movies[0].SortInventory(Movies);
 
  //print the inventory information
  label3 = new JLabel("<html><font size=+1>Sorted Movies inventory</html>");
  container.add( label3 );
 
  for(int i = 0; i < Movies.length; i++)
  {
   Movie aDVD = Movies;
 
  label4 = new JLabel("DVD Name: " + aDVD.getName() +
  "| Rating: " + aDVD.getRating() +
  "| Item #: " + aDVD.getNum() +
  "| Number in stock: " + aDVD.getStock() +
  "| Price: $" + Currency.format(aDVD.getPrice()) +
  "| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
  "| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
  container.add(label4);
  }
 

  //calulcating total value and displaying
  Double totalInv = Movies[0].CalculateTotalInventoryValue(Movies);
  label5 = new JLabel("Total Inventory Value: " + n.format(totalInv) + "\n");
  container.add( label5 );
 
 }
 
 public static void main(String args[])
 {
 
	  Inventorytest4 frame = new Inventorytest4();
 
	  //Set JLabel window size and visibility
	  frame.setSize( 900, 300 );
	  frame.setVisible( true );
	  frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
 
 }
}




C:\Documents and Settings\paccda\Desktop\Inventorytest4.java:43: incompatible types
found : Movie[]
required: Movie
Movie aDVD = Movies;
^
C:\Documents and Settings\paccda\Desktop\Inventorytest4.java:65: incompatible types
found : Movie[]
required: Movie
Movie aDVD = Movies;
^
2 errors

Tool completed with exit code 1

Is This A Good Question/Topic? 0
  • +

Replies To: GUi File error

#2 mensahero   User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: GUi File error

Posted 13 June 2008 - 08:00 AM

Quote

Movie aDVD = Movies;


Movies is an array.. as you declared it here.. see below..

Quote

Movie[] Movies = new Movie[4];


You can't assign an array object into a non-array object.. :blink:
Was This Post Helpful? 0
  • +
  • -

#3 deepacc   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-May 08

Re: GUi File error

Posted 13 June 2008 - 08:09 AM

View Postmensahero, on 13 Jun, 2008 - 08:00 AM, said:

Quote

Movie aDVD = Movies;


Movies is an array.. as you declared it here.. see below..

Quote

Movie[] Movies = new Movie[4];


You can't assign an array object into a non-array object.. :blink:

Thank you but i am still confused what do you mean by that??
Was This Post Helpful? 0
  • +
  • -

#4 mensahero   User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: GUi File error

Posted 13 June 2008 - 08:20 AM

owkie its like this.. an ARRAY holds records/objects.. and a variable can only hold a single record.. make sense?

Movies << is an array.. it holds 4 records/objects of Movie Class..

aDVD << is just a single variable.. a variable... that can only hold a single record..

Tip:

1. Why create another instance of Movie .. aDVD.. when you can directly use Movies[index] directly.. :blink:

I really suck at explanation..

whats the purpose of this block of code

  for(int i = 0; i < Movies.length; i++)
  {
   Movie aDVD = Movies;

  label2 = new JLabel("DVD Name: " + aDVD.getName() +
  "| Rating: " + aDVD.getRating() +
  "| Item #: " + aDVD.getNum() +
  "| Number in stock: " + aDVD.getStock() +
  "| Price: $" + Currency.format(aDVD.getPrice()) +
  "| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
  "| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
  container.add(label2);
  }


This post has been edited by mensahero: 13 June 2008 - 08:24 AM

Was This Post Helpful? 0
  • +
  • -

#5 herefishyfishy   User is offline

  • D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 60
  • Joined: 01-May 08

Re: GUi File error

Posted 13 June 2008 - 08:23 AM

Movies is an array of many movies. You can't assign that to a file of type Movie. Think about it. Movies has many movies in it. movie can only store one.
Was This Post Helpful? 0
  • +
  • -

#6 deepacc   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-May 08

Re: GUi File error

Posted 13 June 2008 - 08:24 AM

View Postmensahero, on 13 Jun, 2008 - 08:20 AM, said:

owkie its like this.. an ARRAY holds records/objects.. and a variable can only hold a single record.. make sense?

Movies << is an array.. it holds 4 records/objects of Movie Class..

aDVD << is just a single variable.. a variable... that can only hold a single record..

Tip:

1. Why create another instance of Movie .. aDVD.. when you can directly use Movies[index] directly.. :blink:

I really suck at explanation..

Thank you not a sucky explanation I just do not really get this java stuff. My teacher gave me that code to use, becuase mine was not good enough for their liking. I used Movies[index] in my code my teacher said no gave me that code to wrk with. So i have no choice but to use it can I get it to work is the question???????????????
Was This Post Helpful? 0
  • +
  • -

#7 gl3thr0   User is offline

  • D.I.C Regular

Reputation: 19
  • View blog
  • Posts: 319
  • Joined: 27-October 07

Re: GUi File error

Posted 13 June 2008 - 08:25 AM

okay in english what he means is that you cant say something is something its not :P like you cant say
String[] x = new String("hi");
they are not the same type one is an array of strings one is just a string

what you tried to do was use the "object" movie which is of type Movie and set it equal to Movies which is of type Movie Array

now if u wanted it to work you could change it to..
Movie aDVD = Movies[i];//or some other int

does tht make sense now?
Was This Post Helpful? 0
  • +
  • -

#8 mensahero   User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: GUi File error

Posted 13 June 2008 - 08:28 AM

Your teacher sucks..... no offense.. why would he tell you to copy/paste his premade code.. and hope that it will work.. lmao.. :blink:

YES the code will work.. ? that's if you code it correctly.. well if you don't want explanations... you could always say..

"HERE IS MY CODE" ... PLEASE MAKE IT WORK.. because my teacher insisted..

and what kind of instructor will give you this code..

 for(int i = 0; i < Movies.length; i++)
  {
   Movie aDVD = Movies;

  label2 = new JLabel("DVD Name: " + aDVD.getName() +
  "| Rating: " + aDVD.getRating() +
  "| Item #: " + aDVD.getNum() +
  "| Number in stock: " + aDVD.getStock() +
  "| Price: $" + Currency.format(aDVD.getPrice()) +
  "| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
  "| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
  container.add(label2);
  }



.. :blink: what's the point I don't get it.. I hate your teacher.. :blink:

This post has been edited by mensahero: 13 June 2008 - 08:31 AM

Was This Post Helpful? 0
  • +
  • -

#9 deepacc   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-May 08

Re: GUi File error

Posted 13 June 2008 - 08:37 AM

View Postgl3thr0, on 13 Jun, 2008 - 08:25 AM, said:

okay in english what he means is that you cant say something is something its not :P like you cant say
String[] x = new String("hi");
they are not the same type one is an array of strings one is just a string

what you tried to do was use the "object" movie which is of type Movie and set it equal to Movies which is of type Movie Array

now if u wanted it to work you could change it to..
Movie aDVD = Movies[i];//or some other int

does tht make sense now?


THank you that worked!!!!! This has been a really hard class, everything I have coded my teacher has said is wrong. I now have to add

• Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next item, and the last item in the inventory. If the first item is displayed and the user clicks on the Previous button, the last item should display. If the last item is displayed and the user clicks on the Next button, the first item should display.

• Add a company logo to the GUI using Java graphics classes.
Was This Post Helpful? 0
  • +
  • -

#10 deepacc   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-May 08

Re: GUi File error

Posted 13 June 2008 - 11:58 AM

View Postdeepacc, on 13 Jun, 2008 - 08:37 AM, said:

View Postgl3thr0, on 13 Jun, 2008 - 08:25 AM, said:

okay in english what he means is that you cant say something is something its not :P like you cant say
String[] x = new String("hi");
they are not the same type one is an array of strings one is just a string

what you tried to do was use the "object" movie which is of type Movie and set it equal to Movies which is of type Movie Array

now if u wanted it to work you could change it to..
Movie aDVD = Movies[i];//or some other int

does tht make sense now?


THank you that worked!!!!! This has been a really hard class, everything I have coded my teacher has said is wrong. I now have to add

• Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next item, and the last item in the inventory. If the first item is displayed and the user clicks on the Previous button, the last item should display. If the last item is displayed and the user clicks on the Next button, the first item should display.

• Add a company logo to the GUI using Java graphics classes.

SO i took a stab at it and i think i am way off track but here is my code I get two errors so far please help
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.*;

public class Inventorytest4 extends JFrame
{

 //Define private variables of type JLabel to hold the data for display
 private JLabel label1, label2, label3, label4, label5;

	// set up GUI
	public Inventorytest4 ()
	{

	super( "Inventory of DVD Movies" );

	// get content pane and set its layout
	Container container = getContentPane();
	   container.setLayout( new FlowLayout() );


  //create an array of products
  Movie[] Movies = new Movie[4];

  //populate the array
  Movies[0] = new Movie("111", "Superman", 11, 12.99, "PG");
  Movies[1] = new Movie("222", "Batman Returns", 9, 11.99, "PG 13");
  Movies[2] = new Movie("333", "Madagascar", 10, 10.99, "G");
  Movies[3] = new Movie("444", "Cars", 15, 13.99, "G");

  //initiate decimal format object
  NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
  DecimalFormat Currency = new DecimalFormat("#0.00");

  //print the inventory information
  label1 = new JLabel("<html><font size=+1>Non sorted Movies inventory</html>");
  container.add( label1 );

  for(int i = 0; i < Movies.length; i++)
  {
   Movie aDVD = Movies[i];

  label2 = new JLabel("DVD Name: " + aDVD.getName() +
  "| Rating: " + aDVD.getRating() +
  "| Item #: " + aDVD.getNum() +
  "| Number in stock: " + aDVD.getStock() +
  "| Price: $" + Currency.format(aDVD.getPrice()) +
  "| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
  "| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
  container.add(label2);
  }


  //sorting the array
  Movies[0].SortInventory(Movies);

  //print the inventory information
  label3 = new JLabel("<html><font size=+1>Sorted Movies inventory</html>");
  container.add( label3 );

  for(int i = 0; i < Movies.length; i++)
  {
   Movie aDVD = Movies[i];

  label4 = new JLabel("DVD Name: " + aDVD.getName() +
  "| Rating: " + aDVD.getRating() +
  "| Item #: " + aDVD.getNum() +
  "| Number in stock: " + aDVD.getStock() +
  "| Price: $" + Currency.format(aDVD.getPrice()) +
  "| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
  "| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
  container.add(label4);
  }


  //calulcating total value and displaying
  Double totalInv = Movies[0].CalculateTotalInventoryValue(Movies);
  label5 = new JLabel("Total Inventory Value: " + n.format(totalInv) + "\n");
  container.add( label5 );

 }

 public static void main(String args[])
 {

	  Inventorytest4 frame = new Inventorytest4();

	  //Set JLabel window size and visibility
	  frame.setSize( 900, 300 );
	  frame.setVisible( true );
	  frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );


private JPanel centerPanel;
private JPanel buttonPanel;









theInventory = inventory;




centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));



buttonPanel = new JPanel();
JButton nextButton = new JButton("Next");
nextButton.addActionListener(new NextButtonHandler());
buttonPanel.add(nextButton);
centerPanel.add(buttonPanel);



jp = new JPanel(flo);
itemNumberLabel.setPreferredSize(dim);
jp.add(itemNumberLabel);
itemNumberText = new JTextField(3);
itemNumberText.setEditable(false);
jp.add(itemNumberText);
centerPanel.add(jp);



jp = new JPanel(flo);
prodnameLabel.setPreferredSize(dim);
jp.add(prodnameLabel);
prodnameText = new JTextField(17);
prodnameText.setEditable(false);
jp.add(prodnameText);
centerPanel.add(jp);



jp = new JPanel(flo);
prodpriceLabel.setPreferredSize(dim);
jp.add(prodpriceLabel);
prodpriceText = new JTextField(17);
prodpriceText.setEditable(false);
jp.add(prodpriceText);
centerPanel.add(jp);



jp = new JPanel(flo);
numinstockLabel.setPreferredSize(dim);
jp.add(numinstockLabel);
numinstockText = new JTextField(5);
numinstockText.setEditable(false);
jp.add(numinstockText);
centerPanel.add(jp);



jp = new JPanel(flo);
restockingFeeLabel.setPreferredSize(dim);
jp.add(restockingFeeLabel);
restockingFeeText = new JTextField(17);
restockingFeeText.setEditable(false);
jp.add(restockingFeeText);
centerPanel.add(jp);



jp = new JPanel(flo);
valueLabel.setPreferredSize(dim);
jp.add(valueLabel);
valueText = new JTextField(17);
valueText.setEditable(false);
jp.add(valueText);
centerPanel.add(jp);




jp = new JPanel(flo);
totalValueLabel.setPreferredSize(dim);
jp.add(totalValueLabel);
totalValueText = new JTextField(17);
totalValueText.setEditable(false);
jp.add(totalValueText);
centerPanel.add(jp);



setContentPane(centerPanel);



repaintGUI();

}
public void repaintGUI() {
Movie temp = (Movie) theInventory.getDVD(index);



if (temp != null) {
itemNumberText.setText("" + temp.getItemNo());
prodnameText.setText(temp.getTitle());
prodpriceText.setText(String.format("$%.2f", temp.getUnitPrice()));
restockingFeeText.setText(String.format("$%.2f", temp.restockingFee

()));
numinstockText.setText("" + temp.getInStock());
valueText.setText(String.format("$%.2f", temp.value()));
}
totalValueText.setText(String.format("$%.2f", theInventory.value()));
}



class NextButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
int numItems = theInventory.getNumItems();
index = (++index) % numItems;
repaintGUI();
}
}








}




View Postdeepacc, on 13 Jun, 2008 - 11:58 AM, said:

View Postdeepacc, on 13 Jun, 2008 - 08:37 AM, said:

View Postgl3thr0, on 13 Jun, 2008 - 08:25 AM, said:

okay in english what he means is that you cant say something is something its not :P like you cant say
String[] x = new String("hi");
they are not the same type one is an array of strings one is just a string

what you tried to do was use the "object" movie which is of type Movie and set it equal to Movies which is of type Movie Array

now if u wanted it to work you could change it to..
Movie aDVD = Movies[i];//or some other int

does tht make sense now?


THank you that worked!!!!! This has been a really hard class, everything I have coded my teacher has said is wrong. I now have to add

• Modify the Inventory Program by adding a button to the GUI that allows the user to move to the first item, the previous item, the next item, and the last item in the inventory. If the first item is displayed and the user clicks on the Previous button, the last item should display. If the last item is displayed and the user clicks on the Next button, the first item should display.

• Add a company logo to the GUI using Java graphics classes.

SO i took a stab at it and i think i am way off track but here is my code I get two errors so far please help
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.*;
import java.util.*;

public class Inventorytest4 extends JFrame
{

 //Define private variables of type JLabel to hold the data for display
 private JLabel label1, label2, label3, label4, label5;

	// set up GUI
	public Inventorytest4 ()
	{

	super( "Inventory of DVD Movies" );

	// get content pane and set its layout
	Container container = getContentPane();
	   container.setLayout( new FlowLayout() );


  //create an array of products
  Movie[] Movies = new Movie[4];

  //populate the array
  Movies[0] = new Movie("111", "Superman", 11, 12.99, "PG");
  Movies[1] = new Movie("222", "Batman Returns", 9, 11.99, "PG 13");
  Movies[2] = new Movie("333", "Madagascar", 10, 10.99, "G");
  Movies[3] = new Movie("444", "Cars", 15, 13.99, "G");

  //initiate decimal format object
  NumberFormat n = NumberFormat.getCurrencyInstance(Locale.US);
  DecimalFormat Currency = new DecimalFormat("#0.00");

  //print the inventory information
  label1 = new JLabel("<html><font size=+1>Non sorted Movies inventory</html>");
  container.add( label1 );

  for(int i = 0; i < Movies.length; i++)
  {
   Movie aDVD = Movies[i];

  label2 = new JLabel("DVD Name: " + aDVD.getName() +
  "| Rating: " + aDVD.getRating() +
  "| Item #: " + aDVD.getNum() +
  "| Number in stock: " + aDVD.getStock() +
  "| Price: $" + Currency.format(aDVD.getPrice()) +
  "| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
  "| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
  container.add(label2);
  }


  //sorting the array
  Movies[0].SortInventory(Movies);

  //print the inventory information
  label3 = new JLabel("<html><font size=+1>Sorted Movies inventory</html>");
  container.add( label3 );

  for(int i = 0; i < Movies.length; i++)
  {
   Movie aDVD = Movies[i];

  label4 = new JLabel("DVD Name: " + aDVD.getName() +
  "| Rating: " + aDVD.getRating() +
  "| Item #: " + aDVD.getNum() +
  "| Number in stock: " + aDVD.getStock() +
  "| Price: $" + Currency.format(aDVD.getPrice()) +
  "| Restocking fee(5%): " + n.format(aDVD.getRestockingFee()) +
  "| Inventory Value: " + n.format(aDVD.getInventoryTotal()) + "\n");
  container.add(label4);
  }


  //calulcating total value and displaying
  Double totalInv = Movies[0].CalculateTotalInventoryValue(Movies);
  label5 = new JLabel("Total Inventory Value: " + n.format(totalInv) + "\n");
  container.add( label5 );

 }

 public static void main(String args[])
 {

	  Inventorytest4 frame = new Inventorytest4();

	  //Set JLabel window size and visibility
	  frame.setSize( 900, 300 );
	  frame.setVisible( true );
	  frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );


private JPanel centerPanel;
private JPanel buttonPanel;









theInventory = inventory;




centerPanel = new JPanel();
centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS));



buttonPanel = new JPanel();
JButton nextButton = new JButton("Next");
nextButton.addActionListener(new NextButtonHandler());
buttonPanel.add(nextButton);
centerPanel.add(buttonPanel);



jp = new JPanel(flo);
itemNumberLabel.setPreferredSize(dim);
jp.add(itemNumberLabel);
itemNumberText = new JTextField(3);
itemNumberText.setEditable(false);
jp.add(itemNumberText);
centerPanel.add(jp);



jp = new JPanel(flo);
prodnameLabel.setPreferredSize(dim);
jp.add(prodnameLabel);
prodnameText = new JTextField(17);
prodnameText.setEditable(false);
jp.add(prodnameText);
centerPanel.add(jp);



jp = new JPanel(flo);
prodpriceLabel.setPreferredSize(dim);
jp.add(prodpriceLabel);
prodpriceText = new JTextField(17);
prodpriceText.setEditable(false);
jp.add(prodpriceText);
centerPanel.add(jp);



jp = new JPanel(flo);
numinstockLabel.setPreferredSize(dim);
jp.add(numinstockLabel);
numinstockText = new JTextField(5);
numinstockText.setEditable(false);
jp.add(numinstockText);
centerPanel.add(jp);



jp = new JPanel(flo);
restockingFeeLabel.setPreferredSize(dim);
jp.add(restockingFeeLabel);
restockingFeeText = new JTextField(17);
restockingFeeText.setEditable(false);
jp.add(restockingFeeText);
centerPanel.add(jp);



jp = new JPanel(flo);
valueLabel.setPreferredSize(dim);
jp.add(valueLabel);
valueText = new JTextField(17);
valueText.setEditable(false);
jp.add(valueText);
centerPanel.add(jp);




jp = new JPanel(flo);
totalValueLabel.setPreferredSize(dim);
jp.add(totalValueLabel);
totalValueText = new JTextField(17);
totalValueText.setEditable(false);
jp.add(totalValueText);
centerPanel.add(jp);



setContentPane(centerPanel);



repaintGUI();

}
public void repaintGUI() {
Movie temp = (Movie) theInventory.getDVD(index);



if (temp != null) {
itemNumberText.setText("" + temp.getItemNo());
prodnameText.setText(temp.getTitle());
prodpriceText.setText(String.format("$%.2f", temp.getUnitPrice()));
restockingFeeText.setText(String.format("$%.2f", temp.restockingFee

()));
numinstockText.setText("" + temp.getInStock());
valueText.setText(String.format("$%.2f", temp.value()));
}
totalValueText.setText(String.format("$%.2f", theInventory.value()));
}



class NextButtonHandler implements ActionListener {
public void actionPerformed(ActionEvent e) {
int numItems = theInventory.getNumItems();
index = (++index) % numItems;
repaintGUI();
}
}








}



sorry forget to give ther errors C:\Documents and Settings\paccda\Desktop\Inventorytest4.java:96: illegal start of expression
private JPanel centerPanel;
^
C:\Documents and Settings\paccda\Desktop\Inventorytest4.java:97: illegal start of expression
private JPanel buttonPanel;
^
2 errors

Tool completed with exit code 1
Was This Post Helpful? 0
  • +
  • -

#11 mensahero   User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: GUi File error

Posted 13 June 2008 - 11:59 AM

Quote

SO i took a stab at it and i think i am way off track but here is my code I get two errors so far please help


Try removing the "private " thingy.. :blink:

This post has been edited by mensahero: 13 June 2008 - 12:03 PM

Was This Post Helpful? 0
  • +
  • -

#12 deepacc   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-May 08

Re: GUi File error

Posted 13 June 2008 - 12:07 PM

View Postmensahero, on 13 Jun, 2008 - 11:59 AM, said:

Quote

SO i took a stab at it and i think i am way off track but here is my code I get two errors so far please help


Try removing the "private " thingy.. :blink:

when i remove that i get 100 new errors this class is kicking my *ss man
Was This Post Helpful? 0
  • +
  • -

#13 mensahero   User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: GUi File error

Posted 13 June 2008 - 12:09 PM

Quote

private JPanel centerPanel;
private JPanel buttonPanel;


I mean those.. did you try removing the private of those declarations..?
Was This Post Helpful? 0
  • +
  • -

#14 deepacc   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 26
  • Joined: 27-May 08

Re: GUi File error

Posted 13 June 2008 - 12:14 PM

View Postmensahero, on 13 Jun, 2008 - 12:09 PM, said:

Quote

private JPanel centerPanel;
private JPanel buttonPanel;


I mean those.. did you try removing the private of those declarations..?

yes i did thats when i get the errors :( i have flunked the all th eparts of this minus the first part. This is really hard to understand I read my book and it does not help either
Was This Post Helpful? 0
  • +
  • -

#15 mensahero   User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 680
  • Joined: 26-May 08

Re: GUi File error

Posted 13 June 2008 - 12:25 PM

are you sure your method main is inside a class.. I can't possibly test your code.. but I'm tracing the brackets and it seems it doesn't belong inside the inventory class.. could you check.. if your main is indeed inside a class..:blink:


I test your code.. and it seems I'm right.. you should remove the private modifier on those two jpanel..

It's says.. private modifier is not allow here.. and I don't even compile it.. :blink:

And I really don't get how you get to type all those code when you're not even sure if its gonna compile.. :blink:

This post has been edited by mensahero: 13 June 2008 - 12:30 PM

Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2