JEditorPane jp = new JEditorPane("text/html", textString); jp.validate(); int w = jp.getWidth(), h = jp.getHeight(); BufferedImage saveimg = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); Graphics2D g2 = saveimg.createGraphics(); jp.paint(g2);
/** * Add a JEditorPane to the bottom on the dialog. */ private void addMessagePanel() { htmlPanel = new JPanel(); htmlPane = new JEditorPane("text/html", ""); htmlPane.setEditable(false); htmlPane.validate(); htmlPanel.setLayout(new GridLayout(1, 1)); htmlPanel.setPreferredSize(new Dimension(100, 100)); htmlPanel.add(new JScrollPane(htmlPane), BorderLayout.CENTER); htmlPanel.validate(); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.gridx = 0; c.gridy = 1; c.gridwidth = 3; c.weightx = 1.0; c.weighty = 1.0; c.anchor = GridBagConstraints.SOUTH; startTime = new Date().getTime(); lastReportTime = startTime; timer.activity.getViewPanel(false).add(htmlPanel, c); }
public void run() { HTMLDocument doc = (HTMLDocument) issuesInfoPane.getDocument(); issuesInfoPane.setText(_appStr); issuesInfoPane.validate(); issuesInfoPane.setCaretPosition(0); registerHTMLButton(doc, "enter", new ActionListener() { //NOI18N
public void run() { commChannelsDisplayer.setText(_istr); commChannelsDisplayer.validate(); commChannelsDisplayer.setCaretPosition(0); HTMLDocument htm = (HTMLDocument) commChannelsDisplayer.getDocument(); Element e = htm.getElement(CHAT_BUTTON); if (e != null) { AttributeSet attr = e.getAttributes(); Enumeration enu = attr.getAttributeNames(); while (enu.hasMoreElements()) { Object name = enu.nextElement(); Object value = attr.getAttribute(name); if ("model".equals(name.toString())) { //NOI18N final DefaultButtonModel model = (DefaultButtonModel) value; model.setActionCommand(CHAT_BUTTON); model.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { ChatTopComponent ct = ChatTopComponent.findInstance(); ct.open(); ct.requestActive(); ct.setActiveGroup(instProj.getName() + "@muc." + instProj.getKenai().getUrl().getHost()); // NOI18N } }); } } } } });
JEditorPane.validate();