📄 adminframe.java
字号:
shopTable.setGridColor(new Color(119, 131, 223));
guest.setLayout(guestLay);
tablePane.setAutoscrolls(true);
tablePane.setBackground(new Color(223, 223, 191));
setTitle("VSM Administration Client Application.");
address.setRows(4);
addpane.setBounds(new Rectangle(270, 100, 230, 65));
reset.setModel(new ToggleButtonModel());
reset.setBackground(new Color(131, 131, 87));
reset.setActionCommand("reset");
reset.setBounds(new Rectangle(380, 435, 70, 30));
reset.setText("Reset");
updateCat.setBackground(new Color(131, 131, 87));
updateCat.setModel(new ToggleButtonModel());
guest.setBackground(new Color(223, 223, 191));
profile.setBackground(new Color(223, 223, 191));
Category.setBackground(new Color(179, 177, 142));
shops.setBackground(new Color(223, 223, 191));
menuLookJava.addActionListener(myListener);
menuLookWin.addActionListener(myListener);
menuLookMotif.addActionListener(myListener);
menuHelp.setText("Help");
menuHelp.setMnemonic(KeyEvent.VK_H);
menuFileAbt.setText("About");
menuFileAbt.setMnemonic(KeyEvent.VK_B);
menuHelp.add(menuFileAbt);
menuFile.add(menuFileOpen);
menuFile.add(menuFileSave);
menuFile.add(menuFileSaveAs);
menuFile.addSeparator();
menuFile.add(menuFileExit);
menuBar.add(menuFile);
menuLook.add(menuLookJava);
menuLook.add(menuLookWin);
menuLook.add(menuLookMotif);
menuBar.add(menuLook);
menuBar.add(menuHelp);
shops.add(
shopReject,
new GridBagConstraints(
1, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(40, 20, 183, 0), 15, 3));
shops.add(
shopApprove,
new GridBagConstraints(
0, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(40, 250, 183, 0), 9, 3));
tablePane.getViewport().add(shopTable, null);
shops.add(
tablePane,
new GridBagConstraints(
0, 0, 3, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(0, 0, 0, 0), 331, -174));
catTabPane.getViewport().add(catTable, null);
catTable.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
AdminFrame.this.putStatus("");
ListSelectionModel lsm = (ListSelectionModel) e.getSource();
if(!lsm.isSelectionEmpty() && !e.getValueIsAdjusting()) {
// Setup the action to be performed when a row got selected
int selectedRow = lsm.getMinSelectionIndex();
// Get the values for the selected row and print
TableModel mymodel = catTable.getModel();
catName.setText((String) mymodel.getValueAt(selectedRow, 0));
String[] categories = (String[]) mymodel.getValueAt(selectedRow, 1);
CATID = (String) mymodel.getValueAt(selectedRow, 2);
model.removeAllElements();
for(int i = 0; i < categories.length; i++) {
model.addElement(categories [ i ]);
}
properties.setSelectedIndex(0);
}
}
});
Category.add(
catTabPane,
new GridBagConstraints(
0, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(0, 0, 4, 0), 297, 240));
Category.add(
bottom,
new GridBagConstraints(
0, 1, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(1, -85, -12, 0), 839, 258));
tab.addTab("Category", Category);
tab.addTab("Shops", shops);
listPanel.getViewport().add(properties, null);
bottom.add(listPanel, null);
bottom.add(catnameLab, null);
bottom.add(catName, null);
bottom.add(propertyLab, null);
bottom.add(propName, null);
bottom.add(addProperty, null);
bottom.add(addCat, null);
bottom.add(updateCat, null);
bottom.add(propListLab, null);
bottom.add(delete, null);
tab.addTab("Profile", profile);
tab.addTab("Guest Book", guest);
profile.add(profUpdate, null);
addpane.getViewport().add(address, null);
profile.add(addpane, null);
profile.add(reset, null);
profile.add(cardNumb, null);
profile.add(expDate, null);
profile.add(provider, null);
profile.add(password, null);
profile.add(phone, null);
profile.add(country, null);
profile.add(state, null);
profile.add(city, null);
profile.add(email, null);
profile.add(zip, null);
profile.add(lname, null);
profile.add(fname, null);
profile.add(expLab, null);
profile.add(cardNumbLab, null);
profile.add(cardLab, null);
profile.add(passwdLab, null);
profile.add(phoneLab, null);
profile.add(zipLab, null);
profile.add(countryLab, null);
profile.add(addressLab, null);
profile.add(cityLab, null);
profile.add(stateLab, null);
profile.add(emailLab, null);
profile.add(lnameLab, null);
profile.add(fnameLab, null);
guest.add(
guestExit,
new GridBagConstraints(
1, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(40, 15, 183, 0), 15, 3));
guest.add(
guestDelete,
new GridBagConstraints(
0, 1, 1, 1, 0.0, 0.0,
GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(40, 245, 183, 0), 15, 3));
guestPane1.getViewport().add(guestTable, null);
guest.add(
guestPane1,
new GridBagConstraints(
0, 0, 3, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(0, 0, 0, -10), 331, -174));
this.getContentPane().add(
status,
new GridBagConstraints(
0, 1, 1, 1, 1.0, 0.0,
GridBagConstraints.WEST,
GridBagConstraints.HORIZONTAL,
new Insets(0, 0, -2, -6),
772, 25));
this.getContentPane().add(
tab,
new GridBagConstraints(
0, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(0, 0, 0, -6),
-10, -409));
this.getContentPane().add(
statusBar,
new GridBagConstraints(
0, 0,
GridBagConstraints.REMAINDER,
GridBagConstraints.REMAINDER,
0.0, 0.0,
GridBagConstraints.WEST,
GridBagConstraints.NONE,
new Insets(0, 0, 0, 0), 0,
0));
this.getContentPane().add(
panelCenter,
new GridBagConstraints(
0, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.CENTER,
GridBagConstraints.BOTH,
new Insets(0, 0, 0, -6),
779, 509));
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent we) {
System.exit(0);
}
});
// Add a listener to handle the panel focus change
tab.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent e) {
switch(((JTabbedPane) e.getSource()).getSelectedIndex()) {
case 0 : {
parent.displayCategories();
break;
}
case 1 : {
parent.displayShops();
break;
}
case 2 : {
parent.getUserData("admin");
break;
}
case 3 : {
parent.displayGuestBook();
break;
}
}
parent.gui.putStatus("");
}
});
}
/**
* Displays the "About the Application" dialog box.
*
* @param e
*/
void helpAbout(ActionEvent e) {
JOptionPane.showMessageDialog(
this, new AboutPanel(), "About",
JOptionPane.PLAIN_MESSAGE);
}
/**
* JTable initialization. Sets up the column name and the table model for the
* JTable
*/
public void shopTableInit() {
String[] cols = { "User Name", "Date", "Status" };
Object[] defaultv = { "", "", "" };
shopmodel = new GenTableModel(cols, defaultv, 0);
shopTable = new JTable(shopmodel);
shopTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
/**
* JTable initialization. Sets up the column name and the table model for the
* JTable
*/
public void guestTableInit() {
String[] cols = { "User Name", "Email", "Date", "Comment", "Rating" };
Object[] defaultv = { "", "", "", "", "" };
guestmodel = new GenTableModel(cols, defaultv, 0);
guestTable = new JTable(guestmodel);
guestTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
/**
* JTable initialization. Sets up the column name and the table model for the
* JTable
*/
public void catTableInit() {
String[] cols = { "Category Name" };
Object[] defaultv = { "" };
catmodel = new GenTableModel(cols, defaultv, 0);
catTable = new JTable(catmodel);
catTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
}
/**
* Displays status on status field
*
* @param message status of operation
*/
public void putStatus(String message) {
status.setText(message);
status.setScrollOffset(0);
}
/**
* Inner class which handles the various look and feel of the application UI.
*
* @author Reghu
* @version 1.0
*/
class RadioListener implements ActionListener {
/**
* Apply the selected look and feel to the UI components.
*
* @param e
*/
public void actionPerformed(ActionEvent e) {
String lnfName = e.getActionCommand();
try {
UIManager.setLookAndFeel(lnfName);
SwingUtilities.updateComponentTreeUI(parent.gui);
} catch(Exception exc) {
System.err.println("Could not load LookAndFeel: " + lnfName);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -