下面列出了java.awt.HeadlessException#printStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void tableChanged(TableModelEvent e) {
int row=e.getFirstRow();
int userId=Integer.parseInt(table.getValueAt(row, 0).toString());
String userName=table.getValueAt(row, 1).toString();
String pwdString=table.getValueAt(row, 2).toString();
//String IP=table.getValueAt(row, 3).toString();
//String state=table.getValueAt(row, 4).toString();
String userGender=table.getValueAt(row, 5).toString();
String userEmail=table.getValueAt(row, 6).toString();
//String userSignature=table.getValueAt(row, 5).toString();
Date userBirthday=Date.valueOf(table.getValueAt(row, 9).toString());
Users user=new Users(userId,userName,pwdString, userGender, userEmail,userBirthday);
UserDao userDao=new UserDao();
try {
if(userDao.update(user))
{
JOptionPane.showMessageDialog(null, "修改成功!");
}
else {
JOptionPane.showMessageDialog(null, "修改失败!");
}
} catch (HeadlessException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
/**
* Get Top Left X and Y Positions for a Window to centre it on the
* currently active screen at application startup
* @param windowWidth - Window Width
* @param windowHeight - Window Height
*/
public StartUpLocation(double windowWidth, double windowHeight) {
//System.out.println("(" + windowWidth + ", " + windowHeight + ")");
// Get X Y of start-up location on Active Screen
// simple_JavaFX_App
try {
// Get current mouse location, could return null if mouse is moving Super-Man fast
Point p = MouseInfo.getPointerInfo().getLocation();
// Get list of available screens
List<Screen> screens = Screen.getScreens();
if (p != null && screens != null && screens.size() > 1) {
// in order for xPos != 0 and yPos != 0 in startUpLocation, there has to be more than 1 screen
// Screen bounds as rectangle
Rectangle2D screenBounds;
// Go through each screen to see if the mouse is currently on that screen
for (Screen screen : screens) {
screenBounds = screen.getVisualBounds();
// Trying to compute Left Top X-Y position for the Applcation Window
// If the Point p is in the Bounds
if (screenBounds.contains(p.x, p.y)) {
// Fixed Size Window Width and Height
xPos = screenBounds.getMinX() + ((screenBounds.getMaxX() - screenBounds.getMinX() - windowWidth) / 2);
yPos = screenBounds.getMinY() + ((screenBounds.getMaxY() - screenBounds.getMinY() - windowHeight) / 2);
return;
}
}
}
} catch (HeadlessException headlessException) {
// Catch and report exceptions
headlessException.printStackTrace();
}
}
public static void displayErrorDialogAndThrowException(String errorMesg, Throwable t, boolean rethrowException) {
try {
if(errorMesg != null && errorMesg.length() > 80) {
errorMesg = errorMesg.replaceAll("(.{80})", "$1\n");
}
JOptionPane.showMessageDialog(null, errorMesg, "Fatal error", JOptionPane.ERROR_MESSAGE);
} catch (HeadlessException e) {
e.printStackTrace();
}
if(rethrowException) {
throw new RuntimeException(errorMesg, t);
}
}
public static void displayErrorDialogAndThrowException(String errorMesg, Throwable t, boolean rethrowException) {
try {
if(errorMesg != null && errorMesg.length() > 80) {
errorMesg = errorMesg.replaceAll("(.{80})", "$1\n");
}
JOptionPane.showMessageDialog(null, errorMesg, "Fatal error", JOptionPane.ERROR_MESSAGE);
} catch (HeadlessException e) {
e.printStackTrace();
}
if(rethrowException) {
throw new RuntimeException(errorMesg, t);
}
}
@Override
public void actionPerformed(ActionEvent e) {
// SwingUtilities.invokeLater(new Runnable(){
// public void run() {
// MainPanel.getInstance().setCenterPanel(UserManagePanel.getInstance());
// }
// });
try {
int option = JOptionPane.showConfirmDialog(panel, "要删除用户'"+selectedUserId+"'吗?");
if ( option == JOptionPane.YES_OPTION ) {
int childCount = model.getRoot().getChildCount();
for ( int i=0; i<childCount; i++ ) {
UserTreeTableNode treeNode = (UserTreeTableNode)(model.getRoot().getChildAt(i));
UserId userId = (UserId)treeNode.getKey();
if ( this.selectedUserId.equals(userId) ) {
model.removeNodeFromParent(treeNode);
User user = UserManager.getInstance().queryUser(userId);
String accountName = user.getAccountName();
Account account = AccountManager.getInstance().queryAccountByName(accountName);
user.setAccount(account);
//UserManager.getInstance().removeUser(selectedUserId);
AccountManager.getInstance().deleteGameRole(null, user);
panel.updateButtonStatus();
break;
}
}
}
} catch (HeadlessException e1) {
e1.printStackTrace();
}
}