📄 adminframe.java
字号:
/*
* @author Reghu
* @version 1.0
*
* Development Environment : Oracle9i JDeveloper
* Name of the Application : AdminFrame.java
* Creation/Modification History :
*
* Reghu 30-March-2003 Created
*
*/
package oracle.otnsamples.vsm.client;
// Java awt classes
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultListModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.JToggleButton.ToggleButtonModel;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.EtchedBorder;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableModel;
import javax.swing.text.Caret;
/**
* This file contains the business logic of creating the UI components of the
* admin utility of VSM applicatioon and it is generated by JDeveloper while
* designing the UI components.
*
* @author Reghu
* @version 1.0
*/
public class AdminFrame extends JFrame {
// Look and feel related classes
private static String metalClassName =
"javax.swing.plaf.metal.MetalLookAndFeel";
private static String motifClassName =
"com.sun.java.swing.plaf.motif.MotifLookAndFeel";
private static String windowsClassName =
"com.sun.java.swing.plaf.windows.WindowsLookAndFeel";
protected DefaultListModel model = new DefaultListModel();
protected GenTableModel catmodel;
protected GenTableModel guestmodel;
protected GenTableModel shopmodel;
// Button components
protected JButton addCat = new JButton();
protected JButton addProperty = new JButton();
protected JButton delete = new JButton();
protected JButton guestExit = new JButton();
protected JButton guestDelete = new JButton();
protected JButton profUpdate = new JButton();
protected JButton reset = new JButton();
protected JButton shopApprove = new JButton();
protected JButton shopReject = new JButton();
protected JButton updateCat = new JButton();
protected JComboBox country = new JComboBox();
protected JList properties = new JList(model);
protected JPanel guest = new JPanel();
protected JPasswordField password = new JPasswordField();
protected JScrollPane guestPane1 = new JScrollPane();
// Table components
protected JTable catTable = new JTable();
protected JTable guestTable = new JTable();
protected JTable shopTable = new JTable();
// Textfield and Textarea components
protected JTextArea address = new JTextArea();
protected JTextField cardNumb = new JTextField();
protected JTextField catName = new JTextField();
protected JTextField city = new JTextField();
protected JTextField email = new JTextField();
protected JTextField expDate = new JTextField();
protected JTextField fname = new JTextField();
protected JTextField lname = new JTextField();
protected JTextField phone = new JTextField();
protected JTextField propName = new JTextField();
protected JTextField provider = new JTextField();
protected JTextField state = new JTextField();
protected JTextField status = new JTextField();
protected JTextField zip = new JTextField();
// The main application class which uses this frame
AdminSample parent;
ButtonGroup group = new ButtonGroup();
private Caret caret1 = new javax.swing.text.DefaultCaret();
private ComboBoxModel comboBoxModel1 = new javax.swing.DefaultComboBoxModel();
// Layout manager
private GridBagLayout catLay = new GridBagLayout();
private GridBagLayout frameLay = new GridBagLayout();
private GridBagLayout guestLay = new GridBagLayout();
private GridBagLayout shopLay = new GridBagLayout();
// Labels used in the UI
private JLabel addressLab = new JLabel();
private JLabel cardLab = new JLabel();
private JLabel cardNumbLab = new JLabel();
private JLabel catnameLab = new JLabel();
private JLabel cityLab = new JLabel();
private JLabel countryLab = new JLabel();
private JLabel emailLab = new JLabel();
private JLabel expLab = new JLabel();
private JLabel fnameLab = new JLabel();
private JLabel lnameLab = new JLabel();
private JLabel passwdLab = new JLabel();
private JLabel phoneLab = new JLabel();
private JLabel propListLab = new JLabel();
private JLabel propertyLab = new JLabel();
private JLabel stateLab = new JLabel();
private JLabel statusBar = new JLabel();
private JLabel zipLab = new JLabel();
// Menu and menu items in the UI
private JMenu menuFile = new JMenu();
private JMenu menuHelp = new JMenu();
private JMenu menuLook = new JMenu();
private JMenuBar menuBar = new JMenuBar();
private JMenuItem menuFileAbt = new JMenuItem();
private JMenuItem menuFileExit = new JMenuItem();
private JMenuItem menuFileOpen = new JMenuItem();
private JMenuItem menuFileSave = new JMenuItem();
private JMenuItem menuFileSaveAs = new JMenuItem();
// Panels used in the Application
private JPanel Category = new JPanel();
private JPanel bottom = new JPanel();
private JPanel panelCenter = new JPanel();
private JPanel profile = new JPanel();
private JPanel shops = new JPanel();
private JRadioButtonMenuItem menuLookJava = new JRadioButtonMenuItem();
private JRadioButtonMenuItem menuLookMotif = new JRadioButtonMenuItem();
private JRadioButtonMenuItem menuLookWin = new JRadioButtonMenuItem();
private JScrollPane addpane = new JScrollPane();
private JScrollPane catTabPane = new JScrollPane();
private JScrollPane listPanel = new JScrollPane();
private JScrollPane tablePane = new JScrollPane();
private JTabbedPane tab = new JTabbedPane();
private JTableHeader jTableHeader1 = new JTableHeader();
private String CATID;
/**
* Constructor, initializes and sets up listeners for the GUI components of
* the application
*/
public AdminFrame(AdminSample parent) {
try {
this.parent = parent;
setIconImage(new ImageIcon(getClass().getClassLoader().getResource("otnlogo_small.gif")).getImage());
guestTableInit();
shopTableInit();
catTableInit();
jbInit();
} catch(Exception e) {
e.printStackTrace();
}
}
/**
* Initialize all the GUI components and the layout
*
* @exception Exception
*/
private void jbInit() throws Exception {
menuBar.setBackground(new Color(223, 223, 191));
this.setJMenuBar(menuBar);
this.getContentPane().setLayout(frameLay);
panelCenter.setLayout(null);
this.setSize(new Dimension(780, 598));
menuFile.setText("File");
menuFile.setMnemonic(KeyEvent.VK_F);
menuFileOpen.setText("Open");
menuFileOpen.setMnemonic(KeyEvent.VK_O);
menuFileOpen.setEnabled(false);
menuFileSave.setText("Save");
menuFileSave.setMnemonic(KeyEvent.VK_S);
menuFileSave.setEnabled(false);
menuFileSaveAs.setText("Save As");
menuFileSaveAs.setMnemonic(KeyEvent.VK_A);
menuFileSaveAs.setEnabled(false);
menuFile.addSeparator();
menuFileExit.setText("Exit");
menuFileExit.setMnemonic(KeyEvent.VK_X);
menuFileExit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
System.exit(0);
}
});
menuLook.setText("Look & Feel");
menuLook.setMnemonic(KeyEvent.VK_L);
menuLook.addSeparator();
ButtonGroup group = new ButtonGroup();
shops.setLayout(shopLay);
profile.setLayout(null);
profile.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
fnameLab.setText("First Name");
fnameLab.setBounds(new Rectangle(175, 25, 75, 20));
fnameLab.setBackground(new Color(223, 223, 191));
fnameLab.setFont(new Font("Dialog", 1, 12));
lnameLab.setText("Last Name");
lnameLab.setBounds(new Rectangle(175, 50, 95, 20));
lnameLab.setBackground(new Color(223, 223, 191));
lnameLab.setFont(new Font("Dialog", 1, 12));
emailLab.setText("Email id");
emailLab.setBounds(new Rectangle(175, 75, 60, 20));
emailLab.setBackground(new Color(223, 223, 191));
emailLab.setFont(new Font("Dialog", 1, 12));
stateLab.setText("State");
stateLab.setBounds(new Rectangle(175, 190, 75, 30));
stateLab.setBackground(new Color(223, 223, 191));
stateLab.setFont(new Font("Dialog", 1, 12));
cityLab.setText("City");
cityLab.setBounds(new Rectangle(175, 165, 75, 30));
cityLab.setBackground(new Color(223, 223, 191));
cityLab.setFont(new Font("Dialog", 1, 12));
addressLab.setText("Address");
addressLab.setBounds(new Rectangle(175, 95, 75, 30));
addressLab.setBackground(new Color(223, 223, 191));
addressLab.setFont(new Font("Dialog", 1, 12));
countryLab.setText("Country");
countryLab.setBounds(new Rectangle(175, 215, 75, 30));
countryLab.setBackground(new Color(223, 223, 191));
countryLab.setFont(new Font("Dialog", 1, 12));
zipLab.setText("Zip");
zipLab.setBounds(new Rectangle(175, 240, 65, 30));
zipLab.setBackground(new Color(223, 223, 191));
zipLab.setFont(new Font("Dialog", 1, 12));
phoneLab.setText("Phone");
phoneLab.setBounds(new Rectangle(175, 265, 75, 30));
phoneLab.setBackground(new Color(223, 223, 191));
phoneLab.setFont(new Font("Dialog", 1, 12));
passwdLab.setText("Password");
passwdLab.setBounds(new Rectangle(175, 290, 75, 30));
passwdLab.setBackground(new Color(223, 223, 191));
passwdLab.setFont(new Font("Dialog", 1, 12));
cardLab.setText("Card Provider");
cardLab.setBounds(new Rectangle(175, 315, 125, 30));
cardLab.setBackground(new Color(223, 223, 191));
cardLab.setFont(new Font("Dialog", 1, 12));
cardNumbLab.setText("Card Number");
cardNumbLab.setBounds(new Rectangle(175, 340, 85, 30));
cardNumbLab.setBackground(new Color(223, 223, 191));
cardNumbLab.setFont(new Font("Dialog", 1, 12));
expLab.setText("Expiry Date");
expLab.setBounds(new Rectangle(175, 365, 70, 30));
expLab.setBackground(new Color(223, 223, 191));
expLab.setFont(new Font("Dialog", 1, 12));
updateCat.setText("Update");
updateCat.setBounds(new Rectangle(295, 435, 75, 30));
updateCat.setActionCommand("update");
// Action to be performed while pressing the update category button
updateCat.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae) {
int size = properties.getModel().getSize();
String[] item = new String[ size ];
// Get all item objects
for(int i = 0; i < size; i++) {
item [ i ] = (String) properties.getModel().getElementAt(i);
}
parent.modifyCategory(CATID, item);
}
});
fname.setBounds(new Rectangle(270, 25, 250, 20));
lname.setBounds(new Rectangle(270, 50, 250, 20));
zip.setBounds(new Rectangle(270, 245, 155, 20));
email.setBounds(new Rectangle(270, 75, 250, 20));
city.setBounds(new Rectangle(270, 170, 205, 20));
state.setBounds(new Rectangle(270, 195, 205, 20));
country.setBounds(new Rectangle(270, 220, 155, 20));
country.setModel(comboBoxModel1);
phone.setBounds(new Rectangle(270, 270, 155, 20));
password.setBounds(new Rectangle(270, 295, 210, 20));
provider.setBounds(new Rectangle(270, 320, 210, 20));
expDate.setBounds(new Rectangle(270, 370, 210, 20));
cardNumb.setBounds(new Rectangle(270, 345, 210, 20));
menuLookJava.setText("Metal");
menuLookJava.setActionCommand(metalClassName);
menuLookJava.setMnemonic(KeyEvent.VK_M);
menuLookJava.setSelected(true);
group.add(menuLookJava);
menuLookWin.setText("Windows");
menuLookWin.setActionCommand(windowsClassName);
menuLookWin.setMnemonic(KeyEvent.VK_W);
group.add(menuLookWin);
menuLookMotif.setText("Motif");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -