SlideShare a Scribd company logo
PLEASE HELP ME !!
IT IS Due Tonight ;(!
How can I make the add button and remove button initialize button work?
For the buttons should add and remove to the JTextArea and JList.
when you write you use the JTextField to add or remove what you write in the JTextArea and
JList.
For the initialize, the button should initialize the text once.
Ihave three class.
this what I code so far:
import javax.swing.JFrame;
import javax.swing.JTextField;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.Image;
import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JFileChooser;
import java.awt.Insets;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.SwingConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.ImageIcon;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.logging.Handler;
import java.awt.event.ActionEvent;
import java.awt.GridLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Component;
import javax.swing.ButtonGroup;
import javax.swing.DropMode;
import javax.swing.border.EtchedBorder;
import javax.swing.border.LineBorder;
import javax.swing.border.MatteBorder;
import javax.swing.border.TitledBorder;
import javax.swing.UIManager;
import java.awt.FlowLayout;
public class Schedule extends JFrame implements ListSelectionListener, ActionListener {
private ScheduleTextArea STArea;
private ScheduleButton SButton;
private JRadioButtonMenuItem BRed;
private JRadioButtonMenuItem BBlue;
private JRadioButtonMenuItem BGreen;
private JRadioButtonMenuItem BYellow;
private JPanel cntrolPanel;
public static void main(String[] args){
Schedule S= new Schedule();
S.setVisible(true);
}
public Schedule() {
setTitle("Student schedule");
setSize(800,700);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
getContentPane().setLayout(new GridLayout(0, 1, 0, 0));
createMenuBar();
cntrolPanel= new JPanel();
cntrolPanel.setBorder(new MatteBorder(3, 3, 3, 3, (Color) Color.GRAY));
getContentPane().add(cntrolPanel);
cntrolPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
STArea = new ScheduleTextArea();
STArea.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(128, 128, 128)));
cntrolPanel.add(STArea);
SButton = new ScheduleButton(null);
SButton.setBorder(new MatteBorder(1, 1, 1, 1, (Color) Color.GRAY));
cntrolPanel.add(SButton);
}
private void createMenuBar() {
BHandler handler = new BHandler();
JMenuBar menuBar= new JMenuBar();
setJMenuBar(menuBar);
JMenu mnFile = new JMenu("File");
menuBar.add(mnFile);
mnFile.setMnemonic(KeyEvent.VK_F);
JMenuItem mntmSave = new JMenuItem("Save");
mnFile.add(mntmSave);
mntmSave.setMnemonic(KeyEvent.VK_S);
JMenuItem mntmLoad = new JMenuItem("Load");
mnFile.add(mntmLoad);
mntmLoad.setMnemonic(KeyEvent.VK_L);
JMenuItem mntmClear = new JMenuItem("Clear");
mnFile.add(mntmClear);
mntmClear.setMnemonic(KeyEvent.VK_C);
JMenuItem mntmExit = new JMenuItem("Exit");
mnFile.add(mntmExit);
mntmExit.setMnemonic(KeyEvent.VK_X);
mntmSave.addActionListener(handler);
mntmLoad.addActionListener(handler);
mntmClear.addActionListener(handler);
mntmExit.addActionListener(handler);
JMenu mnColor = new JMenu("Color");
menuBar.add(mnColor);
mnColor.setMnemonic(KeyEvent.VK_O);
BRed = new JRadioButtonMenuItem("Red");
mnColor.add(BRed);
mnColor.setMnemonic(KeyEvent.VK_R);
BBlue = new JRadioButtonMenuItem("Blue");
mnColor.add(BBlue);
mnColor.setMnemonic(KeyEvent.VK_B);
BGreen = new JRadioButtonMenuItem("Green");
mnColor.add(BGreen);
mnColor.setMnemonic(KeyEvent.VK_G);
BYellow = new JRadioButtonMenuItem("Yellow ");
mnColor.add(BYellow);
mnColor.setMnemonic(KeyEvent.VK_Y);
BRed.setOpaque(false);
BGreen.setOpaque(false);
BBlue.setOpaque(false);
BYellow.setOpaque(false);
BRed.addActionListener(handler);
BBlue.addActionListener(handler);
BGreen.addActionListener(handler);
BYellow.addActionListener(handler);
}
private class BHandler implements ActionListener {
public void actionPerformed(ActionEvent e){
if(e.getSource() == BRed){
cntrolPanel.setBackground(Color.RED);
}else if(e.getSource() == BBlue){
cntrolPanel.setBackground(Color.BLUE);
}else if(e.getSource()== BGreen){
cntrolPanel.setBackground(Color.GREEN);
}else if(e.getSource()== BYellow){
cntrolPanel.setBackground(Color.YELLOW);
}else if(e.getActionCommand().equals("Save")){
JFileChooser jfc = new JFileChooser();
int Selection =jfc.showSaveDialog(null);
try {
if (Selection==JFileChooser.APPROVE_OPTION) {
File f = jfc.getSelectedFile();
PrintWriter pw = new PrintWriter(new FileWriter(f.getAbsolutePath()));
pw.print(STArea.getTArea());
pw.close();
}
} catch (IOException e1) {
e1.printStackTrace();
}
}else if (e.getActionCommand().equals("Load")){
JFileChooser loadFile = new JFileChooser();
loadFile.showOpenDialog(null);
try{
Scanner file = new Scanner(loadFile.getSelectedFile());
StringBuffer contents = new StringBuffer();
while (file.hasNextLine()) {
contents.append(file.nextLine() + " ");
STArea.getTArea().setText(contents.toString());
}
file.close();
} catch (FileNotFoundException fnfe) {
}
}else if (e.getActionCommand().equals("Clear")){
STArea.getTArea().setText("");
STArea.getTFieldName().setText("");
STArea.getTFieldClass().setText("");
SButton.getlistModel().clear();
}else if (e.getActionCommand().equals("Exit")) {
System.exit(0);
}
}
}
@Override
public void actionPerformed(ActionEvent ae) {
}
@Override
public void valueChanged(ListSelectionEvent e) {
}
}
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import java.awt.GridLayout;
import javax.swing.JLabel;
import java.awt.FlowLayout;
import javax.swing.ScrollPaneConstants;
import javax.swing.JTextPane;
import java.awt.BorderLayout;
import javax.swing.BoxLayout;
import javax.swing.SwingConstants;
public class ScheduleTextArea extends JPanel{
private JTextArea TA;
private JTextField txtName;
private JTextField txtClass;
private JTextPane txtpnStudentsName;
private JTextPane txtpnStudentsClass;
private JPanel panel;
private JPanel panel_1;
public ScheduleTextArea(){
panel = new JPanel();
add(panel);
txtpnStudentsName = new JTextPane();
panel.add(txtpnStudentsName);
txtpnStudentsName.setText("Student's Name:");
txtName = new JTextField();
panel.add(txtName);
txtName.setColumns(10);
txtpnStudentsClass = new JTextPane();
panel.add(txtpnStudentsClass);
txtpnStudentsClass.setText("Student's Class:");
txtClass= new JTextField();
panel.add(txtClass);
txtClass.setColumns(10);
panel_1 = new JPanel();
add(panel_1);
JScrollPane scrollPane = new JScrollPane();
panel_1.add(scrollPane);
scrollPane.setPreferredSize(new Dimension(250, 250));
TA = new JTextArea();
scrollPane.setViewportView(TA);
}
public JTextArea getTArea() {
return TA;
}
public void setTArea(JTextArea TArea) {
this.TA = TArea;
}
public JTextField getTFieldName(){
return txtName;
}
public JTextField getTFieldClass(){
return txtClass;
}
public void setFieldName(JTextField txtName){
this.txtName= txtName;
}
public void setFieldClass(JTextField txtClass){
this.txtClass= txtClass;
}
}
import java.awt.FlowLayout;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionListener;
public class ScheduleButton extends JPanel {
private JList list;
private DefaultListModel listModel;
public ScheduleButton(Schedule S){
super();
setLayout(new FlowLayout());
JPanel listPanel = new JPanel();
listModel= new DefaultListModel();
list = new JList(listModel);
list.addListSelectionListener(S);
this.list.setVisibleRowCount(6);
this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scrollPane = new JScrollPane(list);
listPanel.add(scrollPane);
add(listPanel);
JPanel btnPanel= new JPanel();
JButton btnInitialize = new JButton("Initialize ");
btnInitialize.setIcon(new ImageIcon("C:UsersDalalDesktopmocu.png"));
btnPanel.add(btnInitialize);
btnInitialize.addActionListener(S);
JButton btnAdd = new JButton("Add");
btnPanel.add(btnAdd);
btnAdd.addActionListener(S);
JButton btnRemove = new JButton("Remove");
btnPanel.add(btnRemove);
btnRemove.addActionListener(S);
add(btnPanel);
}
public JList getlist() {
return list;
}
public DefaultListModel getlistModel() {
return listModel;
}
public void setlist(JList list) {
this.list = list;
}
public void setlistModel(DefaultListModel listModel) {
this.listModel = listModel;
}
}
Solution
//Schedule.java
//ScheduleButton.java
//ScheduleTextArea.java

