2013-11-21 53 views
0

在我的驅動程序,它讓我無法找到符號錯誤:Java錯誤:找不到符號[方法.addJob]和[方法.searchR]

「的java:201:錯誤:無法找到符號report.setText (list1.searchR(in));「

「java:257:error:can not find symbol list5.addJob(n2.getText(),」「+(rand5 ++),t,0);」

import javax.swing.*; 
import java.awt.*; 
import java.awt.event.*; 

public class MenuDemo extends JFrame implements ActionListener{ 

    indList list1= new indList(); 
    indList list3= new indList(); 
    indList list4= new indList(); 
    indList list5= new indList(); 
    indList list6= new indList(); 

    public static int rand=1000; 
    public static int rand2=1000; 
    public static int rand3=1000; 
    public static int rand4=1000; 
    public static int rand5=1000; 
    String ty[] = {"SAB", "Aramco","Sabic","JANA","alMuhaidib"}; 
    JComboBox acty1 =new JComboBox(ty); 

    JMenu me=new JMenu("Employer"); 
    JMenuItem mep= new JMenuItem("Post Needed Jobs"); 
    JMenuItem mex=new JMenuItem("Exit"); 

    JMenu ms=new JMenu("Job Seeker"); 
    JMenuItem msf= new JMenuItem("Find Available Jobs"); 
    JMenuItem msa= new JMenuItem("Assign to a New Job"); 

    JMenuBar bar=new JMenuBar(); 


    //// post jobs 

    JLabel l1=new JLabel ("Your organization name:", JLabel.CENTER); 

    JLabel l2=new JLabel ("The job title needed is:", JLabel.CENTER); 
    JTextField n2 =new JTextField(50); 

    JButton b1=new JButton("Submit"); 
    JButton b2=new JButton("Cancel"); 

    JPanel empp1=new JPanel(new GridLayout(3,2)); 


    //////////// Assign 

    JLabel lll4=new JLabel("The job title that you want to request for:", JLabel.CENTER); 
    JTextField nnn3=new JTextField(50); 

    JLabel lll5=new JLabel("Your name:", JLabel.CENTER); 
    JTextField nnn4=new JTextField(30); 

    JLabel lll6=new JLabel("ID:", JLabel.CENTER); 
    JTextField nnn5=new JTextField(10); 

    JLabel lll7=new JLabel("Phone number:", JLabel.CENTER); 
    JTextField nnn6=new JTextField(10); 

    JLabel lll8=new JLabel("Email address:", JLabel.CENTER); 
    JTextField nnn7=new JTextField(50); 

    JButton bbb3=new JButton("Send Request"); 
    JButton bbb4=new JButton("Cancel"); 

    JPanel sap2=new JPanel(new GridLayout(6,2)); 

    ////////////// report 

    JTextArea report =new JTextArea(15,40); 
    JPanel panel3= new JPanel(new FlowLayout()); 
    Font font = new Font("Times New Romman", Font.BOLD, 30); 

的MenuDemo類:

public MenuDemo(){ 

    setLayout(new FlowLayout()); 
    setTitle("Job Program"); 
    setSize(600,600); 
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    empp1.add(l1); 
    empp1.add(acty1); 
    empp1.add(l2); 
    empp1.add(n2); 
    empp1.add(b1); 
    b1.addActionListener(this); 
    empp1.add(b2); 
    b2.addActionListener(this); 

    empp1.setVisible(false); 
    add(empp1); 


    /////////// result assign 
    sap2.add(lll4); 
    sap2.add(nnn3); 
    sap2.add(lll5); 
    sap2.add(nnn4); 
    sap2.add(lll6); 
    sap2.add(nnn5); 
    sap2.add(lll7); 
    sap2.add(nnn6); 
    sap2.add(lll8); 
    sap2.add(nnn7); 
    sap2.add(bbb3); 
    bbb3.addActionListener(this); 
    sap2.add(bbb4); 
    bbb4.addActionListener(this); 

    sap2.setVisible(false); 
    add(sap2); 

    ///////// menu 

    me.add(mep); 
    me.add(mex); 
    mep.addActionListener(this); 
    mex.addActionListener(this); 
    bar.add(me); 

    ms.add(msf); 
    ms.add(msa); 
    msf.addActionListener(this); 
    msa.addActionListener(this); 
    bar.add(ms); 

    setJMenuBar(bar); 

    ////////// 

     Font fnt = new Font("Arial", Font.BOLD, 14);  
     panel3.add(new JLabel ("The Result of search:")); 
     JScrollPane scrolpane = new JScrollPane(report); 
     report.setFont(fnt); 

     scrolpane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); 
     scrolpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); 

     panel3.add(scrolpane); 
     panel3.setVisible(false); 
     add(panel3); 

     setVisible(true); 


} 



