Results 1 to 6 of 6
- 03-19-2013, 07:32 PM #1
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 590
- Rep Power
- 6
error says "can not find method.....
1) when I have an inner clase called:
2) and I declare the next field in the main clase:Java Code:public class SingleRoomInfo { // principle class holds all room info private JLabel panelref,firstname, lastname, pianoicon, roomfree, reserved ,endtime; public void setFirstName(JLabel fn) { firstname = fn; } // more methods etc. }
private SingleRoomPanel[] singleroompanel;
3) and Initialize the above like this:
4) why I get an error when saying in a other methodJava Code:singleroompanel = new SingleRoomPanel[MAXROOM]; // initialize the for (int i = 0; i < singleroompanel.length; i++) { // roominfopanrl array singleroompanel[i] = new SingleRoomPanel(); }
singleroompanel[panelcount].setFirstName(new JLabel("firstname"));
(error says "can not find method setFirstName")
why can't programming be easier......
- 03-19-2013, 07:52 PM #2
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 688
- Rep Power
- 1
Re: error says "can not find method.....
Please show the offending code in the context in which the error occurred.
Regards,
JimThe Java™ Tutorial
YAT -- Yet Another Typo
- 03-19-2013, 07:56 PM #3
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 590
- Rep Power
- 6
Re: error says "can not find method.....
It is a little messy, still working on it
Java Code:/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package roomassigment; import java.awt.Dimension; import javax.swing.*; /** * * */ public class SingleRoomPanel extends JPanel { private Box bh1, bh2, bh3, bv1, bv2; private JLabel firstname, lastname, endtime, reserved; private JProgressBar TimeBar; private SingleRoomPanel[] singleroompanel; private final static int MAXROOM = 90; private int panelcount; public static void main(String[] args) { } public SingleRoomPanel() { panelcount = 0; singleroompanel = new SingleRoomPanel[MAXROOM]; // initialize the for (int i = 0; i < singleroompanel.length; i++) { // roominfopanrl array singleroompanel[i] = new SingleRoomPanel(); } } public JPanel CreateSingleRoomPanel(JPanel jp) { jp.setLayout(new BoxLayout(jp, BoxLayout.LINE_AXIS)); firstname = new JLabel("firstname"); singleroompanel[panelcount].setFirstName(new JLabel("firstname")); TimeBar = new JProgressBar(0, 60); TimeBar.setPreferredSize( new Dimension( 5, 60 ) ); TimeBar.setStringPainted(false); TimeBar.setValue(0); TimeBar.setOrientation(SwingConstants.VERTICAL); TimeBar.setStringPainted(true); bh1 = Box.createHorizontalBox(); bh2 = Box.createHorizontalBox(); bh3 = Box.createHorizontalBox(); bv1 = Box.createVerticalBox(); bv2 = Box.createVerticalBox(); jp.setBorder(BorderFactory.createEmptyBorder(0, 10, 10, 10)); bh1.add(firstname); bh1.add(Box.createGlue()); bh1.add(TimeBar); bh2.add(lastname); bh2.add(Box.createGlue()); bh3.add(Box.createHorizontalStrut(25)); bh3.add(reserved); bh3.add(Box.createGlue()); bh3.add(endtime); bv1.add(bh1); bv1.add(bh2); bv1.add(Box.createVerticalStrut(5)); bv1.add(bh3); bv1.add(Box.createVerticalStrut(2)); jp.add(bv1); panelcount++; return jp; } public void setRoompanel(int panelindex, String fn, String ln, String et, Boolean res) { } public class SingleRoomInfo { // principle class holds all room info private JLabel panelref,firstname, lastname, pianoicon, roomfree, reserved ,endtime; public void setFirstName(JLabel fn) { firstname = fn; } public JLabel getFirstName() { return firstname; } public void setLastName(JLabel ln) { lastname = ln; } public JLabel getLastName() { return lastname; } public void setPianoIcon(JLabel pf) { pianoicon = pf; } public JLabel getPianoIcon() { return pianoicon; } public void setEndTime(JLabel et) { endtime = et; } public JLabel getEndTime() { return endtime; } public void setReserved(JLabel rs) { reserved = rs; } public JLabel getReserved() { return reserved; } } }
- 03-19-2013, 07:57 PM #4
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 590
- Rep Power
- 6
Re: error says "can not find method.....
line 44 is the accused one
- 03-19-2013, 08:03 PM #5
Senior Member
- Join Date
- Jan 2013
- Location
- United States
- Posts
- 688
- Rep Power
- 1
Re: error says "can not find method.....
Because the method is in SingleRoomInfo not SingleRoomPanel.
Regards,
JimThe Java™ Tutorial
YAT -- Yet Another Typo
- 03-19-2013, 08:11 PM #6
Senior Member
- Join Date
- Dec 2007
- Location
- Spain
- Posts
- 590
- Rep Power
- 6
Similar Threads
-
How Does Java Find the "main" Method?
By bobg in forum New To JavaReplies: 3Last Post: 05-16-2011, 04:09 AM -
Receiving error "Could not find the main class"
By Kalpesh in forum New To JavaReplies: 2Last Post: 02-02-2011, 06:31 PM -
Error message "could not find the main class"
By srwpchelp in forum New To JavaReplies: 8Last Post: 12-23-2010, 09:15 PM -
Compiling/Running Project in Command Line: "Could not find main class" Error
By Yasemin Gokce in forum New To JavaReplies: 1Last Post: 06-30-2009, 02:32 PM -
"Cannont find symbol Constructor" error
By Welsh in forum New To JavaReplies: 7Last Post: 01-25-2008, 12:12 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks