Skip to content

Commit 34d6d57

Browse files
committed
fix bugs
1 parent c575818 commit 34d6d57

File tree

3 files changed

+26
-20
lines changed

3 files changed

+26
-20
lines changed

src/Library/DlgAddBooks.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import javax.swing.*;
55

66
import java.awt.*;
7+
import java.awt.event.ActionEvent;
8+
import java.awt.event.ActionListener;
79
import java.awt.event.MouseAdapter;
810
import java.awt.event.MouseEvent;
911
import java.awt.image.BufferedImage;
@@ -93,10 +95,11 @@ public class DlgAddBooks extends JDialog {
9395
this.setLayout(null);
9496
//this.setVisible(true); //remove by Li Huang 2014.8.15 to make it can be shown in Modal way
9597

96-
choosePic.addMouseListener(new MouseAdapter() // choose a picture
98+
//choosePic.addMouseListener(new MouseAdapter() // choose a picture
99+
choosePic.addActionListener(new ActionListener() // choose a picture
97100
{
98-
public void mouseClicked(MouseEvent me) {
99-
101+
@Override
102+
public void actionPerformed(ActionEvent e) {
100103
// System.out.println("fffff"); //test1
101104
FileDialog readFD = new FileDialog(new Frame(),
102105
"Choose a file", FileDialog.LOAD);
@@ -112,10 +115,11 @@ public void mouseClicked(MouseEvent me) {
112115
}
113116
});
114117

115-
add.addMouseListener(new MouseAdapter() // add new book
118+
//add.addMouseListener(new MouseAdapter() // add new book
119+
add.addActionListener(new ActionListener() // add new book
116120
{
117-
public void mouseClicked(MouseEvent me) {
118-
121+
@Override
122+
public void actionPerformed(ActionEvent e) {
119123
Validator test = new Validator();
120124

121125
String currentISBN = jtf_isbn.getText();
@@ -173,7 +177,7 @@ public void mouseClicked(MouseEvent me) {
173177
// new reName().rename(picDirectory, picFileName,
174178
// currentISBN);
175179
library.copyBookImage(picDirectory, picFileName, currentISBN);
176-
} catch (Exception e) {
180+
} catch (Exception ex) {
177181
// TODO Auto-generated catch block
178182
System.out.println("No picture selected.");
179183
} finally {
@@ -184,18 +188,17 @@ public void mouseClicked(MouseEvent me) {
184188
}
185189

186190
}
187-
188191
else {
189192
JOptionPane.showMessageDialog(DlgAddBooks.this,
190193
"Invaild book information!", "Error",
191194
JOptionPane.ERROR_MESSAGE);
192195
}
193-
194-
}// mouse clicked
196+
}
195197
});
196198

197-
close.addMouseListener(new MouseAdapter() {
198-
public void mouseClicked(MouseEvent me) {
199+
close.addActionListener( new ActionListener() {
200+
@Override
201+
public void actionPerformed(ActionEvent e) {
199202
//FrmAddBooks.this.setVisible(false); //modify by Li Huang. use dispose() to totally dispose this window
200203
DlgAddBooks.this.dispose();
201204
}

src/Library/DlgAddUsers.java

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import javax.swing.*;
44

5+
import java.awt.event.ActionEvent;
6+
import java.awt.event.ActionListener;
57
import java.awt.event.MouseAdapter;
68
import java.awt.event.MouseEvent;
79

@@ -43,10 +45,10 @@ public class DlgAddUsers extends JDialog {
4345
this.setLayout(null);
4446
//this.setVisible(true); //del by Li Huang 2014.8.14
4547

46-
addUser.addMouseListener(new MouseAdapter() // add new user
48+
addUser.addActionListener(new ActionListener() // add new user
4749
{
48-
public void mouseClicked(MouseEvent me) {
49-
50+
@Override
51+
public void actionPerformed(ActionEvent e) {
5052
Validator validator = new Validator();
5153
if (validator.isUserIdValid(infoPanel.getIdText())
5254
&& validator.isUserNameValid(infoPanel.getNameText())
@@ -67,12 +69,13 @@ public void mouseClicked(MouseEvent me) {
6769
"Invaild user information!", "Error",
6870
JOptionPane.ERROR_MESSAGE);
6971
}
70-
71-
}// mouse clicked
72+
}
7273
});
7374

74-
close.addMouseListener(new MouseAdapter() {
75-
public void mouseClicked(MouseEvent me) {
75+
close.addActionListener( new ActionListener()
76+
{
77+
@Override
78+
public void actionPerformed(ActionEvent e) {
7679
bool_isActionAdd = false;
7780
//FrmAddUsers.this.setVisible(false); //modify by Li Huang 2014.8.14: dirctedly dispose this window
7881
DlgAddUsers.this.dispose();

src/Library/FrmAbout.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public class FrmAbout extends JDialog{
3030
private Random r;
3131

3232
private final String StrAuthors = "Zhipeng Zhou, Run Yan, Sen Li, Li Huang";
33-
private final String StrVersion = "Version: "+ new DecimalFormat("#0.00").format(0.9);
33+
private final String StrVersion = "Version: "+ new DecimalFormat("#0.00").format(1.0);
3434

3535
public FrmAbout() {
3636
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

0 commit comments

Comments
 (0)