More Related Content

Similar to PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf

Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdfTic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
infomalad
 
Need help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdfNeed help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdf
hainesburchett26321
 
I am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdfI am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdf
seamusschwaabl99557
 
Why am I getting an out of memory error and no window of my .pdf
Why am I getting an out of memory error and no window of my .pdfWhy am I getting an out of memory error and no window of my .pdf
Why am I getting an out of memory error and no window of my .pdf
aakarcreations1
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3martha leon
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
udit652068
 
Groovy-er desktop applications with Griffon
Groovy-er desktop applications with GriffonGroovy-er desktop applications with Griffon
Groovy-er desktop applications with Griffon
Eric Wendelin
 
Groovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With GriffonGroovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With Griffon
Matthew McCullough
 
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
 
Programming in java_-_17_-_swing
Programming in java_-_17_-_swingProgramming in java_-_17_-_swing
Programming in java_-_17_-_swingjosodo
 
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
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
Anton Caceres
 
Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Muhammad Shebl Farag
 
package buttongui; import static com.sun.deploy.config.JREInf.pdf
package buttongui; import static com.sun.deploy.config.JREInf.pdfpackage buttongui; import static com.sun.deploy.config.JREInf.pdf
package buttongui; import static com.sun.deploy.config.JREInf.pdf
arjuntiwari586
 
