List of usage examples for javax.swing JTabbedPane getComponent
public Component getComponent(int n)
From source file:tourma.utils.web.WebStatistics.java
/** * /*from w w w .j a v a 2s. c om*/ */ public static String getHTML() { StringBuffer stats = new StringBuffer(""); JPNStatistics jpn = new JPNStatistics(); jpn.setSize(640, 480); JTabbedPane jtp = jpn.getTabbedPane(); for (int i = 0; i < jtp.getTabCount(); i++) { Component comp = jtp.getComponent(i); if (comp instanceof ChartPanel) { ChartPanel panel = (ChartPanel) comp; panel.setSize(640, 480); BufferedImage buf = new BufferedImage(640, 480, BufferedImage.TYPE_INT_ARGB); Graphics g = buf.createGraphics(); panel.print(g); g.dispose(); //BufferedImage buf = toBufferedImage(img, 640, 480); String img_str = WebPicture.getPictureAsHTML(buf, 640, 480, true); stats.append(img_str); } if (comp instanceof JPanel) { // Find JList, Select All then Find ChartPanel JPanel pane = (JPanel) comp; ChartPanel panel = null; JList list = null; for (int j = 0; j < pane.getComponentCount(); j++) { Component c = pane.getComponent(j); if (c instanceof JScrollPane) { for (int k = 0; k < ((JScrollPane) c).getViewport().getComponentCount(); k++) { Component c2 = ((JScrollPane) c).getViewport().getComponent(k); if (c2 instanceof JList) { list = (JList) c2; } } } } if (list != null) { int start = 0; int end = list.getModel().getSize() - 1; if (end >= 0) { list.setSelectionInterval(start, end); } jpn.updatePositions(); } for (int j = 0; j < pane.getComponentCount(); j++) { Component c = pane.getComponent(j); if (c instanceof ChartPanel) { panel = (ChartPanel) c; } } if (panel != null) { panel.setSize(640, 480); BufferedImage buf = new BufferedImage(640, 480, BufferedImage.TYPE_INT_ARGB); Graphics g = buf.createGraphics(); panel.print(g); g.dispose(); //BufferedImage buf = toBufferedImage(img, 640, 480); String img_str = WebPicture.getPictureAsHTML(buf, 640, 480, true); stats.append(img_str); } } } return stats.toString(); }