public void print(PrintJob pj) {
		String text = getText();
		Dimension pageSize = pj.getPageDimension();
		Graphics g = pj.getGraphics();
		FontMetrics fm = g.getFontMetrics();
		int fontHeight = fm.getHeight();
		int linesPerPage = pageSize.height / fontHeight;
		int nLines = countLines(text);
		int nPages = 1 + (nLines - 1) / linesPerPage;
		int top = 0;
		for (int page = 1; page <= nPages; page++) {
			if (page > 1) g = pj.getGraphics();
			int bottom = getLineY(text, 1 + page * linesPerPage);
			g.translate(0, -top);
			g.setClip(0, top, pageSize.width, bottom - top);
			textPane.paint(g);
			g.dispose();
			top = bottom;
		}
	}