Assignment InstructionsInstructions Make sure you go t
Assignment InstructionsInstructions Make sure you go tAssignment InstructionsInstructions Make sure you go t
Assignment InstructionsInstructions Make sure you go t
widdowsonerica
 
Getting some errors when trying to run this program, can anyone help.pdf
Getting some errors when trying to run this program, can anyone help.pdfGetting some errors when trying to run this program, can anyone help.pdf
Getting some errors when trying to run this program, can anyone help.pdf
mohammedfootwear
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdf
atulkapoor33
 
Chapter 5 GUI for introduction of java and gui .ppt
Chapter 5 GUI  for  introduction of java and gui .pptChapter 5 GUI  for  introduction of java and gui .ppt
Chapter 5 GUI for introduction of java and gui .ppt
HabibMuhammed2
 

Similar to PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf (20)

Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdfTic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
Tic Tac Toe game with GUI written in java.SolutionAnswerimp.pdf
 
Need help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdfNeed help writing the code for a basic java tic tac toe game Tic.pdf
Need help writing the code for a basic java tic tac toe game Tic.pdf
 
I am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdfI am sorry but my major does not cover programming in depth (ICT) an.pdf
I am sorry but my major does not cover programming in depth (ICT) an.pdf
 
Why am I getting an out of memory error and no window of my .pdf
Why am I getting an out of memory error and no window of my .pdfWhy am I getting an out of memory error and no window of my .pdf
Why am I getting an out of memory error and no window of my .pdf
 
CORE JAVA-2
CORE JAVA-2CORE JAVA-2
CORE JAVA-2
 
Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3Ejemplos Interfaces Usuario 3
Ejemplos Interfaces Usuario 3
 
Swing
SwingSwing
Swing
 
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdfWorking with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
Working with Layout Managers. Notes 1. In part 2, note that the Gam.pdf
 
