SlideShare a Scribd company logo
1 of 7
Download to read offline
How do I add a ComboBox to this, underneath "Enter Student ID" that says the following?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Registration extends JFrame {
private JDesktopPane theDesktop;
public Registration(){
theDesktop = new JDesktopPane();
JMenuBar bar = new JMenuBar();
JMenu fileMenu = new JMenu("Course");
JMenuItem addCourseItem = new JMenuItem("Add Course");
fileMenu.add(addCourseItem);
JMenu tuitionMenu = new JMenu("Tuition");
JMenuItem calculateItem = new JMenuItem("Calculate Tuition");
JMenuItem printTuitionItem = new JMenuItem("Print Tuition");
JMenuItem printSchedulesItem = new JMenuItem("Print Student Schedules");
tuitionMenu.add(calculateItem);
tuitionMenu.add(printTuitionItem);
tuitionMenu.add(printSchedulesItem);
JMenu exitMenu = new JMenu("Exit");
JMenuItem exitProgramItem = new JMenuItem("Exit Program");
exitMenu.add(exitProgramItem);
addCourseItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
JInternalFrame frame = new JInternalFrame("Enter Student ID", true, true, true, true);
ReadPanel rp = new ReadPanel();
frame.add(rp);
frame.pack();
theDesktop.add(frame);
frame.setVisible(true);
}
});
exitProgramItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
System.exit(0);
}
});
calculateItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
}
});
printTuitionItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
}
});
printSchedulesItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
}
});
bar.add(fileMenu);
bar.add(tuitionMenu);
bar.add(exitMenu);
setJMenuBar(bar);
add(theDesktop);
}
public class ReadPanel extends Panel{
private JLabel findLabel;
private JTextField findField;
private JLabel buttonLabel;
private JButton submitButton;
public ReadPanel(){
findLabel = new JLabel("Enter Student ID");
findField = new JTextField(15);
buttonLabel = new JLabel("Select Course");
buttonLabel = new JLabel("Click to Add");
submitButton = new JButton("Submit");
setLayout(new GridLayout(2,2));
submitButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
System.out.println(findField.getText());
findField.setText("");
}
});
add(findLabel);
add(findField);
add(buttonLabel);
add(buttonLabel);
add(submitButton);
}
}
public static void main(String[] args){
Registration r1 = new Registration();
r1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
r1.setLocationRelativeTo(null);
r1.setSize(400,400);
r1.setVisible(true);
}
} Registration System Course Tuition Exit Course Panel Enter Student ID Select Course Click
to Add Select One Submit
Solution
//Changes added to Registration class in bold text
//Registration.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class Registration extends JFrame {
private JDesktopPane theDesktop;
public Registration(){
theDesktop = new JDesktopPane();
JMenuBar bar = new JMenuBar();
JMenu fileMenu = new JMenu("Course");
JMenuItem addCourseItem = new JMenuItem("Add Course");
fileMenu.add(addCourseItem);
JMenu tuitionMenu = new JMenu("Tuition");
JMenuItem calculateItem = new JMenuItem("Calculate Tuition");
JMenuItem printTuitionItem = new JMenuItem("Print Tuition");
JMenuItem printSchedulesItem = new JMenuItem("Print Student Schedules");
tuitionMenu.add(calculateItem);
tuitionMenu.add(printTuitionItem);
tuitionMenu.add(printSchedulesItem);
JMenu exitMenu = new JMenu("Exit");
JMenuItem exitProgramItem = new JMenuItem("Exit Program");
exitMenu.add(exitProgramItem);
addCourseItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
JInternalFrame frame =
new JInternalFrame("Student Registration",
true, true, true, true);
ReadPanel rp = new ReadPanel();
frame.add(rp);
frame.pack();
theDesktop.add(frame);
frame.setVisible(true);
}
});
exitProgramItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
System.exit(0);
}
});
calculateItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
}
});
printTuitionItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
}
});
printSchedulesItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
}
});
bar.add(fileMenu);
bar.add(tuitionMenu);
bar.add(exitMenu);
setJMenuBar(bar);
add(theDesktop);
}
public class ReadPanel extends Panel{
private JLabel findLabel;
private JTextField findField;
//Declare two separate labels and combo box
private JLabel buttonLabel1;
private JComboBoxcoursetBox;
private JLabel buttonLabel2;
private JButton submitButton;
public ReadPanel()
{
//Set gride layout of 3 rows and 2 columns
setLayout(new GridLayout(3,2));
//Set courses of array
String[] courses={"Select One","CS100","CS101","CS102"};
findLabel = new JLabel("Enter Student ID");
findField = new JTextField(15);
buttonLabel1 = new JLabel("Select Course");
coursetBox=new JComboBox(courses);
buttonLabel2 = new JLabel("Click to Add");
submitButton = new JButton("Submit");
submitButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae){
System.out.println(findField.getText());
findField.setText("");
//get text from the combo box of selected item
String courseName=(String) coursetBox.getSelectedItem();
System.out.println(courseName);
}
});
add(findLabel);add(findField);
add(buttonLabel1);add(coursetBox);
add(buttonLabel2);add(submitButton);
}
}
public static void main(String[] args){
Registration r1 = new Registration();
r1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
r1.setLocationRelativeTo(null);
r1.setSize(400,400);
r1.setVisible(true);
}
}
Sample output:
Click Add Course button

