java - Swing中的多个依赖组合框
问题描述
我的学生注册代码要求,根据所选学科选择课程。
例如:学科毕业后启用多个流,如果我们选择“法律”,则必须在课程组合框中显示与法律相关的课程。我已经实现了依赖于学科组合框的流组合框。所有这些组合框的任何最佳方法。
private void Combo_desciplineActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(Combo_descipline.getSelectedItem().equals("Certificate")){
Combo_stream.removeAllItems();
Combo_stream.addItem("Agriculture");
Combo_stream.addItem("Fashion Design and Technology");
Combo_stream.addItem("Film Technology");
Combo_stream.setSelectedItem(null);
}
else if(Combo_descipline.getSelectedItem().equals("Diploma")){
Combo_stream.removeAllItems();
Combo_stream.addItem("Agriculture");
Combo_stream.addItem("Fashion Design and Technology");
Combo_stream.addItem("Film Technology");
Combo_stream.addItem("Healthcare and Allied Sciences");
Combo_stream.addItem("Management");
Combo_stream.addItem("Media and Mass Communication");
Combo_stream.addItem("Pharmacy");
Combo_stream.addItem("Polytechnic");
Combo_stream.addItem("Yoga and Vedic Science");
Combo_stream.setSelectedItem(null);
}
else if(Combo_descipline.getSelectedItem().equals("Integreted")){
Combo_stream.removeAllItems();
Combo_stream.addItem("Agriculture");
Combo_stream.addItem("Arts");
Combo_stream.addItem("Commerce");
Combo_stream.addItem("Computer Science and IT");
Combo_stream.addItem("Education");
Combo_stream.addItem("Engineering and Technology");
Combo_stream.addItem("Fashion Design and Technology");
Combo_stream.addItem("Law");
Combo_stream.addItem("Management");
Combo_stream.addItem("Science");
Combo_stream.setSelectedItem(null);
}
else if(Combo_descipline.getSelectedItem().equals("Lateral Entry")){
Combo_stream.removeAllItems();
Combo_stream.addItem("Engineering and Technology");
Combo_stream.addItem("Fashion Design and Technology");
Combo_stream.addItem("Polytechnic");
Combo_stream.setSelectedItem(null);
}
else if(Combo_descipline.getSelectedItem().equals("PG")){
Combo_stream.removeAllItems();
Combo_stream.addItem("Agriculture");
Combo_stream.addItem("Arts");
Combo_stream.addItem("Commerce");
Combo_stream.addItem("Computer Science and IT");
Combo_stream.addItem("Education");
Combo_stream.addItem("Engineering and Technology");
Combo_stream.addItem("Fashion Design and Technology");
Combo_stream.addItem("Film Technology");
Combo_stream.addItem("Healthcare and Allied Sciences");
Combo_stream.addItem("Home Science");
Combo_stream.addItem("Law");
Combo_stream.addItem("Management");
Combo_stream.addItem("Media and Mass Communication");
Combo_stream.addItem("Pharmacy");
Combo_stream.addItem("Physiotherapy");
Combo_stream.addItem("Science");
Combo_stream.addItem("Yoga and Vedic Science");
Combo_stream.setSelectedItem(null);
}
else if(Combo_descipline.getSelectedItem().equals("PG Diploma")){
Combo_stream.removeAllItems();
Combo_stream.addItem("Agriculture");
Combo_stream.addItem("Arts");
Combo_stream.addItem("Computer Science and IT");
Combo_stream.addItem("Fashion Design and Technology");
Combo_stream.addItem("Film Technology");
Combo_stream.addItem("Healthcare and Allied Sciences");
Combo_stream.addItem("Home Science");
Combo_stream.addItem("Law");
Combo_stream.addItem("Management");
Combo_stream.addItem("Media and Mass Communication");
Combo_stream.addItem("Pharmacy");
Combo_stream.addItem("Science");
Combo_stream.addItem("Yoga and Vedic Science");
Combo_stream.setSelectedItem(null);
}
else if(Combo_descipline.getSelectedItem().equals("Phd/MPhil")){
Combo_stream.removeAllItems();
Combo_stream.addItem("Agriculture");
Combo_stream.addItem("Arts");
Combo_stream.addItem("Commerce");
Combo_stream.addItem("Computer Science and IT");
Combo_stream.addItem("Education");
Combo_stream.addItem("Engineering and Technology");
Combo_stream.addItem("Fashion Design and Technology");
Combo_stream.addItem("Film Technology");
Combo_stream.addItem("Healthcare and Allied Sciences");
Combo_stream.addItem("Home Science");
Combo_stream.addItem("Law");
Combo_stream.addItem("Management");
Combo_stream.addItem("Media and Mass Communication");
Combo_stream.addItem("Pharmacy");
Combo_stream.addItem("Science");
Combo_stream.addItem("Yoga and Vedic Science");
Combo_stream.setSelectedItem(null);
}
else if(Combo_descipline.getSelectedItem().equals("UG")){
Combo_stream.removeAllItems();
Combo_stream.addItem("Agriculture");
Combo_stream.addItem("Arts");
Combo_stream.addItem("Commerce");
Combo_stream.addItem("Computer Science and IT");
Combo_stream.addItem("Education");
Combo_stream.addItem("Engineering and Technology");
Combo_stream.addItem("Fashion Design and Technology");
Combo_stream.addItem("Film Technology");
Combo_stream.addItem("Healthcare and Allied Sciences");
Combo_stream.addItem("Home Science");
Combo_stream.addItem("Law");
Combo_stream.addItem("Management");
Combo_stream.addItem("Media and Mass Communication");
Combo_stream.addItem("Pharmacy");
Combo_stream.addItem("Physiotherapy");
Combo_stream.addItem("Science");
Combo_stream.addItem("Yoga and Vedic Science");
Combo_stream.setSelectedItem(null);
}
}
它应该如下所示:
解决方案
推荐阅读
- django - 如何在 django-restfmework 的序列化程序中显示子类别
- r - R - 我应该如何在 timevis 中格式化 BCE 日期?
- mongodb - MongoDB:查询集合并按另一个集合中的数组过滤
- reactjs - Flutter 中类似 React 的条件渲染
- android - 问题将 Nativescript angular 升级到 angular 9:在 android 上运行
- string - Out-GridView(powershell 4)中的额外空列?
- json - JSON数据未在IONIC和ANJULAR中首次获取
- android - 如何为基隆迪语做语言翻译?
- c - 将 -static 与 GCC 一起使用可以保证我的 C 程序可以跨 x86 发行版运行吗?
- css - 使用 Selenium Web 驱动程序获取产品名称时出现 InvalidSelector 错误