Groovy-er desktop applications with Griffon
Groovy-er desktop applications with GriffonGroovy-er desktop applications with Griffon
Groovy-er desktop applications with Griffon
 
Groovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With GriffonGroovy-er Desktop Applications With Griffon
Groovy-er Desktop Applications With Griffon
 
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
 
Programming in java_-_17_-_swing
Programming in java_-_17_-_swingProgramming in java_-_17_-_swing
Programming in java_-_17_-_swing
 
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
 
Violet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole TeamViolet Peña - Storybook: A React Tool For Your Whole Team
Violet Peña - Storybook: A React Tool For Your Whole Team
 
Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1Getting started with GUI programming in Java_1
Getting started with GUI programming in Java_1
 
package buttongui; import static com.sun.deploy.config.JREInf.pdf
package buttongui; import static com.sun.deploy.config.JREInf.pdfpackage buttongui; import static com.sun.deploy.config.JREInf.pdf
package buttongui; import static com.sun.deploy.config.JREInf.pdf
 
Assignment InstructionsInstructions Make sure you go t
Assignment InstructionsInstructions Make sure you go tAssignment InstructionsInstructions Make sure you go t
Assignment InstructionsInstructions Make sure you go t
 
Getting some errors when trying to run this program, can anyone help.pdf
Getting some errors when trying to run this program, can anyone help.pdfGetting some errors when trying to run this program, can anyone help.pdf
Getting some errors when trying to run this program, can anyone help.pdf
 
Java ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdfJava ProgrammingImplement an auction application with the followin.pdf
Java ProgrammingImplement an auction application with the followin.pdf
 
Chapter 5 GUI for introduction of java and gui .ppt
Chapter 5 GUI  for  introduction of java and gui .pptChapter 5 GUI  for  introduction of java and gui .ppt
Chapter 5 GUI for introduction of java and gui .ppt
 

More from badshetoms

Determining Cash Payments to StockholdersThe board of directors de.pdf
Determining Cash Payments to StockholdersThe board of directors de.pdfDetermining Cash Payments to StockholdersThe board of directors de.pdf
Determining Cash Payments to StockholdersThe board of directors de.pdf
badshetoms
 
Assume that Stanford CPAs encountered the following issues during va.pdf
Assume that Stanford CPAs encountered the following issues during va.pdfAssume that Stanford CPAs encountered the following issues during va.pdf
Assume that Stanford CPAs encountered the following issues during va.pdf
badshetoms
 
Because his last undergrad research assistant died on the job, Profes.pdf
Because his last undergrad research assistant died on the job, Profes.pdfBecause his last undergrad research assistant died on the job, Profes.pdf
Because his last undergrad research assistant died on the job, Profes.pdf
badshetoms
 
When a coalition of credit card companies form an interest group cal.pdf
When a coalition of credit card companies form an interest group cal.pdfWhen a coalition of credit card companies form an interest group cal.pdf
When a coalition of credit card companies form an interest group cal.pdf
badshetoms
 
What is the relationship between government and economicsWh.pdf
What is the relationship between government and economicsWh.pdfWhat is the relationship between government and economicsWh.pdf
What is the relationship between government and economicsWh.pdf
badshetoms
 
Which method, streak or pour plate is easier for obtaining cultur.pdf
Which method, streak or pour plate is easier for obtaining cultur.pdfWhich method, streak or pour plate is easier for obtaining cultur.pdf
Which method, streak or pour plate is easier for obtaining cultur.pdf
badshetoms
 
Write an algorithm in pseudocode called copy Stack that copies the co.pdf
Write an algorithm in pseudocode called copy Stack that copies the co.pdfWrite an algorithm in pseudocode called copy Stack that copies the co.pdf
Write an algorithm in pseudocode called copy Stack that copies the co.pdf
badshetoms
 
Use properties of logarithms to condense 4 ln x-6 ln y. Write the .pdf
Use properties of logarithms to condense 4 ln x-6 ln y. Write the .pdfUse properties of logarithms to condense 4 ln x-6 ln y. Write the .pdf
Use properties of logarithms to condense 4 ln x-6 ln y. Write the .pdf
badshetoms
 
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdfWhat is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
badshetoms
 
