📄 mediamanagerframe.java
字号:
tapeTable = new JTable(tapeContent, tapeHead);
tapeScroll = new JScrollPane(tapeTable);
tape.add(tapeScroll);
tabbedPane.addTab(" 磁带明细 ",tape);
JPanel info = new JPanel();
info.setLayout(new GridLayout(2,1,3,3));
JPanel help = new JPanel();
help.setLayout(new GridLayout(8,1));
help.setBorder(new TitledBorder("简易使用说明"));
JLabel help1 = new JLabel("本系统界面简洁美观,功能实用。可以对图书,CD与磁带进行管理。");
JLabel help2 = new JLabel("点击『插入记录』根据信息提示来添加新的条目。");
JLabel help3 = new JLabel("选中一条记录后点击『删除记录』可以将选中的记录删除");
JLabel help4 = new JLabel("点击『查询记录』可以按照不同类型根据关键词进行模糊查询");
JLabel help5 = new JLabel("如果想退出系统,可以点击『退出系统』按钮");
JLabel help6 = new JLabel();
JLabel help7 = new JLabel();
JLabel help8 = new JLabel();
help.add(help1);
help.add(help2);
help.add(help3);
help.add(help4);
help.add(help5);
help.add(help6);
help.add(help7);
help.add(help8);
JPanel about = new JPanel();
about.setLayout(new GridLayout(8,1));
about.setBorder(new TitledBorder("关于本系统"));
JLabel about1 = new JLabel("音像图书管理系统");
JLabel about2 = new JLabel("Media Manager 2005 beta1 build 0426");
JLabel about3 = new JLabel();
JLabel about4 = new JLabel("版权所有: 软件学院.55030106.徐徐");
JLabel about5 = new JLabel("版权声明: 本软件开放源代码。");
JLabel about6 = new JLabel(" 如果您在使用过程中发现本系统存在什么不足,请及时指出,谢谢");
JLabel about7 = new JLabel();
JLabel about8 = new JLabel("请密切留意本系统的最新版本");
about.add(about1);
about.add(about2);
about.add(about3);
about.add(about4);
about.add(about5);
about.add(about6);
about.add(about7);
about.add(about8);
info.add(help);
info.add(about);
tabbedPane.addTab(" 其他信息 ",info);
main.add(tabbedPane);
}
protected void windowClosed() {
System.exit(0);
}
protected void bookQuery(){
BookQuery bookQuery = new BookQuery(this,"请输入",true);
bookQuery.setVisible(true);
boolean find=false;
if(bookQuery.key!=null && !bookQuery.key.equals("")){
String des = bookQuery.key.toLowerCase();
for(int i=0;i<bookCount;++i){
String cnt=bookContent[i][bookQuery.type].toLowerCase();
if(cnt.contains(des)){ //[模糊查询]
find=true;
BookInput newBook = new BookInput(this,"查询到符合条件",true);
newBook.setValue(bookContent[i][0],bookContent[i][1],bookContent[i][2],
bookContent[i][3],bookContent[i][4],bookContent[i][5],bookContent[i][6],"下一个 (O)","取 消 (C)");
newBook.setVisible(true);
if(newBook.mediaName==null)break;
}
}
if(!find){
JOptionPane.showMessageDialog(this,"很抱歉,没有查询到符合条件的记录");
}
}
}
protected void bookInsert(){
BookInput newBook = new BookInput(this,"请填写记录",true);
newBook.setVisible(true);
if(newBook.mediaName!=null && !newBook.mediaName.equals("")){
MyBook a = new MyBook();
a.setMediaName(newBook.mediaName);
a.setArtist(newBook.artist);
a.setEditor(newBook.editor);
a.setPress(newBook.press);
a.setPrice(newBook.price);
a.setPublishDate(newBook.publishDate);
a.setBookISBN(newBook.bookISBN);
bookInfo[bookcp++]=a;
++bookCount;
showBookTable();
}
}
protected void bookDelete(){
if(bookTable.getSelectedRowCount()!=1){
JOptionPane.showMessageDialog(this,"请选中一条记录");
}
else{
int i,id=bookTable.getSelectedRow();
for(i=0;i<bookcp;++i){
if(!bookInfo[i].delete && bookInfo[i].id==id){
bookInfo[i].delete=true;
--bookCount;
break;
}
}
showBookTable();
}
}
protected void showBookTable(){
bookContent = null;
bookContent = new String[bookCount][7];
for(int i=0,j=0;j<bookcp;++j){
if(!bookInfo[j].delete){
bookContent[i][0]=bookInfo[j].getMediaName();
bookContent[i][1]=bookInfo[j].getArtist();
bookContent[i][2]=bookInfo[j].getEditor();
bookContent[i][3]=bookInfo[j].getPress();
bookContent[i][4]=bookInfo[j].getPrice();
bookContent[i][5]=bookInfo[j].getPublishDate();
bookContent[i][6]=bookInfo[j].getBookISBN();
bookInfo[j].id=i;
++i;
}
}
book.remove(bookScroll);
bookTable = null;
bookScroll = null;
bookTable = new JTable(bookContent, bookHead);
bookTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
bookScroll = new JScrollPane(bookTable);
book.add(bookScroll);
book.setVisible(false);
book.setVisible(true);
}
protected void cdQuery(){
CdQuery cdQuery = new CdQuery(this,"请输入",true);
cdQuery.setVisible(true);
boolean find=false;
if(cdQuery.key!=null && !cdQuery.key.equals("")){
String des = cdQuery.key.toLowerCase();
for(int i=0;i<cdCount;++i){
String cnt = cdContent[i][cdQuery.type].toLowerCase();
if(cnt.contains(des)){
find=true;
CdInput newCd = new CdInput(this,"查询到符合条件",true);
newCd.setValue(cdContent[i][0],cdContent[i][1],cdContent[i][2],
cdContent[i][3],cdContent[i][4],cdContent[i][5],"下一个 (O)","取 消 (C)");
newCd.setVisible(true);
if(newCd.mediaName==null)break;
}
}
if(!find){
JOptionPane.showMessageDialog(this,"很抱歉,没有查询到符合条件的记录");
}
}
}
protected void cdInsert(){
CdInput newCd = new CdInput(this,"请填写记录",true);
newCd.setVisible(true);
//[:)]
if(newCd.artist.equals("ViVo"))JOptionPane.showMessageDialog(this,"I LOVE YOU!");
if(newCd.mediaName!=null && !newCd.mediaName.equals("")){
MyCD a = new MyCD();
a.setMediaName(newCd.mediaName);
a.setArtist(newCd.artist);
a.setPress(newCd.press);
a.setPrice(newCd.price);
a.setCdPublisher(newCd.publisher);
a.setCdISRC(newCd.ISRC);
cdInfo[cdcp++]=a;
++cdCount;
showCdTable();
}
}
protected void cdDelete(){
if(cdTable.getSelectedRowCount()!=1){
JOptionPane.showMessageDialog(this,"请选中一条记录");
}
else{
int i,id=cdTable.getSelectedRow();
for(i=0;i<cdcp;++i){
if(!cdInfo[i].delete && cdInfo[i].id==id){
cdInfo[i].delete=true;
--cdCount;
break;
}
}
showCdTable();
}
}
protected void showCdTable(){
cdContent = null;
cdContent = new String[cdCount][6];
int i,j;
for(i=0,j=0;j<cdcp;++j){
if(!cdInfo[j].delete){
cdContent[i][0]=cdInfo[j].getMediaName();
cdContent[i][1]=cdInfo[j].getArtist();
cdContent[i][2]=cdInfo[j].getPress();
cdContent[i][3]=cdInfo[j].getPrice();
cdContent[i][4]=cdInfo[j].getCdPublisher();
cdContent[i][5]=cdInfo[j].getCdISRC();
cdInfo[j].id=i;
++i;
}
}
cd.remove(cdScroll);
cdTable = null;
cdScroll = null;
cdTable = new JTable(cdContent, cdHead);
cdTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
cdScroll = new JScrollPane(cdTable);
cd.add(cdScroll);
cd.setVisible(false);
cd.setVisible(true);
}
protected void tapeQuery(){
TapeQuery tapeQuery = new TapeQuery(this,"请输入",true);
tapeQuery.setVisible(true);
boolean find=false;
if(tapeQuery.key!=null && !tapeQuery.key.equals("")){
String des = tapeQuery.key.toLowerCase();
for(int i=0;i<tapeCount;++i){
String cnt = tapeContent[i][tapeQuery.type].toLowerCase();
if(cnt.contains(des)){
find=true;
TapeInput newTape = new TapeInput(this,"查询到符合条件",true);
newTape.setValue(tapeContent[i][0],tapeContent[i][1],tapeContent[i][2],tapeContent[i][3],
tapeContent[i][4],"下一个 (O)","取 消 (C)");
newTape.setVisible(true);
if(newTape.mediaName==null)break;
}
}
if(!find){
JOptionPane.showMessageDialog(this,"很抱歉,没有查询到符合条件的记录");
}
}
}
protected void tapeInsert(){
TapeInput newTape = new TapeInput(this,"请填写记录",true);
newTape.setVisible(true);
if(newTape.mediaName!=null && !newTape.mediaName.equals("")){
MyTape a = new MyTape();
a.setMediaName(newTape.mediaName);
a.setArtist(newTape.artist);
a.setPress(newTape.press);
a.setPrice(newTape.price);
a.setTapeISRC(newTape.ISRC);
tapeInfo[tapecp++]=a;
++tapeCount;
showTapeTable();
}
}
protected void tapeDelete(){
if(tapeTable.getSelectedRowCount()!=1){
JOptionPane.showMessageDialog(this,"请选中一条记录");
}
else{
int i,id=tapeTable.getSelectedRow();
for(i=0;i<tapecp;++i){
if(!tapeInfo[i].delete && tapeInfo[i].id==id){
tapeInfo[i].delete=true;
--tapeCount;
break;
}
}
showTapeTable();
}
}
protected void showTapeTable(){
tapeContent = null;
tapeContent = new String[tapeCount][5];
int i,j;
for(i=0,j=0;j<tapecp;++j){
if(!tapeInfo[j].delete){
tapeContent[i][0]=tapeInfo[j].getMediaName();
tapeContent[i][1]=tapeInfo[j].getArtist();
tapeContent[i][2]=tapeInfo[j].getPress();
tapeContent[i][3]=tapeInfo[j].getPrice();
tapeContent[i][4]=tapeInfo[j].getTapeISRC();
tapeInfo[j].id=i;
++i;
}
}
tape.remove(tapeScroll);
tapeTable = null;
tapeScroll = null;
tapeTable = new JTable(tapeContent, tapeHead);
tapeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
tapeScroll = new JScrollPane(tapeTable);
tape.add(tapeScroll);
tape.setVisible(false);
tape.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -