Java Code Examples for java.awt.HeadlessException#printStackTrace()

The following examples show how to use java.awt.HeadlessException#printStackTrace() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UserTableCahnged.java    From myqq with MIT License 5 votes vote down vote up
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();
	}
	
}
 
Example 2
Source File: StartUpLocation.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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();
    }
    
}
 
Example 3
Source File: Utils.java    From java-scanner-access-twain with GNU Affero General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example 4
Source File: Utils.java    From java-ocr-api with GNU Affero General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example 5
Source File: UserDelAction.java    From gameserver with Apache License 2.0 5 votes vote down vote up
@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();
		}
	}