More Related Content

Similar to How do I add a ComboBox to this, underneath Enter Student ID tha.pdf

import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdfimport java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
venkt12345
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
martha leon
 
import java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdf
import java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdfimport java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdf
import java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdf
anupambedcovers
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
sudhirchourasia86
 
Im getting List Full when I try to add 2nd student.Driver..pdf
Im getting List Full when I try to add 2nd student.Driver..pdfIm getting List Full when I try to add 2nd student.Driver..pdf
Im getting List Full when I try to add 2nd student.Driver..pdf
forwardcom41
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
arvindarora20042013
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdf
flashfashioncasualwe
 
I hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdfI hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdf
apexelectronices01
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
forwardcom41
 

Similar to How do I add a ComboBox to this, underneath Enter Student ID tha.pdf (16)

Oop lecture9 10
Oop lecture9 10Oop lecture9 10
Oop lecture9 10
 
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdfimport java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
import java.awt.Color;import java.awt.Insets;import java.awt.Con.pdf
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
 
import java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdf
import java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdfimport java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdf
import java.awt.event.ActionEvent; import java.awt.event.ActionLis.pdf
 
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdfpackage net.codejava.swing.mail;import java.awt.Font;import java.pdf
package net.codejava.swing.mail;import java.awt.Font;import java.pdf
 
Im getting List Full when I try to add 2nd student.Driver..pdf
Im getting List Full when I try to add 2nd student.Driver..pdfIm getting List Full when I try to add 2nd student.Driver..pdf
Im getting List Full when I try to add 2nd student.Driver..pdf
 
Java!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdfJava!!!!!Create a program that authenticates username and password.pdf
Java!!!!!Create a program that authenticates username and password.pdf
 
Oop lecture6
Oop lecture6Oop lecture6
Oop lecture6
 
Oop lecture9
Oop lecture9Oop lecture9
Oop lecture9
 
Advance Java Programs skeleton
Advance Java Programs skeletonAdvance Java Programs skeleton
Advance Java Programs skeleton
 
How do i add a file menu to my java programSolutionHere goes .pdf
How do i add a file menu to my java programSolutionHere goes .pdfHow do i add a file menu to my java programSolutionHere goes .pdf
How do i add a file menu to my java programSolutionHere goes .pdf
 
Write a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdfWrite a GUI application to simulate writing out a check. The value o.pdf
Write a GUI application to simulate writing out a check. The value o.pdf
 
In Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdfIn Java Write a GUI application to simulate writing out a check. The.pdf
In Java Write a GUI application to simulate writing out a check. The.pdf
 
I hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdfI hope the below code is helpful to you, please give me rewards.im.pdf
I hope the below code is helpful to you, please give me rewards.im.pdf
 
Java questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdfJava questionI am having issues returning the score sort in numeri.pdf
Java questionI am having issues returning the score sort in numeri.pdf
 
011 more swings_adv
011 more swings_adv011 more swings_adv
011 more swings_adv
 

More from fathimahardwareelect

using the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdfusing the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdf
fathimahardwareelect
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
fathimahardwareelect
 
Question 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdfQuestion 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdf
fathimahardwareelect
 
List and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdfList and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdf
fathimahardwareelect
 
Please write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdfPlease write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdf
fathimahardwareelect
 
Please help me find my errors. I am lost as I know what the problem.pdf
Please help me find my errors. I am lost as I know what the problem.pdfPlease help me find my errors. I am lost as I know what the problem.pdf
Please help me find my errors. I am lost as I know what the problem.pdf
fathimahardwareelect
 
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdfIdentify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
fathimahardwareelect
 
How does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdfHow does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdf
fathimahardwareelect
 

More from fathimahardwareelect (20)

Which one of the following is NOT a social trend that is currently af.pdf
Which one of the following is NOT a social trend that is currently af.pdfWhich one of the following is NOT a social trend that is currently af.pdf
Which one of the following is NOT a social trend that is currently af.pdf
 
Which of the following is normally a major activity of materials man.pdf
Which of the following is normally a major activity of materials man.pdfWhich of the following is normally a major activity of materials man.pdf
Which of the following is normally a major activity of materials man.pdf
 
