Results 1 to 14 of 14
- 10-21-2011, 11:35 PM #1
Member
- Join Date
- Oct 2011
- Posts
- 38
- Rep Power
- 0
I need help with putting a logo on my code
Here is the code for my logo but i have two error and i am not sure where it would go can someone please help me. The top code is the logo code and the buttom is my inventory code.. and i am getting 2 errors with this.
C:\Java Test>javac InventoryPart5.java
InventoryPart5.java:137: error: cannot find symbol
Label = new JLabel(logo);
^
symbol: variable Label
location: class InventoryPart5
InventoryPart5.java:138: error: cannot find symbol
Label.setToolTipText("Camera Shop");
^
symbol: variable Label
location: class InventoryPart5
2 errors
Java Code:import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; public class Logo extends JPanel { public Logo() { super(); setPreferredSize(new Dimension(200,200)); } public void paint(Graphics g) { g.setColor(Color.red); g.fillRoundRect(60,60,110,90,5,5); g.setColor(Color.blue); g.drawString("DVD Store", 70, 105); } }
Java Code:import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.DecimalFormat; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JTextField; import javax.swing.Icon; import javax.swing.ImageIcon; public class InventoryPart5 extends JFrame { private static DecimalFormat currency = new DecimalFormat("$#,##0.00"); private JTextField itemNumberTF; private JTextField productNameTF; private JTextField unitsInStockTF; private JTextField priceTF; private JTextField supplierNameTF; private JTextField restockFeeTF; private JTextField valueOfInventoryTF; private JTextField totalValueOfInventoryTF; private JButton FirstBT; private JButton BackBT; private JButton nextBT; private JButton lastBT; private Supplier[] products; private int current = 0; public static void main(String[] args) { new InventoryPart5(); } public InventoryPart5() { super("Inventory Part 5"); setSize(500, 300); setLocationRelativeTo(null); setDefaultCloseOperation(EXIT_ON_CLOSE); products = new Supplier[5]; products[0] = new Supplier(500, "STYLUS", 10, 800, "Olympus"); products[1] = new Supplier(200, "COOLPIX", 20, 650, "Nikon"); products[2] = new Supplier(300, "Powershot", 15, 890, "Canon"); products[3] = new Supplier(350, "Cyber-shot", 10, 1200, "Sony"); products[4] = new Supplier(400, "Easyshare", 80, 1500, "Kodak"); sortArray(); createComponents(); setVisible(true); updateFields(); } private void createComponents() { JPanel p = new JPanel(); p.setLayout(new BorderLayout()); p.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); p.add(createFieldsPanel(), BorderLayout.CENTER); p.add(createButtonsPanel(), BorderLayout.SOUTH); setContentPane(p); } private JPanel createButtonsPanel() { JPanel p = new JPanel(); p.setLayout(new FlowLayout(FlowLayout.RIGHT)); FirstBT = new JButton("First"); FirstBT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { current = 0; updateFields(); } }); p.add(FirstBT); BackBT = new JButton("Back"); BackBT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (current > 0) { current--; updateFields(); } } }); p.add(BackBT); nextBT = new JButton("Next"); nextBT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (current < products.length - 1) current++; updateFields(); } }); p.add(nextBT); lastBT = new JButton("Last"); lastBT.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { current = products.length-1; updateFields(); } }); p.add(lastBT); Icon logo = new ImageIcon("C:/logo.jpg"); Label = new JLabel(logo); Label.setToolTipText("Camera Shop"); return p; } protected void updateFields() { Supplier s = products[current]; itemNumberTF.setText(String.valueOf(s.getItemNumber())); productNameTF.setText(s.getProductName()); unitsInStockTF.setText(String.valueOf(s.getUnitsInStock())); priceTF.setText(currency.format(s.getPrice())); supplierNameTF.setText(s.getSupplierName()); restockFeeTF.setText(currency.format(s.calculateRestockFee())); valueOfInventoryTF.setText(currency.format(s.calculateInventory())); totalValueOfInventoryTF.setText(currency.format(calculateInventory())); } private JPanel createFieldsPanel() { JPanel p = new JPanel(); p.setLayout(new GridLayout(0, 2, 5, 5)); p.add(new JLabel("Item Number")); itemNumberTF = new JTextField(); p.add(itemNumberTF); p.add(new JLabel("Product Name")); productNameTF = new JTextField(); p.add(productNameTF); p.add(new JLabel("Units In Stock")); unitsInStockTF = new JTextField(); p.add(unitsInStockTF); p.add(new JLabel("Unit Price")); priceTF = new JTextField(); p.add(priceTF); p.add(new JLabel("Supplier Name")); supplierNameTF = new JTextField(); p.add(supplierNameTF); p.add(new JLabel("Restock Fee")); restockFeeTF = new JTextField(); p.add(restockFeeTF); p.add(new JLabel("Value Of Inventory")); valueOfInventoryTF = new JTextField(); p.add(valueOfInventoryTF); p.add(new JLabel("")); p.add(new JLabel("")); p.add(new JLabel("Value Of The Entire Inventory")); totalValueOfInventoryTF = new JTextField(); p.add(totalValueOfInventoryTF); return p; } public double calculateInventory() { double value = 0; for (int i = 0; i < products.length; i++) { value += products[i].calculateInventory(); } return value; } public void sortArray() { int n = products.length; boolean swapped; do { swapped = false; for (int i = 0; i < n - 1; i++) { String name1 = products[i].getProductName(); String name2 = products[i + 1].getProductName(); if (name1.compareToIgnoreCase(name2) > 0) { Supplier temp = products[i]; products[i] = products[i + 1]; products[i + 1] = temp; swapped = true; } } n = n - 1; } while (swapped); } }
-
Re: I need help with putting a logo on my code
- 10-21-2011, 11:57 PM #3
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,547
- Rep Power
- 11
Re: I need help with putting a logo on my code
You have not declared Label anywhere.error: cannot find symbol
- 10-22-2011, 12:00 AM #4
Member
- Join Date
- Oct 2011
- Posts
- 38
- Rep Power
- 0
Re: I need help with putting a logo on my code
ok how do i do that
-
Re: I need help with putting a logo on my code
Just like you declare any other variable: type variable name;
Also note that it should be label not Label.
i.e.,
Or you can declare and initialize on the same line:Java Code:JLabel label; // declares label
Java Code:JLabel label = new JLabel("..."); // declares and initializes label
- 10-22-2011, 12:05 AM #6
Member
- Join Date
- Oct 2011
- Posts
- 38
- Rep Power
- 0
Re: I need help with putting a logo on my code
ok in what area would i put that in or line
-
Re: I need help with putting a logo on my code
- 10-22-2011, 12:11 AM #8
Member
- Join Date
- Oct 2011
- Posts
- 38
- Rep Power
- 0
Re: I need help with putting a logo on my code
yes this is my original code
-
Re: I need help with putting a logo on my code
Heck, this is the same error that you had in this post yesterday in code guru: CodeGuru: Error In code need Help please ... and they already told you what the error message meant and its solution. The solution hasn't changed in one day.
-
Re: I need help with putting a logo on my code
But a search on Google shows that much of your code has been borrowed (e.g., stackoverflow: modify-the-inventory-program-to-use-a-gui), and it has to be -- you use anonymous inner classes in this code -- surely you weren't taught that in class, and I fear that you don't understand what they are or why you're using them.
You really don't want to use borrowed code as you won't understand the code you're using and this will hamper your attempt to learn to program.Last edited by Fubarable; 10-22-2011 at 12:39 AM.
- 10-22-2011, 12:18 AM #11
Member
- Join Date
- Oct 2011
- Posts
- 38
- Rep Power
- 0
Re: I need help with putting a logo on my code
no this is diffrent error i got that one fix
-
Re: I need help with putting a logo on my code
- 10-22-2011, 12:33 AM #13
Member
- Join Date
- Oct 2011
- Posts
- 38
- Rep Power
- 0
Re: I need help with putting a logo on my code
well that didnt help me like i said i have a code but i just dont know where to put in i need to put a logo in my code somewhere.
-
Re: I need help with putting a logo on my code
Similar Threads
-
Legal to use the Java Logo?
By developjava in forum Forum LobbyReplies: 2Last Post: 06-02-2012, 08:16 PM -
setting application logo to tab
By sameerk in forum JavaServer Pages (JSP) and JSTLReplies: 2Last Post: 10-29-2010, 11:36 AM -
Adding Logo to my project
By ibrahimyoussof in forum New To JavaReplies: 0Last Post: 04-14-2010, 10:56 AM -
Adding Logo to Video Uploading by Java swing
By arindam in forum New To JavaReplies: 0Last Post: 11-12-2008, 03:14 PM -
Putting code together.
By newbee in forum New To JavaReplies: 3Last Post: 04-17-2008, 03:53 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks