List of usage examples for javax.swing JEditorPane setPreferredSize
@BeanProperty(preferred = true, description = "The preferred size of the component.") public void setPreferredSize(Dimension preferredSize)
From source file:org.isatools.isacreator.visualization.StudyInfoPanel.java
private JPanel prepareStudyInformation() { studyInformation.removeAll();/* w w w. j av a 2 s .c o m*/ JEditorPane currentlyShowingInfo = new JEditorPane(); currentlyShowingInfo.setContentType("text/html"); currentlyShowingInfo.setEditable(false); currentlyShowingInfo.setBackground(UIHelper.BG_COLOR); currentlyShowingInfo.setPreferredSize(new Dimension(width - 10, height - 30)); JScrollPane infoScroller = new JScrollPane(currentlyShowingInfo, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); infoScroller.setBackground(UIHelper.BG_COLOR); infoScroller.getViewport().setBackground(UIHelper.BG_COLOR); infoScroller.setPreferredSize(new Dimension(width - 10, height - 50)); infoScroller.setBorder(null); IAppWidgetFactory.makeIAppScrollPane(infoScroller); Map<String, String> data = getStudyDetails(); String labelContent = "<html>" + "<head>" + "<style type=\"text/css\">" + "<!--" + ".bodyFont {" + " font-family: Verdana;" + " font-size: 9px;" + " color: #006838;" + "}" + "-->" + "</style>" + "</head>" + "<body class=\"bodyFont\">"; for (Object key : data.keySet()) { labelContent += ("<p><b>" + ((String) key).trim() + ": </b>"); labelContent += (data.get(key) + "</font></p>"); } labelContent += "</body></html>"; currentlyShowingInfo.setText(labelContent); studyInformation.add(infoScroller); return studyInformation; }
From source file:org.pentaho.reporting.engine.classic.demo.util.CompoundDemoFrame.java
protected JComponent createDescriptionTextPane(final URL url) { final JEditorPane editorPane = new JEditorPane(); editorPane.setEditable(false);//from w w w. j a va 2 s . c o m editorPane.setPreferredSize(new Dimension(400, 200)); if (url != null) { try { editorPane.setPage(url); } catch (IOException e) { logger.error("Failed to load demo description", e); editorPane.setText("Unable to load the demo description. Error: " + e.getMessage()); } } else { editorPane.setText("Unable to load the demo description. No such resource."); } return new JScrollPane(editorPane, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); }
From source file:org.squidy.designer.knowledgebase.RepositoryItem.java
private void initPane() { // Add Zoomable Component new Thread(new Runnable() { public void run() { // ProgressIndicator indicator = new // ProgressIndicator(InformationShape.this); if (information == null || "".equals(information)) { return; }//from w w w .j a va 2s. c o m URL url = null; try { try { if (information.endsWith(".pdf")) { url = InformationShape.class.getResource(information); } else if (information.endsWith(".html")) { try { url = new URL(information); } catch (Exception e) { url = InformationShape.class.getResource(information); } } else { url = new URL(information); } } catch (Exception e) { // do nothing } PNode cropNode; // PDF if (information.endsWith(".pdf")) { if (LOG.isDebugEnabled()) { LOG.debug("Display information as PDF."); } cropNode = new PDFPane(url.getFile()); } // HTML else { if (LOG.isDebugEnabled()) { LOG.debug("Display information as HTML."); } JEditorPane editorPane = new JEditorPane(); editorPane.setFont(internalFont.deriveFont(10f)); FontMetrics fm = editorPane.getFontMetrics(editorPane.getFont()); int editorWidth = 400; editorPane.setPreferredSize(new Dimension(editorWidth, FontUtils.getLineCount(information, editorWidth) * fm.getHeight())); cropNode = JComponentWrapper.create(editorPane); editorPane.setEditable(false); if (information.endsWith(".html")) { HTMLEditorKit editorKit = new HTMLEditorKit(); editorPane.setEditorKit(editorKit); editorPane.setPage(url); editorPane.setPreferredSize(new Dimension(800, 2000)); } else { editorPane.setText(information); } // Prepare HTML Kit // HTMLParser editorKit = new HTMLParser(); // HTMLParserCallback callback = new // HTMLParserCallback(); // getComponentEditorPane().setEditorKit(editorKit); // //Open connection // InputStreamReader reader = new // InputStreamReader(url.openStream()); // //Start parse process // editorKit.getParser().parse(reader, callback, true); // Wait until parsing process has finished // try { // Thread.sleep(2000); // } // catch (InterruptedException e) { // if (LOG.isErrorEnabled()) { // LOG.error("Error in " + // InformationShape.class.getName() + ".", e); // } // } } cropScroll = new CropScroll(cropNode, new Dimension(1000, 700), 0.2); cropScroll.setOffset( getBoundsReference().getCenterX() - cropScroll.getBoundsReference().getCenterX(), 250); addChild(cropScroll); invalidateFullBounds(); invalidateLayout(); invalidatePaint(); } catch (MalformedURLException e) { if (LOG.isErrorEnabled()) { LOG.error("Could not parse URL from input string: " + e.getMessage() + " in " + RepositoryItem.class.getName() + ".\nInput was: " + information); } } catch (IOException e) { if (LOG.isErrorEnabled()) { LOG.error("Could not create HTMLPane in " + RepositoryItem.class.getName(), e); } } // indicator.done(); } }).start(); }
From source file:org.squidy.designer.zoom.impl.InformationShape.java
private void initPane() { // Add Zoomable Component new Thread(new Runnable() { public void run() { // ProgressIndicator indicator = new // ProgressIndicator(InformationShape.this); if (informationSource == null || "".equals(informationSource)) { return; }/*from w w w. j a va 2 s . c o m*/ try { if (informationSource.endsWith(".pdf")) { url = InformationShape.class.getResource(informationSource); } else if (informationSource.endsWith(".html")) { try { url = new URL(informationSource); } catch (Exception e) { url = InformationShape.class.getResource(informationSource); } } else { url = new URL(informationSource); } } catch (Exception e) { // do nothing } PNode cropNode; // PDF if (informationSource.endsWith(".pdf")) { if (LOG.isDebugEnabled()) { LOG.debug("Display information as PDF."); } cropNode = new PDFPane(url.getFile()); } // HTML else { if (LOG.isDebugEnabled()) { LOG.debug("Display information as HTML."); } if (informationSource.startsWith("http") || informationSource.endsWith(".html")) { XHTMLPanel xhtmlPanel = new XHTMLPanel(); try { xhtmlPanel.setDocument(url.toURI().toString()); } catch (URISyntaxException e) { // TODO Auto-generated catch block e.printStackTrace(); } xhtmlPanel.setPreferredSize(new Dimension(800, 800)); // xhtmlPanel.addPropertyChangeListener("preferredSize", new PropertyChangeListener() { // // public void propertyChange(PropertyChangeEvent evt) { // cropScroll.updateScroller(); // cropNode. // } // }); cropNode = JComponentWrapper.create(xhtmlPanel); } else { JEditorPane editorPane = new JEditorPane(); editorPane.setFont(internalFont.deriveFont(10f)); FontMetrics fm = editorPane.getFontMetrics(editorPane.getFont()); int editorWidth = 400; editorPane.setPreferredSize(new Dimension(editorWidth, FontUtils.getLineCount(informationSource, editorWidth) * fm.getHeight())); cropNode = JComponentWrapper.create(editorPane); editorPane.setEditable(false); editorPane.setText(informationSource); } // Prepare HTML Kit // HTMLParser editorKit = new HTMLParser(); // HTMLParserCallback callback = new // HTMLParserCallback(); // getComponentEditorPane().setEditorKit(editorKit); // //Open connection // InputStreamReader reader = new // InputStreamReader(url.openStream()); // //Start parse process // editorKit.getParser().parse(reader, callback, true); // Wait until parsing process has finished // try { // Thread.sleep(2000); // } // catch (InterruptedException e) { // if (LOG.isErrorEnabled()) { // LOG.error("Error in " + // InformationShape.class.getName() + ".", e); // } // } } cropScroll = new CropScroll(cropNode, new Dimension(1000, 700), 0.2); cropScroll.setOffset( getBoundsReference().getCenterX() - cropScroll.getBoundsReference().getCenterX(), 250); addChild(cropScroll); invalidateFullBounds(); invalidateLayout(); invalidatePaint(); // indicator.done(); } }).start(); }