9. How much would it cost to construct a building today that cost $12.pdf
9. How much would it cost to construct a building today that cost $12.pdf9. How much would it cost to construct a building today that cost $12.pdf
9. How much would it cost to construct a building today that cost $12.pdf
badshetoms
 
True or false 20. A manufacturer has a duty to warn about risks that.pdf
True or false 20. A manufacturer has a duty to warn about risks that.pdfTrue or false 20. A manufacturer has a duty to warn about risks that.pdf
True or false 20. A manufacturer has a duty to warn about risks that.pdf
badshetoms
 
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdfto a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
badshetoms
 
There are many cases of human disease where an enzyme activity is lac.pdf
There are many cases of human disease where an enzyme activity is lac.pdfThere are many cases of human disease where an enzyme activity is lac.pdf
There are many cases of human disease where an enzyme activity is lac.pdf
badshetoms
 
The United states has utilize multiple forms of liberalism through o.pdf
The United states has utilize multiple forms of liberalism through o.pdfThe United states has utilize multiple forms of liberalism through o.pdf
The United states has utilize multiple forms of liberalism through o.pdf
badshetoms
 
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdf
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdfCalculator 26 ng Learning pose that the Fed engages in expansionary.pdf
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdf
badshetoms
 
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdfSilver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
badshetoms
 
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdfProblem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
badshetoms
 
Privacy and Security What types of health care data are protected u.pdf
Privacy and Security What types of health care data are protected u.pdfPrivacy and Security What types of health care data are protected u.pdf
Privacy and Security What types of health care data are protected u.pdf
badshetoms
 
1. Project risk is normally highest during the project Executing Pro.pdf
1. Project risk is normally highest during the project Executing Pro.pdf1. Project risk is normally highest during the project Executing Pro.pdf
1. Project risk is normally highest during the project Executing Pro.pdf
badshetoms
 
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdfPart AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
badshetoms
 

More from badshetoms (20)

Determining Cash Payments to StockholdersThe board of directors de.pdf
Determining Cash Payments to StockholdersThe board of directors de.pdfDetermining Cash Payments to StockholdersThe board of directors de.pdf
Determining Cash Payments to StockholdersThe board of directors de.pdf
 
Assume that Stanford CPAs encountered the following issues during va.pdf
Assume that Stanford CPAs encountered the following issues during va.pdfAssume that Stanford CPAs encountered the following issues during va.pdf
Assume that Stanford CPAs encountered the following issues during va.pdf
 
Because his last undergrad research assistant died on the job, Profes.pdf
Because his last undergrad research assistant died on the job, Profes.pdfBecause his last undergrad research assistant died on the job, Profes.pdf
Because his last undergrad research assistant died on the job, Profes.pdf
 
When a coalition of credit card companies form an interest group cal.pdf
When a coalition of credit card companies form an interest group cal.pdfWhen a coalition of credit card companies form an interest group cal.pdf
When a coalition of credit card companies form an interest group cal.pdf
 
What is the relationship between government and economicsWh.pdf
What is the relationship between government and economicsWh.pdfWhat is the relationship between government and economicsWh.pdf
What is the relationship between government and economicsWh.pdf
 
Which method, streak or pour plate is easier for obtaining cultur.pdf
Which method, streak or pour plate is easier for obtaining cultur.pdfWhich method, streak or pour plate is easier for obtaining cultur.pdf
Which method, streak or pour plate is easier for obtaining cultur.pdf
 
Write an algorithm in pseudocode called copy Stack that copies the co.pdf
Write an algorithm in pseudocode called copy Stack that copies the co.pdfWrite an algorithm in pseudocode called copy Stack that copies the co.pdf
Write an algorithm in pseudocode called copy Stack that copies the co.pdf
 
Use properties of logarithms to condense 4 ln x-6 ln y. Write the .pdf
Use properties of logarithms to condense 4 ln x-6 ln y. Write the .pdfUse properties of logarithms to condense 4 ln x-6 ln y. Write the .pdf
Use properties of logarithms to condense 4 ln x-6 ln y. Write the .pdf
 
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdfWhat is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
What is the Insertion Sort MIPS Assembly codeSolution.globl m.pdf
 
