مشاهدة النتائج 1 الى 2 من 2
  1. #1

    سؤال ساعدوني يا جماعه لازم اسلم البروجكت اليوم

    حد يقول لي شو الغلط في هذا الكود


    //----------------------------
    import java.util.*;
    import java.io.*;
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.FlowLayout;

    //-------------------------------
    public class AM_AH extends JFrame implements ActionListener, ItemListener {

    JFileChooser file_ch = new JFileChooser();
    JPanel check_cp = new JPanel();
    JPanel Button_p = new JPanel();
    JPanel tbl_P = new JPanel();
    JTable table;
    private Object[][] insInfo = new Object[3][5];
    String [] Days = {"UW", "MR", "T"};
    String[] colHeader = {"weekDay", "2:00~3:15", "3:45~5:00", "5:30~6:45", "7:15~8:30"};

    public AM_AH ()
    {

    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );

    this.setResizable(true);

    this.setLocation(150, 150);

    this.setSize(300, 150);

    this.setTitle("CECS instructros schedule");

    this.setLayout(new FlowLayout(FlowLayout.RIGHT));

    //Button_p.add(drawButton());

    // Button_p.add(drawCloseButton());

    Button_p.setSize(60 , 80);

    this.add(Button_p);

    table = new JTable(insInfo, colHeader);

    tbl_P.add(new JScrollPane(table));

    tbl_P.setSize(300, 200);

    this.add( tbl_P);

    check_cp.setVisible(false);

    this.add(check_cp);

    this.setVisible(true);

    adddays();
    }
    //------------------------------------
    public static void main(String[] args)
    {

    AM_AH Jproj = new AM_AH();
    }

    //-----------------------------
    private Object adddays()
    {
    for (int i = 0; i < 3; i++)
    {
    insInfo [i][0] = Days[i];
    }
    return insInfo;
    }
    //---------------------

    /* private JButton drawButton()
    {

    JButton btnF = new JButton("File");
    btnF.addActionListener(this);
    return btnF;
    }*/
    //-----------------------------
    /*private JButton drawCloseButton()
    {

    JButton btnC = new JButton("Close");
    btnC.addActionListener(this);
    return btnC;
    }*/
    //-----------------------------------

    public JMenuBar createMenuBar()
    {

    JMenuBar mbar = new JMenuBar();
    setJMenuBar(mbar);

    JMenu fileMenu = new JMenu("File");
    mbar.add(fileMenu);

    JMenuItem OpenMenu = new JMenuItem("Open");
    fileMenu.add(OpenMenu);
    OpenMenu.setActionCommand("open");
    OpenMenu.addActionListener(this);

    JMenuItem ExitMenu = new JMenuItem("Exit");
    fileMenu.add(ExitMenu);
    ExitMenu.setActionCommand("exit");
    ExitMenu.addActionListener(this);

    return mbar;
    } //end of createmenu


    //-------------------------------------
    public void actionPerformed(ActionEvent a)
    {
    if (a.getActionCommand().equals("Files"))
    {
    int num = file_ch.showOpenDialog(AM_AH.this);
    if (num == JFileChooser.APPROVE_OPTION)
    {
    File f_1 = file_ch.getSelectedFile();
    // readFile(f_1.getAbsolutePath());

    }
    }
    else if(a.getActionCommand().equals("Close"))
    {
    this.dispose();/*chk this*/
    }

    }
    //------------------------------

    private void checkBox(String[] Drs)
    {

    Set hashSet = new HashSet(Arrays.asList(Drs));
    String[] asma = (String[]) hashSet.toArray(new String[hashSet.size()]);

    for (int i = 0; i < asma.length; i++)
    {
    if (asma[i] != null)
    {
    System.out.println(asma[i]);
    JCheckBox check_box = new JCheckBox(asma[i]);
    check_box.setSelected(true);
    check_box.addItemListener(this);
    check_cp.add(check_box);
    }

    }

    check_cp.setVisible(true);
    }
    //-----------------------------------------------

    //read file method
    public void Reader(String f_2)

    {

    String aline;//
    String[] input;//
    String[] Drs = new String[10];
    String Subject;
    String Instructors;
    int i = 0;

    try {

    FileInputStream fin = new FileInputStream(f_2);
    BufferedReader br = new BufferedReader(new InputStreamReader(fin));
    String pattern = "@|=|-";//whta the token do.......what is this sequnce do
    while ((aline = br.readLine()) != null)
    {

    input = aline.split(pattern);
    if (aline.length() > 0)
    {

    Instructors = input[0];
    Drs[i] = Instructors;
    Subject = Instructors.charAt(0) + ":-" + input[1] + "/" + input[2];
    setResults(Subject, input[3], input[4]);
    i++;
    }

    }
    }
    catch (Exception e)
    {
    e.printStackTrace();
    }

    checkBox(Drs);

    }
    //------------------------------
    private void setResults(String Subject, String Days, String time)

    {

    int[] row= null;
    int []colm = null;
    String val;

    row = new int[getRow(Days).length];
    row = getRow(Days);

    colm = new int[getColumns(time).length];
    colm = getColumns(time);

    for (int i = 0; i < row.length; i++)
    {
    for (int j = 0; j < colm.length; j++)
    {
    val = getCellValue(row[i], colm[j]);
    table.setValueAt(Subject.concat(val), row[i], colm[j]);
    }
    }

    }



    //-------------------------------------
    private String getCellValue(int row, int colm)
    {
    String value;
    value = (String) table.getValueAt(row, colm);

    if (value == null)
    {
    value = "";
    }
    return value;
    }
    //---------------------------

    public int[] getRow(String Days)
    {
    int[] row = new int[Days.length()];
    for (int n = 0; n < Days.length(); n++)

    {
    switch (Days.charAt(n))
    {
    case "UW":
    row[n] = 0;
    break;
    case "MR":
    row[n] = 1;
    break;
    case 'T':
    row[n] = 2;
    break;
    }
    }
    return row;
    }
    //----------------------
    private int[] getColumns(String time)
    {
    int[] colm = null;

    if ("2:00~3:15".equals(time))
    {
    colm = new int[1];
    colm[0] = 1;
    } else if ("3:45~5:00".equals(time))
    {
    colm = new int[1];
    colm[0] = 2;
    } else if ("5:30~6:45".equals(time))
    {
    colm = new int[1];
    colm[0] = 3;
    } else if ("7:15~8:30".equals(time))
    {
    colm = new int[1];
    colm[0] = 4;
    } else if ("2:00~5:00".equals(time))
    {
    colm = new int[2];
    colm[0] = 1;
    colm[1] = 2;

    } else if ("5:30~8:30".equals(time))
    {
    colm = new int[2];
    colm[0] = 3;
    colm[1] = 4;

    }

    return colm;
    }
    //-------------------------------

    public void itemStateChanged(ItemEvent a)

    {
    JCheckBox Boxbox = (JCheckBox) a.getItemSelectable();
    removeContent(Boxbox.getText().charAt(0));
    }
    //----------------------------------
    private void removeContent(char rc)
    {
    String value22;
    for (int n = 0; n < 5; n++)
    {
    for (int m = 1; m < 5; m++)
    {
    value22 = getCellValue(n, m);
    if (value22.indexOf(rc) >= 0 && value22.length() > 6)
    {
    System.out.println(value22.replaceAll(value22.subs tring(value22.indexOf(rc), 11), " "));
    value22 = value22.replace(value22.substring(value22.indexOf( rc), 11), "");

    table.setValueAt("", n, m);
    table.setValueAt(value22, n, m);
    }
    }
    }
    }
    }


    لما اسوي له كومبايل يعطيني هذوله المسجين


    AM_AH.java:252: incompatible types
    found : java.lang.String
    required: char
    case "UW":
    ^
    AM_AH.java:255: incompatible types
    found : java.lang.String
    required: char
    case "MR":
    ^
    اخر تعديل كان بواسطة » almazuoona في يوم » 14-05-2009 عند الساعة » 17:09


  2. ...

  3. #2
    الغلط هة يجب switch case يجب أن يكون عند case عدد او charو ليس string
    string توضع بين " "
    char j;au fdk ' '

بيانات عن الموضوع

الأعضاء الذين يشاهدون هذا الموضوع

عدد زوار الموضوع الآن 1 . (0 عضو و 1 ضيف)

المفضلات

collapse_40b قوانين المشاركة

  • غير مصرّح لك بنشر موضوع جديد
  • غير مصرّح بالرد على المواضيع
  • غير مصرّح لك بإرفاق ملفات
  • غير مصرّح لك بتعديل مشاركاتك
  •  

مكسات على ايفون  مكسات على اندرويد  Rss  Facebook  Twitter