javax.swing.JTextPane.setPage()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中javax.swing.JTextPane.setPage()方法的一些代码示例,展示了JTextPane.setPage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextPane.setPage()方法的具体详情如下:
包路径:javax.swing.JTextPane
类名称:JTextPane
方法名:setPage

JTextPane.setPage介绍

暂无

代码示例

代码示例来源:origin: marytts/marytts

licenseTextPane.setPage(licenseURL);
} catch (IOException ioe) {
  licenseTextPane

代码示例来源:origin: marytts/marytts

licenseTextPane.setPage(licenseURL);
} catch (IOException ioe) {
  licenseTextPane

代码示例来源:origin: KokaKiwi/MCLauncher

public void run()
{
  try
  {
    editorPane.setPage(url);
  }
  catch (final IOException e)
  {
    editorPane
        .setText("<html><body>Error during loading page. :(</body></html>");
    e.printStackTrace();
  }
}

代码示例来源:origin: stackoverflow.com

JTextPane pane = new JTextPane();
JFrame frame = new JFrame("Example");
frame.add(pane);
frame.setVisible(true);
File file = new File(args[0]);
pane.setPage(file.toURL().toString());
frame.pack();

代码示例来源:origin: chatty/chatty

/**
 * Loads the given page into the window. This only changes the page, not
 * the position in the page, although loading the page can trigger just
 * that.
 * 
 * @param page 
 */
private void loadPage(String page) {
  try {
    textPane.setPage(getClass().getResource(page));
    currentPage = page;
  } catch (IOException ex) {
    LOGGER.warning("Invalid page: "+page+" ("+ex.getLocalizedMessage()+")");
  }
}

代码示例来源:origin: RPTools/maptool

public void run() {
    try {
      JTextPane pane = new JTextPane();
      pane.setPage(licenseFileFinal.toURI().toURL());
      JOptionPane.showMessageDialog(MapTool.getFrame(), pane, "License for " + libraryName, JOptionPane.INFORMATION_MESSAGE);
    } catch (MalformedURLException e) {
      log.error("Could not load license file: " + licenseFileFinal, e);
    } catch (IOException e) {
      log.error("Could not load license file: " + licenseFileFinal, e);
    }
  }
});

代码示例来源:origin: stackoverflow.com

JTextPane tp = new JTextPane();
JScrollPane js = new JScrollPane();
js.getViewport().add(tp);
JFrame jf = new JFrame();
jf.getContentPane().add(js);
jf.pack();
jf.setSize(800,800);
jf.setVisible(true); 

try {
 URL url = new URL("http://www.google.com");
 tp.setPage(url);
} 
catch (Exception e) {
 e.printStackTrace();
}

代码示例来源:origin: org.zaproxy/zap

private void showLicense(int page) {
  String localUrl = null;
  switch (page) {
//String remoteUrl = "http://www.statistica.unimib.it/utenti/dellavedova/software/artistic2.html";
    case 0:
      localUrl = "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "license/TheClarifiedArtisticLicense.htm";
      break;
  }
  try{
    txtLicense.setPage(localUrl);
  } catch (final IOException e){
    e.printStackTrace();
     JOptionPane.showMessageDialog(new JFrame(), "Error: setting file is missing. Program will exit.");
     System.exit(0);
  }
}

代码示例来源:origin: KokaKiwi/MCLauncher

public void hyperlinkUpdate(HyperlinkEvent he)
  {
    if (he.getEventType() == EventType.ACTIVATED)
    {
      try
      {
        editorPane.setPage(he.getURL());
      }
      catch (final IOException e)
      {
        e.printStackTrace();
      }
    }
  }
});

代码示例来源:origin: org.zaproxy/zap

private void showLicense(int page) {
  String localUrl = null;
  switch (page) {
//String remoteUrl = "http://www.statistica.unimib.it/utenti/dellavedova/software/artistic2.html";
    case 0:
      //localUrl = "file:" + System.getProperty("user.dir") + System.getProperty("file.separator") + "license/TheClarifiedArtisticLicense.htm";
      localUrl = "file:" + Constant.getZapInstall() + System.getProperty("file.separator") + "license/ApacheLicense-2.0.txt";
      break;
  }
  try{
    txtLicense.setPage(localUrl);
  } catch (final IOException e){
    e.printStackTrace();
     JOptionPane.showMessageDialog(new JFrame(), "Error: setting file is missing. Program will exit.");
     System.exit(0);
  }
}

代码示例来源:origin: iamxiatian/xsimilarity

public static JPanel createPanel() {
  JPanel mainPanel = new JPanel();
  mainPanel.setLayout(new BorderLayout());
  JTextPane editorPane = new JTextPane();
  editorPane.setEditable(false);
  //让长文本自动换行
  editorPane.setEditorKit(new StyledEditorKit());
  editorPane.setContentType("text/html");
  try {
    URL url = Resources.getResource("about.html");//可以用html格式文件做你的帮助系统了
    editorPane.setPage(url);
  } catch (IOException e1) {
    editorPane.setText(e1.getMessage());
  }
  //editorPane.setText("<html><body>个人主页:<a href='xiatian.irm.cn'>http://xiatian.irm.cn/</a></body></html>");
  mainPanel.add(new JScrollPane(editorPane), BorderLayout.CENTER);
  return mainPanel;
}

代码示例来源:origin: com.metsci.glimpse/glimpse-wizard