9. How much would it cost to construct a building today that cost $12.pdf
9. How much would it cost to construct a building today that cost $12.pdf9. How much would it cost to construct a building today that cost $12.pdf
9. How much would it cost to construct a building today that cost $12.pdf
 
True or false 20. A manufacturer has a duty to warn about risks that.pdf
True or false 20. A manufacturer has a duty to warn about risks that.pdfTrue or false 20. A manufacturer has a duty to warn about risks that.pdf
True or false 20. A manufacturer has a duty to warn about risks that.pdf
 
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdfto a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
to a 1911 in an effort to reduce violence against Suffragettes of NAW.pdf
 
There are many cases of human disease where an enzyme activity is lac.pdf
There are many cases of human disease where an enzyme activity is lac.pdfThere are many cases of human disease where an enzyme activity is lac.pdf
There are many cases of human disease where an enzyme activity is lac.pdf
 
The United states has utilize multiple forms of liberalism through o.pdf
The United states has utilize multiple forms of liberalism through o.pdfThe United states has utilize multiple forms of liberalism through o.pdf
The United states has utilize multiple forms of liberalism through o.pdf
 
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdf
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdfCalculator 26 ng Learning pose that the Fed engages in expansionary.pdf
Calculator 26 ng Learning pose that the Fed engages in expansionary.pdf
 
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdfSilver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
Silver chromate is sparingly soluble in aqueous solutions. The Ksp o.pdf
 
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdfProblem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
Problem 21.12 Histone genes are unusual among eukaryotic genes becaus.pdf
 
Privacy and Security What types of health care data are protected u.pdf
Privacy and Security What types of health care data are protected u.pdfPrivacy and Security What types of health care data are protected u.pdf
Privacy and Security What types of health care data are protected u.pdf
 
1. Project risk is normally highest during the project Executing Pro.pdf
1. Project risk is normally highest during the project Executing Pro.pdf1. Project risk is normally highest during the project Executing Pro.pdf
1. Project risk is normally highest during the project Executing Pro.pdf
 
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdfPart AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
Part AAxonemal dyneins areAxonemal dyneins areassociated with ci.pdf
 

Recently uploaded

Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
Wasim Ak
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
Scholarhat
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 

Recently uploaded (20)

Normal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of LabourNormal Labour/ Stages of Labour/ Mechanism of Labour
Normal Labour/ Stages of Labour/ Mechanism of Labour
 
Azure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHatAzure Interview Questions and Answers PDF By ScholarHat
Azure Interview Questions and Answers PDF By ScholarHat
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 