What is the role of civil society in promoting democracySolutio.pdf
What is the role of civil society in promoting democracySolutio.pdfWhat is the role of civil society in promoting democracySolutio.pdf
What is the role of civil society in promoting democracySolutio.pdf
 
What mechanism causes plant ion-uptake to acidify soilSolution.pdf
What mechanism causes plant ion-uptake to acidify soilSolution.pdfWhat mechanism causes plant ion-uptake to acidify soilSolution.pdf
What mechanism causes plant ion-uptake to acidify soilSolution.pdf
 
using the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdfusing the knowledge about experiments that are related to plant g.pdf
using the knowledge about experiments that are related to plant g.pdf
 
True or False Justify your answer.The concept of flooding is alwa.pdf
True or False Justify your answer.The concept of flooding is alwa.pdfTrue or False Justify your answer.The concept of flooding is alwa.pdf
True or False Justify your answer.The concept of flooding is alwa.pdf
 
True or False. If H is a subgroup of the group G then H is one of it.pdf
True or False.  If H is a subgroup of the group G then H is one of it.pdfTrue or False.  If H is a subgroup of the group G then H is one of it.pdf
True or False. If H is a subgroup of the group G then H is one of it.pdf
 
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdfTHE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
THE CODE HAS A SEGMENTATION FAULT BUT I CANNOT FIND OUT WHERE. NEED .pdf
 
Immunizations that the elderly need to receive on a yearly basis inc.pdf
Immunizations that the elderly need to receive on a yearly basis inc.pdfImmunizations that the elderly need to receive on a yearly basis inc.pdf
Immunizations that the elderly need to receive on a yearly basis inc.pdf
 
Question 11 Scarcity means O people need to use marginal analysis to .pdf
Question 11 Scarcity means O people need to use marginal analysis to .pdfQuestion 11 Scarcity means O people need to use marginal analysis to .pdf
Question 11 Scarcity means O people need to use marginal analysis to .pdf
 
Question 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdfQuestion 2 Sba Do you know something about the Statement Of Financ.pdf
Question 2 Sba Do you know something about the Statement Of Financ.pdf
 
Question 1. give the CC++ code that defines an empty 5 element arra.pdf
Question 1. give the CC++ code that defines an empty 5 element arra.pdfQuestion 1. give the CC++ code that defines an empty 5 element arra.pdf
Question 1. give the CC++ code that defines an empty 5 element arra.pdf
 
List and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdfList and explain all the components of company culture.Jackson, S..pdf
List and explain all the components of company culture.Jackson, S..pdf
 
Please write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdfPlease write 5-6 setences about each emotional intelligence capabili.pdf
Please write 5-6 setences about each emotional intelligence capabili.pdf
 
Please help me find my errors. I am lost as I know what the problem.pdf
Please help me find my errors. I am lost as I know what the problem.pdfPlease help me find my errors. I am lost as I know what the problem.pdf
Please help me find my errors. I am lost as I know what the problem.pdf
 
Negligence and intentional torts are subject to civil litigation as .pdf
Negligence and intentional torts are subject to civil litigation as .pdfNegligence and intentional torts are subject to civil litigation as .pdf
Negligence and intentional torts are subject to civil litigation as .pdf
 
Incuded within the major CPI basket groups are various government-cha.pdf
Incuded within the major CPI basket groups are various government-cha.pdfIncuded within the major CPI basket groups are various government-cha.pdf
Incuded within the major CPI basket groups are various government-cha.pdf
 
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdfIdentify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
Identify major groupings within the Lophotrochozoa and Ecdy gg g soz.pdf
 
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdfHow many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
How many grams of solid NaCN have to be added to 1.4 L of water to d.pdf
 
How does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdfHow does Warhol add to the semiotic statement of the readymadeS.pdf
How does Warhol add to the semiotic statement of the readymadeS.pdf
 

Recently uploaded

Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 

Recently uploaded (20)

How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
dusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learningdusjagr & nano talk on open tools for agriculture research and learning
dusjagr & nano talk on open tools for agriculture research and learning
 
Simple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdfSimple, Complex, and Compound Sentences Exercises.pdf
Simple, Complex, and Compound Sentences Exercises.pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in  Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in Uttam Nagar (delhi) call me [🔝9953056974🔝] escort service 24X7
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
latest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answerslatest AZ-104 Exam Questions and Answers
latest AZ-104 Exam Questions and Answers
 