public DescriptionWizardPage( Object id, Object parentId, String title, String descriptionFile )
{
  super( id, parentId, title );
  this.descriptionFile = descriptionFile;
  this.container.setLayout( new MigLayout( ) );
  JTextPane descriptionArea = new JTextPane( );
  descriptionArea.setEditable( false );
  descriptionArea.setOpaque( false );
  URL url = getDescriptionResource( descriptionFile );
  try
  {
    descriptionArea.setPage( url );
  }
  catch ( IOException e )
  {
    descriptionArea.setText( String.format( "Error: Unable to load page description from: %s", descriptionFile ) );
  }
  this.container.add( descriptionArea, "split, span, pushx, growx, wrap" );
  this.container.add( new JSeparator( SwingConstants.HORIZONTAL ), "split, span, gap 0 0 10 10, pushx, growx, wrap" );
}

代码示例来源:origin: edu.illinois.lis/indri

/** Create the frame that shows the help file and render the html.
 */
private void makeHelp() {
java.net.URL helpURL = IndexUI.class.getResource(helpFile);
JTextPane help = new JTextPane();
  
//Create and set up the window.
helpFrame = new JFrame("Indri Index Builder Help");
help.setPreferredSize(new Dimension(650, 400));
help.setEditable(false);
help.addHyperlinkListener(new DocLinkListener(indriIcon.getImage()));
JScrollPane scroller = new JScrollPane(help); 
try {
  help.setPage(helpURL);
} catch (IOException ex) {
  help.setText("Help file unavailable.");
}
helpFrame.getContentPane().add(scroller, BorderLayout.CENTER);
helpFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
helpFrame.setIconImage(indriIcon.getImage());
helpFrame.pack();
}

代码示例来源:origin: stackoverflow.com

final JTextPane pane = new JTextPane();
 pane.setEditable(false);
 pane.setContentType("text/html");
 pane.setPage("http://swingx.java.net");
 ToolTipManager.sharedInstance().registerComponent(pane);
 HyperlinkListener l = new HyperlinkListener() {
   @Override
   public void hyperlinkUpdate(HyperlinkEvent e) {
     if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) {
       try {
         pane.setPage(e.getURL());
       } catch (IOException e1) {
         e1.printStackTrace();
       }
     }
   }
 };
 pane.addHyperlinkListener(l);

代码示例来源:origin: de.dfki.mary/marytts-runtime

licenseTextPane.setPage(licenseURL);
} catch (IOException ioe) {
  licenseTextPane

代码示例来源:origin: edu.illinois.lis/indri

/** Create the frame that shows the help file and render the html.
Saves time when the user opens the help.
*/
private void makeHelp() {
java.net.URL helpURL = RetUI.class.getResource(helpFile);
Image image = createImageIcon(iconFile).getImage();
JTextPane help = new JTextPane();
  
//Create and set up the window.
helpFrame = new JFrame("Indri Retrieval UI Help");
help.setPreferredSize(new Dimension(650, 400));
help.setEditable(false);
help.addHyperlinkListener(new DocLinkListener(image));
JScrollPane scroller = new JScrollPane(help);
try {
  help.setPage(helpURL);
} catch (IOException ex) {
  help.setText("Help file unavailable.");
}
helpFrame.getContentPane().add(scroller, BorderLayout.CENTER);
helpFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);    
helpFrame.setIconImage(image);
helpFrame.pack();
}

代码示例来源:origin: org.vesalainen.dsql/dsql

public HelpDialog()
{
  super(null, ModalityType.MODELESS);
  try
  {
    JTextPane pane = new JTextPane();
    pane.setEditable(false);
    String path = "doc-files/DSQLParser-batchStatement.html";
    URL url = DSQLParser.class.getResource(path);
    pane.setPage(url);
    JScrollPane scrollPane = new JScrollPane(pane);
    setPreferredSize(new Dimension(450, 410));
    add(scrollPane, BorderLayout.CENTER);
    pack();
    setVisible(true);
  }
  catch (IOException ex)
  {
    throw new IllegalArgumentException(ex);
  }
}

代码示例来源:origin: org.activecomponents.jadex/jadex-commons-gui

/**
   *  Open an url in this pane.
   */
  public void	setPage(URL url)
  {
    try
    {
      // Hack??? Allow relative file urls to be loaded
      setDocument(getEditorKit().createDefaultDocument());

      super.setPage(url);
//            history.add(url);
    }
    catch(IOException ex)
    {
      BrowserPane.this.setText("Could not open page: "+ex);
    }
  }

代码示例来源:origin: edu.stanford.protege/org.protege.editor.core.application

pane.setEditable(false);
URL u = getClass().getResource("ResetPreferencesExplanation.html");
pane.setPage(u);
Font font = UIManager.getFont("TextArea.font");
if (font != null) {

代码示例来源:origin: omegat-org/omegat

/** Loads Instant start article */
private void createAdditionalPanes() {
  introPaneTitle = OStrings.getString("DOCKING_INSTANT_START_TITLE");
  try {
    String language = detectInstantStartLanguage();
    introPane = new JTextPane();
    introPane
        .setComponentOrientation(EditorUtils.isRTL(language) ? ComponentOrientation.RIGHT_TO_LEFT
            : ComponentOrientation.LEFT_TO_RIGHT);
    introPane.setEditable(false);
    DragTargetOverlay.apply(introPane, dropInfo);
    URI uri = Help.getHelpFileURI(language, OConsts.HELP_INSTANT_START);
    if (uri != null) {
      introPane.setPage(uri.toURL());
    }
  } catch (IOException e) {
    // editorScroller.setViewportView(editor);
  }
  emptyProjectPaneTitle = OStrings.getString("TF_INTRO_EMPTYPROJECT_FILENAME");
  emptyProjectPane = new JTextPane();
  emptyProjectPane.setEditable(false);
  emptyProjectPane.setText(OStrings.getString("TF_INTRO_EMPTYPROJECT"));
  emptyProjectPane.setFont(mw.getApplicationFont());
  DragTargetOverlay.apply(emptyProjectPane, dropInfo);
}

相关文章

JTextPane类方法