PLEASE HELP ME !!IT IS Due Tonight ;(!How can I make the add but.pdf

  • 1. PLEASE HELP ME !! IT IS Due Tonight ;(! How can I make the add button and remove button initialize button work? For the buttons should add and remove to the JTextArea and JList. when you write you use the JTextField to add or remove what you write in the JTextArea and JList. For the initialize, the button should initialize the text once. Ihave three class. this what I code so far: import javax.swing.JFrame; import javax.swing.JTextField; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.GridBagConstraints; import java.awt.Image; import javax.swing.JButton; import javax.swing.JColorChooser; import javax.swing.JFileChooser; import java.awt.Insets; import javax.swing.JList; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JMenuBar; import javax.swing.JMenu; import javax.swing.SwingConstants; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import javax.swing.JMenuItem; import javax.swing.JRadioButtonMenuItem; import javax.swing.ImageIcon; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.io.File; import java.io.FileNotFoundException;
  • 2. import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; import java.util.logging.Handler; import java.awt.event.ActionEvent; import java.awt.GridLayout; import javax.swing.JLabel; import javax.swing.JPanel; import java.awt.Component; import javax.swing.ButtonGroup; import javax.swing.DropMode; import javax.swing.border.EtchedBorder; import javax.swing.border.LineBorder; import javax.swing.border.MatteBorder; import javax.swing.border.TitledBorder; import javax.swing.UIManager; import java.awt.FlowLayout; public class Schedule extends JFrame implements ListSelectionListener, ActionListener { private ScheduleTextArea STArea; private ScheduleButton SButton; private JRadioButtonMenuItem BRed; private JRadioButtonMenuItem BBlue; private JRadioButtonMenuItem BGreen; private JRadioButtonMenuItem BYellow; private JPanel cntrolPanel; public static void main(String[] args){ Schedule S= new Schedule(); S.setVisible(true); } public Schedule() {
  • 3. setTitle("Student schedule"); setSize(800,700); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().setLayout(new GridLayout(0, 1, 0, 0)); createMenuBar(); cntrolPanel= new JPanel(); cntrolPanel.setBorder(new MatteBorder(3, 3, 3, 3, (Color) Color.GRAY)); getContentPane().add(cntrolPanel); cntrolPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5)); STArea = new ScheduleTextArea(); STArea.setBorder(new MatteBorder(1, 1, 1, 1, (Color) new Color(128, 128, 128))); cntrolPanel.add(STArea); SButton = new ScheduleButton(null); SButton.setBorder(new MatteBorder(1, 1, 1, 1, (Color) Color.GRAY)); cntrolPanel.add(SButton); } private void createMenuBar() { BHandler handler = new BHandler(); JMenuBar menuBar= new JMenuBar(); setJMenuBar(menuBar); JMenu mnFile = new JMenu("File"); menuBar.add(mnFile); mnFile.setMnemonic(KeyEvent.VK_F);
  • 4. JMenuItem mntmSave = new JMenuItem("Save"); mnFile.add(mntmSave); mntmSave.setMnemonic(KeyEvent.VK_S); JMenuItem mntmLoad = new JMenuItem("Load"); mnFile.add(mntmLoad); mntmLoad.setMnemonic(KeyEvent.VK_L); JMenuItem mntmClear = new JMenuItem("Clear"); mnFile.add(mntmClear); mntmClear.setMnemonic(KeyEvent.VK_C); JMenuItem mntmExit = new JMenuItem("Exit"); mnFile.add(mntmExit); mntmExit.setMnemonic(KeyEvent.VK_X); mntmSave.addActionListener(handler); mntmLoad.addActionListener(handler); mntmClear.addActionListener(handler); mntmExit.addActionListener(handler); JMenu mnColor = new JMenu("Color"); menuBar.add(mnColor); mnColor.setMnemonic(KeyEvent.VK_O); BRed = new JRadioButtonMenuItem("Red"); mnColor.add(BRed); mnColor.setMnemonic(KeyEvent.VK_R); BBlue = new JRadioButtonMenuItem("Blue"); mnColor.add(BBlue); mnColor.setMnemonic(KeyEvent.VK_B);
  • 5. BGreen = new JRadioButtonMenuItem("Green"); mnColor.add(BGreen); mnColor.setMnemonic(KeyEvent.VK_G); BYellow = new JRadioButtonMenuItem("Yellow "); mnColor.add(BYellow); mnColor.setMnemonic(KeyEvent.VK_Y); BRed.setOpaque(false); BGreen.setOpaque(false); BBlue.setOpaque(false); BYellow.setOpaque(false); BRed.addActionListener(handler); BBlue.addActionListener(handler); BGreen.addActionListener(handler); BYellow.addActionListener(handler); } private class BHandler implements ActionListener { public void actionPerformed(ActionEvent e){ if(e.getSource() == BRed){ cntrolPanel.setBackground(Color.RED); }else if(e.getSource() == BBlue){ cntrolPanel.setBackground(Color.BLUE); }else if(e.getSource()== BGreen){ cntrolPanel.setBackground(Color.GREEN); }else if(e.getSource()== BYellow){ cntrolPanel.setBackground(Color.YELLOW); }else if(e.getActionCommand().equals("Save")){ JFileChooser jfc = new JFileChooser();
  • 6. int Selection =jfc.showSaveDialog(null); try { if (Selection==JFileChooser.APPROVE_OPTION) { File f = jfc.getSelectedFile(); PrintWriter pw = new PrintWriter(new FileWriter(f.getAbsolutePath())); pw.print(STArea.getTArea()); pw.close(); } } catch (IOException e1) { e1.printStackTrace(); } }else if (e.getActionCommand().equals("Load")){ JFileChooser loadFile = new JFileChooser(); loadFile.showOpenDialog(null); try{ Scanner file = new Scanner(loadFile.getSelectedFile()); StringBuffer contents = new StringBuffer(); while (file.hasNextLine()) { contents.append(file.nextLine() + " "); STArea.getTArea().setText(contents.toString()); } file.close(); } catch (FileNotFoundException fnfe) { } }else if (e.getActionCommand().equals("Clear")){ STArea.getTArea().setText("");
  • 7. STArea.getTFieldName().setText(""); STArea.getTFieldClass().setText(""); SButton.getlistModel().clear(); }else if (e.getActionCommand().equals("Exit")) { System.exit(0); } } } @Override public void actionPerformed(ActionEvent ae) { } @Override public void valueChanged(ListSelectionEvent e) { } } import java.awt.Dimension; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import java.awt.GridLayout; import javax.swing.JLabel; import java.awt.FlowLayout;
  • 8. import javax.swing.ScrollPaneConstants; import javax.swing.JTextPane; import java.awt.BorderLayout; import javax.swing.BoxLayout; import javax.swing.SwingConstants; public class ScheduleTextArea extends JPanel{ private JTextArea TA; private JTextField txtName; private JTextField txtClass; private JTextPane txtpnStudentsName; private JTextPane txtpnStudentsClass; private JPanel panel; private JPanel panel_1; public ScheduleTextArea(){ panel = new JPanel(); add(panel); txtpnStudentsName = new JTextPane(); panel.add(txtpnStudentsName); txtpnStudentsName.setText("Student's Name:"); txtName = new JTextField(); panel.add(txtName); txtName.setColumns(10); txtpnStudentsClass = new JTextPane(); panel.add(txtpnStudentsClass); txtpnStudentsClass.setText("Student's Class:"); txtClass= new JTextField(); panel.add(txtClass); txtClass.setColumns(10); panel_1 = new JPanel();
  • 9. add(panel_1); JScrollPane scrollPane = new JScrollPane(); panel_1.add(scrollPane); scrollPane.setPreferredSize(new Dimension(250, 250)); TA = new JTextArea(); scrollPane.setViewportView(TA); } public JTextArea getTArea() { return TA; } public void setTArea(JTextArea TArea) { this.TA = TArea; } public JTextField getTFieldName(){ return txtName; } public JTextField getTFieldClass(){ return txtClass; } public void setFieldName(JTextField txtName){ this.txtName= txtName; } public void setFieldClass(JTextField txtClass){ this.txtClass= txtClass; } } import java.awt.FlowLayout; import javax.swing.DefaultListModel; import javax.swing.ImageIcon; import javax.swing.JButton;
  • 10. import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionListener; public class ScheduleButton extends JPanel { private JList list; private DefaultListModel listModel; public ScheduleButton(Schedule S){ super(); setLayout(new FlowLayout()); JPanel listPanel = new JPanel(); listModel= new DefaultListModel(); list = new JList(listModel); list.addListSelectionListener(S); this.list.setVisibleRowCount(6); this.list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); JScrollPane scrollPane = new JScrollPane(list); listPanel.add(scrollPane); add(listPanel);
  • 11. JPanel btnPanel= new JPanel(); JButton btnInitialize = new JButton("Initialize "); btnInitialize.setIcon(new ImageIcon("C:UsersDalalDesktopmocu.png")); btnPanel.add(btnInitialize); btnInitialize.addActionListener(S); JButton btnAdd = new JButton("Add"); btnPanel.add(btnAdd); btnAdd.addActionListener(S); JButton btnRemove = new JButton("Remove"); btnPanel.add(btnRemove); btnRemove.addActionListener(S); add(btnPanel); } public JList getlist() { return list; } public DefaultListModel getlistModel() { return listModel; } public void setlist(JList list) { this.list = list; } public void setlistModel(DefaultListModel listModel) { this.listModel = listModel; } }