How do I add a ComboBox to this, underneath Enter Student ID tha.pdf

  • 1. How do I add a ComboBox to this, underneath "Enter Student ID" that says the following? import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class Registration extends JFrame { private JDesktopPane theDesktop; public Registration(){ theDesktop = new JDesktopPane(); JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu("Course"); JMenuItem addCourseItem = new JMenuItem("Add Course"); fileMenu.add(addCourseItem); JMenu tuitionMenu = new JMenu("Tuition"); JMenuItem calculateItem = new JMenuItem("Calculate Tuition"); JMenuItem printTuitionItem = new JMenuItem("Print Tuition"); JMenuItem printSchedulesItem = new JMenuItem("Print Student Schedules"); tuitionMenu.add(calculateItem); tuitionMenu.add(printTuitionItem); tuitionMenu.add(printSchedulesItem); JMenu exitMenu = new JMenu("Exit"); JMenuItem exitProgramItem = new JMenuItem("Exit Program"); exitMenu.add(exitProgramItem); addCourseItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae) {
  • 2. JInternalFrame frame = new JInternalFrame("Enter Student ID", true, true, true, true); ReadPanel rp = new ReadPanel(); frame.add(rp); frame.pack(); theDesktop.add(frame); frame.setVisible(true); } }); exitProgramItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ System.exit(0); } }); calculateItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ } }); printTuitionItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ } }); printSchedulesItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ } }); bar.add(fileMenu); bar.add(tuitionMenu);
  • 3. bar.add(exitMenu); setJMenuBar(bar); add(theDesktop); } public class ReadPanel extends Panel{ private JLabel findLabel; private JTextField findField; private JLabel buttonLabel; private JButton submitButton; public ReadPanel(){ findLabel = new JLabel("Enter Student ID"); findField = new JTextField(15); buttonLabel = new JLabel("Select Course"); buttonLabel = new JLabel("Click to Add"); submitButton = new JButton("Submit"); setLayout(new GridLayout(2,2)); submitButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ System.out.println(findField.getText()); findField.setText(""); } }); add(findLabel); add(findField); add(buttonLabel);
  • 4. add(buttonLabel); add(submitButton); } } public static void main(String[] args){ Registration r1 = new Registration(); r1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); r1.setLocationRelativeTo(null); r1.setSize(400,400); r1.setVisible(true); } } Registration System Course Tuition Exit Course Panel Enter Student ID Select Course Click to Add Select One Submit Solution //Changes added to Registration class in bold text //Registration.java import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.*; public class Registration extends JFrame { private JDesktopPane theDesktop; public Registration(){ theDesktop = new JDesktopPane(); JMenuBar bar = new JMenuBar(); JMenu fileMenu = new JMenu("Course"); JMenuItem addCourseItem = new JMenuItem("Add Course"); fileMenu.add(addCourseItem); JMenu tuitionMenu = new JMenu("Tuition"); JMenuItem calculateItem = new JMenuItem("Calculate Tuition"); JMenuItem printTuitionItem = new JMenuItem("Print Tuition");
  • 5. JMenuItem printSchedulesItem = new JMenuItem("Print Student Schedules"); tuitionMenu.add(calculateItem); tuitionMenu.add(printTuitionItem); tuitionMenu.add(printSchedulesItem); JMenu exitMenu = new JMenu("Exit"); JMenuItem exitProgramItem = new JMenuItem("Exit Program"); exitMenu.add(exitProgramItem); addCourseItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae) { JInternalFrame frame = new JInternalFrame("Student Registration", true, true, true, true); ReadPanel rp = new ReadPanel(); frame.add(rp); frame.pack(); theDesktop.add(frame); frame.setVisible(true); } }); exitProgramItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ System.exit(0); } }); calculateItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ } }); printTuitionItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ } }); printSchedulesItem.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ } });
  • 6. bar.add(fileMenu); bar.add(tuitionMenu); bar.add(exitMenu); setJMenuBar(bar); add(theDesktop); } public class ReadPanel extends Panel{ private JLabel findLabel; private JTextField findField; //Declare two separate labels and combo box private JLabel buttonLabel1; private JComboBoxcoursetBox; private JLabel buttonLabel2; private JButton submitButton; public ReadPanel() { //Set gride layout of 3 rows and 2 columns setLayout(new GridLayout(3,2)); //Set courses of array String[] courses={"Select One","CS100","CS101","CS102"}; findLabel = new JLabel("Enter Student ID"); findField = new JTextField(15); buttonLabel1 = new JLabel("Select Course"); coursetBox=new JComboBox(courses); buttonLabel2 = new JLabel("Click to Add"); submitButton = new JButton("Submit"); submitButton.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent ae){ System.out.println(findField.getText()); findField.setText(""); //get text from the combo box of selected item String courseName=(String) coursetBox.getSelectedItem(); System.out.println(courseName);
  • 7. } }); add(findLabel);add(findField); add(buttonLabel1);add(coursetBox); add(buttonLabel2);add(submitButton); } } public static void main(String[] args){ Registration r1 = new Registration(); r1.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); r1.setLocationRelativeTo(null); r1.setSize(400,400); r1.setVisible(true); } } Sample output: Click Add Course button