Answered step by step
Verified Expert Solution
Question
1 Approved Answer
package application; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io . File; import java.io . IOException; import java.text.SimpleDateFormat; import java.util.ArrayList; import
package application;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.ioFile;
import java.ioIOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import javax.imageio.ImageIO;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import org.jdesktop.swingx.JXDatePicker;
public class PetGUI implements ActionListener
JFrame frame, addWindow, searchWindow, displayWindow;
JMenuBar menuBar;
JMenu fileMenu, helpMenu;
JMenuItem add, modify, display, report, exit, helpContents, about;
JButton addButton, displayButton, showFileDialogButton, modifyButton;
List pets;
JPanel addPanel, genderPanel, searchPanel, modifyPanel, displayPanel;
JLabel nameLabel, photoLabel, typeLabel, colorLabel, genderLabel, isSterilizedLabel, pedigreeLabel, dateEntryLabel, vaccineOneLabel, vaccineTwoLabel, vaccineThreeLabel;
JTextField nameField, typeField, colorField, pedigreeField, dateEntryField;
JFileChooser fileDialog;
JRadioButton male, female;
ButtonGroup genderGroup;
JCheckBox isSterilizedChkBox, pedigreeChkBox, vaccineOneChkBox, vaccineTwoChkBox, vaccineThreeChkBox;
JXDatePicker picker;
Image selectedImage;
PetGUI
pets new ArrayList;
frame new JFrame;
add new JMenuItemAdd New Pet";
modify new JMenuItemModify a Pet";
display new JMenuItemDisplay Pet Info";
report new JMenuItemReport;
exit new JMenuItemExit;
add.addActionListenerthis;
modify.addActionListenerthis;
display.addActionListenerthis;
report.addActionListenerthis;
exit.addActionListenerthis;
helpContents new JMenuItemHelp contents";
about new JMenuItemAbout;
helpContents.addActionListenerthis;
about.addActionListenerthis;
menuBar new JMenuBar;
fileMenu new JMenuFile;
helpMenu new JMenuHelp;
fileMenu.addadd;
fileMenu.addmodify;
fileMenu.adddisplay;
fileMenu.addreport;
fileMenu.addexit;
helpMenu.addhelpContents;
helpMenu.addabout;
menuBar.addfileMenu;
menuBar.addhelpMenu;
frame.addmenuBar;
frame.setJMenuBarmenuBar;
frame.setLayoutnull;
frame.setSize;
frame.setVisibletrue;
public void actionPerformedActionEvent e
if egetSource add
addWindow new JFrame;
addWindow.setSize;
addWindow.setDefaultCloseOperation;
addWindow.setTitleAdd Pet";
addPanel new JPanel;
addPanel.setLayoutnew GridLayout;
nameLabel new JLabelName:;
addPanel.addnameLabel;
nameField new JTextField;
nameField.setBounds;
addPanel.addnameField;
photoLabel new JLabelPhoto:;
addPanel.addphotoLabel;
fileDialog new JFileChooser;
showFileDialogButton new JButtonOpen File";
showFileDialogButton.addActionListenernew ActionListener
public void actionPerformedActionEvent e
int returnVal fileDialog.showOpenDialogaddWindow;
if returnVal JFileChooser.APPROVEOPTION
File file fileDialog.getSelectedFile;
try
selectedImage ImageIO.readfile;
catch IOException e
eprintStackTrace;
else
;
addPanel.addshowFileDialogButton;
addWindow.setVisibletrue;
typeLabel new JLabelType:;
addPanel.addtypeLabel;
typeField new JTextField;
typeField.setBounds;
addPanel.addtypeField;
colorLabel new JLabelColor:;
addPanel.addcolorLabel;
colorField new JTextField;
colorField.setBounds;
addPanel.addcolorField;
genderLabel new JLabelGender:;
addPanel.addgenderLabel;
male new JRadioButtonMale;;
female new JRadioButtonFemale;
genderGroup new ButtonGroup;
male.setBounds;
female.setBounds;
genderGroup.addmale;
genderGroup.addfemale;
genderPanel new JPanel;
genderPanel.setLayoutnew GridLayout;
genderPanel.addmale;
genderPanel.addfemale
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started