List of usage examples for javax.swing JEditorPane setText
@BeanProperty(bound = false, description = "the text of this component") public void setText(String t)
TextComponent
to the specified content, which is expected to be in the format of the content type of this editor. From source file:io.github.jeddict.jpa.modeler.properties.classmember.ClassMemberPanel.java
private String getCode(String code, String title) { JEditorPane editorPane = new JEditorPane(); editorPane.setContentType("text/x-java"); editorPane.setPreferredSize(new java.awt.Dimension(600, 400)); editorPane.setText(code); OptionDialog dialog = new OptionDialog(editorPane, title); dialog.setVisible(true);/* w w w. j ava2s. c o m*/ if (OK_OPTION == dialog.getDialogResult()) { return editorPane.getText(); } else { return code; } }
From source file:com.eviware.soapui.support.SoapUIVersionUpdate.java
protected JEditorPane createReleaseNotesPane() { JEditorPane text = new JEditorPane(); try {//from w w w .j a v a 2s.c o m text.setPage(getReleaseNotes()); text.setEditable(false); text.setBorder(BorderFactory.createLineBorder(Color.black)); } catch (IOException e) { text.setText(NO_RELEASE_NOTES_INFO); SoapUI.logError(e); } return text; }
From source file:Main.java
public JComponent makeEditorPane(String bullet) { JEditorPane pane = new JEditorPane(); pane.setContentType("text/html"); pane.setEditable(false);//from ww w. jav a 2 s . c om if (bullet != null) { HTMLEditorKit htmlEditorKit = (HTMLEditorKit) pane.getEditorKit(); StyleSheet styleSheet = htmlEditorKit.getStyleSheet(); String u = "http://i.stack.imgur.com/jV29K.png"; styleSheet.addRule(String.format("ul{list-style-image:url(%s);margin:0px 20px;", u)); // styleSheet.addRule("ul{list-style-type:disc;margin:0px 20px;}"); } pane.setText("<html><h1>Heading</h1>Text<ul><li>Bullet point</li></ul></html>"); return pane; }
From source file:eu.apenet.dpt.standalone.gui.APETabbedPane.java
public JComponent createMsgEditionTree(String msg) { JEditorPane waitMessagePane = new JEditorPane(); waitMessagePane.setEditable(false);/*from w w w. j ava2 s . co m*/ waitMessagePane.setContentType("text/plain"); waitMessagePane.setText(msg); waitMessagePane.setCaretPosition(0); return waitMessagePane; }
From source file:com.dmrr.asistenciasx.Horarios.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try {// www .j av a2 s .com int x = jTableHorarios.getSelectedRow(); if (x == -1) { JOptionPane.showMessageDialog(this, "Seleccione un profesor primero", "Datos incompletos", JOptionPane.WARNING_MESSAGE); return; } Integer idProfesor = Integer .parseInt((String) jTableHorarios.getValueAt(jTableHorarios.getSelectedRow(), 1)); JPasswordField pf = new JPasswordField(); String nip = ""; int okCxl = JOptionPane.showConfirmDialog(null, pf, "Introduzca el NIP del jefe del departamento", JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); if (okCxl == JOptionPane.OK_OPTION) { nip = new String(pf.getPassword()); } else { return; } org.jsoup.Connection.Response respuesta = Jsoup .connect("http://siiauescolar.siiau.udg.mx/wus/gupprincipal.valida_inicio") .data("p_codigo_c", "2225255", "p_clave_c", nip).method(org.jsoup.Connection.Method.POST) .timeout(0).execute(); Document login = respuesta.parse(); String sessionId = respuesta.cookie(getFecha() + "SIIAUSESION"); String sessionId2 = respuesta.cookie(getFecha() + "SIIAUUDG"); Document listaHorarios = Jsoup.connect("http://siiauescolar.siiau.udg.mx/wse/sspsecc.consulta_oferta") .data("ciclop", "201510", "cup", "J", "deptop", "", "codprofp", "" + idProfesor, "ordenp", "0", "mostrarp", "1000", "tipop", "T", "secp", "A", "regp", "T") .userAgent("Mozilla").cookie(getFecha() + "SIIAUSESION", sessionId) .cookie(getFecha() + "SIIAUUDG", sessionId2).timeout(0).post(); Elements tabla = listaHorarios.select("body"); tabla.select("style").remove(); Elements font = tabla.select("font"); font.removeAttr("size"); System.out.println(tabla.html()); JEditorPane jEditorPane = new JEditorPane(); jEditorPane.setEditable(false); HTMLEditorKit kit = new HTMLEditorKit(); jEditorPane.setEditorKit(kit); javax.swing.text.Document doc = kit.createDefaultDocument(); jEditorPane.setDocument(doc); jEditorPane.setText(tabla.html()); JOptionPane.showMessageDialog(null, jEditorPane); } catch (IOException ex) { Logger.getLogger(Horarios.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.enderville.enderinstaller.ui.Installer.java
private void loadModDescription(String modName) { JPanel p = getModDescriptionPane(); p.removeAll();/* w w w . ja v a 2 s .c o m*/ p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); final String extras = InstallerConfig.getExtraModsFolder(); final String modFolderName = FilenameUtils.concat(extras, modName); File modFolder = new File(modFolderName); if (!modFolder.exists()) { LOGGER.error("Mod folder for " + modName + " does not exist."); } File descrFile = new File(FilenameUtils.concat(modFolderName, "description.txt")); File imgFile = new File(FilenameUtils.concat(modFolderName, "image.png")); if (!descrFile.exists() && !imgFile.exists()) { p.add(new JLabel("<html>No description for:<br>" + modName + "</html>")); } else { if (imgFile.exists()) { try { JLabel label = new JLabel(); BufferedImage img = ImageIO.read(imgFile); label.setIcon(new ImageIcon(img)); p.add(label); } catch (IOException e) { LOGGER.error("Error reading image file: " + imgFile.getPath(), e); } } if (descrFile.exists()) { StringBuilder buffer = new StringBuilder(); try { BufferedReader r = new BufferedReader(new FileReader(descrFile)); String l = null; while ((l = r.readLine()) != null) { buffer.append(l + "\n"); } r.close(); JEditorPane area = new JEditorPane(); area.setContentType("text/html"); area.setText(buffer.toString()); area.setEditable(false); area.addHyperlinkListener(this); area.setCaretPosition(0); p.add(new JScrollPane(area)); } catch (IOException e) { LOGGER.error("Error reading description file: " + descrFile.getPath(), e); } } } p.validate(); p.repaint(); }
From source file:org.squale.squaleweb.applicationlayer.action.export.ppt.PPTData.java
/** * Convert a html code to an image/*ww w .jav a 2 s . c o m*/ * * @param html html to convert * @return html converted to png * @throws IOException if error * @throws PPTGeneratorException */ protected byte[] htmlToImage(String html) throws IOException, PPTGeneratorException { try { JEditorPane editor = new JEditorPane(); editor.setContentType("text/html"); editor.setText(html); editor.setSize(editor.getPreferredSize()); editor.addNotify(); LOGGER.debug("Panel is built"); BufferedImage bufferSave = new BufferedImage(editor.getPreferredSize().width, editor.getPreferredSize().height, BufferedImage.TYPE_3BYTE_BGR); Graphics g = bufferSave.getGraphics(); g.setColor(Color.WHITE); g.fillRect(0, 0, editor.getPreferredSize().width, editor.getPreferredSize().height); editor.paint(g); LOGGER.debug("graphics is drawn"); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(bufferSave, "png", out); return out.toByteArray(); } catch (HeadlessException e) { LOGGER.error("X Server no initialized or -Djava.awt.headless=true not set !"); throw new PPTGeneratorException("X Server no initialized or -Djava.awt.headless=true not set !"); } }
From source file:org.squale.squaleweb.applicationlayer.action.export.ppt.PPTData.java
/** * Add an image with a html code without change its dimension * // w ww. j a v a2 s . com * @param slideToSet slide to set * @param html html code * @param x horizontal position * @param y vertical position * @throws IOException if error * @throws PPTGeneratorException */ protected void addHtmlPicture(Slide slideToSet, String html, int x, int y) throws IOException, PPTGeneratorException { try { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); if (!ge.isHeadlessInstance()) { LOGGER.warn("Runtime is not configured for supporting graphiv manipulation !"); } JEditorPane editor = new JEditorPane(); editor.setContentType("text/html"); editor.setText(html); LOGGER.debug("Editor pane is built"); editor.setSize(editor.getPreferredSize()); editor.addNotify(); // Serveur X requis LOGGER.debug("Panel rendering is done"); BufferedImage bufferSave = new BufferedImage(editor.getPreferredSize().width, editor.getPreferredSize().height, BufferedImage.TYPE_3BYTE_BGR); Graphics g = bufferSave.getGraphics(); g.setColor(Color.WHITE); g.fillRect(0, 0, editor.getPreferredSize().width, editor.getPreferredSize().height); editor.paint(g); LOGGER.debug("graphics is drawn"); ByteArrayOutputStream out = new ByteArrayOutputStream(); ImageIO.write(bufferSave, "png", out); LOGGER.debug("image is written"); addPicture(slideToSet, out.toByteArray(), new Rectangle(x, y, editor.getPreferredSize().width, editor.getPreferredSize().height)); LOGGER.debug("image is added"); } catch (HeadlessException e) { LOGGER.error("X Server no initialized or -Djava.awt.headless=true not set !"); throw new PPTGeneratorException("X Server no initialized or -Djava.awt.headless=true not set !"); } }
From source file:net.sf.taverna.t2.workbench.ui.credentialmanager.WarnUserAboutJCEPolicyDialog.java
private void initComponents() { // Base font for all components on the form Font baseFont = new JLabel("base font").getFont().deriveFont(11f); // Message saying that updates are available JPanel messagePanel = new JPanel(new BorderLayout()); messagePanel.setBorder(new CompoundBorder(new EmptyBorder(10, 10, 10, 10), new EtchedBorder(LOWERED))); JEditorPane message = new JEditorPane(); message.setEditable(false);//from w w w .j a v a 2s . c o m message.setBackground(this.getBackground()); message.setFocusable(false); HTMLEditorKit kit = new HTMLEditorKit(); message.setEditorKit(kit); StyleSheet styleSheet = kit.getStyleSheet(); //styleSheet.addRule("body {font-family:"+baseFont.getFamily()+"; font-size:"+baseFont.getSize()+";}"); // base font looks bigger when rendered as HTML styleSheet.addRule("body {font-family:" + baseFont.getFamily() + "; font-size:10px;}"); Document doc = kit.createDefaultDocument(); message.setDocument(doc); message.setText( "<html><body>In order for Taverna's security features to function properly - you need to install<br>" + "'Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy'. <br><br>" + "If you do not already have it, for <b>Java 6</b> you can get it from:<br>" + "<a href=\"http://www.oracle.com/technetwork/java/javase/downloads/index.html\">http://www.oracle.com/technetwork/java/javase/downloads/index.html</a><br<br>" + "Installation instructions are contained in the bundle you download." + "</body><html>"); message.addHyperlinkListener(new HyperlinkListener() { @Override public void hyperlinkUpdate(HyperlinkEvent he) { HyperlinkEvent.EventType type = he.getEventType(); if (type == ACTIVATED) // Open a Web browser try { getDesktop().browse(he.getURL().toURI()); // BrowserLauncher launcher = new BrowserLauncher(); // launcher.openURLinBrowser(he.getURL().toString()); } catch (Exception ex) { logger.error("Failed to launch browser to fetch JCE " + he.getURL()); } } }); message.setBorder(new EmptyBorder(5, 5, 5, 5)); messagePanel.add(message, CENTER); doNotWarnMeAgainCheckBox = new JCheckBox("Do not warn me again"); doNotWarnMeAgainCheckBox.setFont(baseFont.deriveFont(12f)); messagePanel.add(doNotWarnMeAgainCheckBox, SOUTH); // Buttons JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER)); JButton okButton = new JButton("OK"); okButton.setFont(baseFont); okButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { okPressed(); } }); buttonsPanel.add(okButton); getContentPane().setLayout(new BorderLayout()); getContentPane().add(messagePanel, CENTER); getContentPane().add(buttonsPanel, SOUTH); pack(); setResizable(false); // Center the dialog on the screen (we do not have the parent) Dimension dimension = getToolkit().getScreenSize(); Rectangle abounds = getBounds(); setLocation((dimension.width - abounds.width) / 2, (dimension.height - abounds.height) / 2); setSize(getPreferredSize()); }
From source file:com.eviware.soapui.support.components.BrowserComponent.java
public Component getComponent() { if (SoapUI.isJXBrowserDisabled()) { JEditorPane jxbrowserDisabledPanel = new JEditorPane(); jxbrowserDisabledPanel.setText("Browser Component disabled or not available on this platform"); panel.add(jxbrowserDisabledPanel); } else {//from ww w . j av a 2 s. c om if (browser == null) { if (addStatusBar) { statusBar = new JPanel(new BorderLayout()); statusLabel = new JLabel(); UISupport.setFixedSize(statusBar, new Dimension(20, 20)); statusBar.add(statusLabel, BorderLayout.WEST); panel.add(statusBar, BorderLayout.SOUTH); } if (!initBrowser()) return panel; configureBrowser(); browser.navigate("about:blank"); } } return panel; }