public static void main(String[] args) 
{ 
    MenuDemo jp=new MenuDemo(); 
} 

    public void actionPerformed(ActionEvent e) 
    { 

     report.setText(""); 
     String c=e.getActionCommand(); 


     if(c.equals("Post Needed Jobs")) 
     { 
      empp1.setVisible(true); 
      panel3.setVisible(false); 
      sap2.setVisible(false); 
     } 

     else if(c.equals("Exit")) 
     { 

     JOptionPane.showMessageDialog(null,"Thank You for using Job Program"); 
      System.exit(0); 
     } 

     else if(c.equals("Find Available Jobs")) 
     { 

      empp1.setVisible(false); 
      panel3.setVisible(true); 
      sap2.setVisible(false); 

      String in= JOptionPane.showInputDialog("Enter Industry To Search in :[SAB, Aramco,Sabic,JANA,alMuhaidib]"); 
       if(in.equalsIgnoreCase("SAB")) 
       { 

         report.setText(""); 

線201:

     report.setText(list1.searchR(in)) ; 
       } 
       if(in.equalsIgnoreCase("Aramco")) 
       { 

         report.setText(""); 
         report.setText(list2.searchR(in)) ; 
       } 
       if(in.equalsIgnoreCase("Sabic")) 
       { 

         report.setText(""); 
         report.setText(list3.searchR(in)) ; 
       } 
       if(in.equalsIgnoreCase("JANA")) 
       { 

         report.setText(""); 
         report.setText(list4.searchR(in)) ; 
       } 
       if(in.equalsIgnoreCase("alMuhaidib")) 
       { 

         report.setText(""); 
         report.setText(list5.searchR(in)) ; 
       } 

       else 

       JOptionPane.showMessageDialog(null,"Enter correct industry in this list:[SAB, Aramco,Sabic,JANA,alMuhaidib]"); 
     } 

     else if(c.equals("Submit")) 
     { 
      String t= (String)acty1.getSelectedItem(); 
      String in=JOptionPane.showInputDialog("Enter Industry To Add in :[SAB, Aramco,Sabic,JANA,alMuhaidib]"); 

      if(in.equalsIgnoreCase("SAB")) 
      { 
       list1.addJob(n2.getText(),""+(rand++) ,t,0); 
       n2.setText(""); 
      } 
      else if(in.equalsIgnoreCase("Aramco")) 
      { 
       list2.addJob(n2.getText(),""+(rand2++) ,t,0); 
      } 
      else if(in.equalsIgnoreCase("Sabic")) 
      { 
       list3.addJob(n2.getText(),""+(rand3++) ,t,0); 
      } 
      else if(in.equalsIgnoreCase("JANA")) 
      { 
       list4.addJob(n2.getText(),""+(rand4++) ,t,0); 
      } 
      else if(in.equalsIgnoreCase("alMuhaidib")) 
      { 

線257:

   list5.addJob(n2.getText(),""+(rand5++) ,t,0); 
      } 
      else 
      { 
       JOptionPane.showMessageDialog(null,"Enter Correct Industry:[SAB, Aramco,Sabic,JANA,alMuhaidib]"); 
      } 
     } 

    } 
} 

的IndLisit類別:

import java.awt.*; 
import javax.swing.*; 
import java.awt.event.*; 

public class indList { 

    public indNode head, tail; 

    public indList(){ 
     head=tail=null; 
    } 

    public boolean isEmpty(){ 
     return head==null; 
    }  

    public void addind(String j, String i) 
    { 


     if(head==null) 
     { 

      head=tail=new indNode(j); 
      JOptionPane.showMessageDialog(null,"Industry added"); 
     } 

     else if (head!=null) 
     { 
    // indNode tmp; 

     // for(tmp=head;tmp!=null && !(tmp.info1.equalsIgnoreCase(i)) ;tmp=tmp.next) ; 
     //   if(tmp== null) 
        { 
         tail.next=new indNode(j); 
         tail=tail.next; 
         JOptionPane.showMessageDialog(null,"Industry Added");  
        } 
     /* else 

      JOptionPane.showMessageDialog(null,"This job title Have been added Before"); */ 


    } 
    } 



    public String printJob() 
     { 
      indNode tmp; 
      if(head==null) 
      return " The industry List is Empty "; 
      else 
      { 
       String r=""; 
        for(tmp=head;tmp!=null ;tmp=tmp.next)  
        r+="\n============\n The Industry:"+tmp.info2; 
         return r; 
      } 

     } 

      public boolean searchind(String j) 
    { 
     indNode tmp; 

      for(tmp=head;tmp!=null && !(tmp.info2.equalsIgnoreCase(j)) ;tmp=tmp.next) ; 
      //JOptionPane.showMessageDialog(null,"The Account results: "+ tmp != null); 
       if (tmp == null) 
        return false; 
        else 
        return true;  


    } 


} 
+0

你的問題不清楚!使用簡單的文字,並逐步解釋如何達到錯誤 –

+1

什麼是indList? – holap

+0

indList類在哪裏? –

回答

1

indList類沒有searchR或addJob方法。這會導致我認爲的編譯錯誤。

public void searchR(String input) { 
    // do something useful here 
} 

public void addJob(String input, String id, String selectedItem, int pos) { 
    // do something useful here 
} 

我不知道你的代碼應該這樣做,所以即使我想要,我也不能提供上述方法的實現。

有很多的你的代碼的問題,您可以修復,使其更具可讀性和可維護性更好:

使用有意義的變量名。而不是'n2'給出一個描述該字段含義的名稱。

類名以大寫字母開頭。儘量避免不需要的縮寫。同時避免提到數據結構,所以'行業'而不是'indList'和'IndustryNode'而不是'indNode'。

字段是對象引用自動初始化爲空,這樣你就可以

public IndustryNode head; 
public IndustryNode tail; 

有更多的改進可能取代

public indNode head, tail; 
public indList(){ 
    head=tail=null; 
} 

但這是一個開始。

相關問題