How to solve this Jcomboboxes problem for library management system?

0 votes
asked Nov 22, 2016 in Java Swing by md_nayeem (400 points)

i am now working with three combobox.if i select compurter from first combobox depertment then in the second combobox it is select all the semesters.
And the code is working perfectly.
Java Code:

String[] dep={"Select Depertment","Compurter","Civil","Electrical","Telecom"};
String[] Compurter={"FirstSemester","SecondSemester","ThirdSemester","FourthSemester","FifthSemester","SixthSemester","SeventhSemester"};
String[] Civil={"FirstSemester","SecondSemester","ThirdSemester","FourthSemester","FifthSemester","SixthSemester","SeventhSemester"};
String[] Electrical={"FirstSemester","SecondSemester","ThirdSemester","FourthSemester","FifthSemester","SixthSemester","SeventhSemester"};
String[] Telecom={"FirstSemester","SecondSemester","ThirdSemester","FourthSemester","FifthSemester","SixthSemester","SeventhSemester"};

divcomboDepertment.removeAllItems();

    for(int i=0; i< dep.length;i++)
    {
    divcomboDepertment.addItem(dep[i]);
    }   

private void divcomboDepertmentItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
divcomboSemester.removeAllItems();

    if(divcomboDepertment.getSelectedIndex() !=0)
    {
        String[] c;

        if (divcomboDepertment.getSelectedIndex()==1)
        {
            c=Compurter;
        }
        else if(divcomboDepertment.getSelectedIndex()==2)
        {
            c =Civil;
        }
        else if(divcomboDepertment.getSelectedIndex()==3)
        {
            c=Electrical;
        }

       else
        {
            c=Telecom;
        }

        for(int i=0; i<c.length; i++)
        {
            divcomboSemester.addItem(c[i]);
        }
    }

but now after select the semesters i want to select again all the books from book combobox by select all semesters one by one and when i click a semester all the semester book will appear in the book combobox.i am coding like this for this part of program.
Java Code:
for(int i=0; i< Compurter.length;i++)
{
divcomboBook.addItem(Compurter[i]);
}
private void divcomboSemesterItemStateChanged(java.awt.event.ItemEvent evt) {
// TODO add your handling code here:
divcomboBook.removeAllItems();

    if(divcomboSemester.getSelectedIndex() !=0)
    {
        String[] b;

        if (divcomboSemester.getSelectedIndex()==1)
        {
            b=FirstSemester;
        }
        else if(divcomboSemester.getSelectedIndex()==2)
        {
            b =SecondSemester;
        }
        else if(divcomboSemester.getSelectedIndex()==3)
        {
            b=ThirdSemester;
        }
       else if(divcomboSemester.getSelectedIndex()==4)
        {
            b=FourthSemester;
        }
       else if(divcomboSemester.getSelectedIndex()==5)
        {
            b=FifthSemester;
        }
       else if(divcomboSemester.getSelectedIndex()==6)
        {
            b=SixthSemester;
        }
       else
        {
            b=SeventhSemester;
        }

        for(int i=0; i<b.length; i++)
        {
            divcomboBook.addItem(b[i]);
        }
    }     

}

But this part of this program is not working perfectly.when i select computer from depertment combobox then semester is selecting perfectly.but after select the semester the books are not loading perfectly in the third book combobox.now how can i fix this problem.
click in the downlink for see my problem Screenshot

https://s16.postimg.org/fzgcixvfp/Untitled.png

Please log in or register to answer this question.

722 questions

656 answers

179 comments

4,747 users

Welcome to IDB Scholars Forum, where you can ask questions and receive answers from other members of the community. It's 100% free.
আইডিবি স্কলারস ফোরামে আপনাকে স্বাগত - প্রোগ্রামিং, ডিজাইন, ডেভেলপমেন্ট, ব্লগিং, ইন্টারনেটসহ তথ্য প্রযুক্তির যাবতীয় বিষয় নিয়ে আলোচনার একটি মুক্ত মঞ্চ হলো এই ফোরাম । এখানে আইসিটি বিষয়ক আপনার প্রশ্ন, উত্তর এবং অভিজ্ঞতা শেয়ার করুন, আলোচনা করুন এবং সমাধান নিন। দেশের তরুণ প্রজন্মকে আইসিটিতে আগ্রহী করাই আমাদের মূল লক্ষ্য।
** ইংলিশ বা বাংলা যে কোনো ভাষায় আপনি এই ফোরামে আলোচনা করতে পারবেন। তবে বাংলাকে ইংরেজি অক্ষরে লিখবেন না।
  1. tulbadex

    110 points

    0 answers

  2. JettaQoa3381

    100 points

    0 answers

  3. clutch7conga

    100 points

    0 answers

  4. WhitneyMauer

    100 points

    0 answers

  5. pajamazipper55

    100 points

    0 answers

...