javax.swing.JEditorPane#setPage ( )源码实例Demo

下面列出了javax.swing.JEditorPane#setPage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: ramus   文件: HTMLPrintable.java
public void loadPage(String url, final ActionListener listener)
        throws IOException {
    this.url = url;
    pane = new JEditorPane();
    pane.setContentType("text/html");
    pane.addPropertyChangeListener("page", new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            generate(0);
            if (listener != null)
                listener.actionPerformed(new ActionEvent(
                        HTMLPrintable.this, 0, "PageLoaded"));
        }
    });
    pane.setPage(url);
}
 
源代码2 项目: jFuzzyLogic   文件: FuzzyDemo.java
private JComponent createHtmlPanel(String url) {

		JScrollPane scroll = new JScrollPane();

		JEditorPane editorPane = new JEditorPane();
		editorPane.setEditable(false);
		java.net.URL helpURL = this.getClass().getResource(url);
		if (helpURL != null) {
			try {
				editorPane.setPage(helpURL);
			} catch (IOException e) {
				System.err.println("Attempted to read a bad URL: " + helpURL);
			}
		} else {
			System.err.println("Couldn't find file:" + helpURL);
		}

		scroll.setViewportView(editorPane);
		return scroll;

	}
 
源代码3 项目: uima-uimaj   文件: ManualHandler.java
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
  if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
    JEditorPane pane = (JEditorPane) e.getSource();
    if (e instanceof HTMLFrameHyperlinkEvent) {
      HTMLFrameHyperlinkEvent evt = (HTMLFrameHyperlinkEvent) e;
      HTMLDocument doc = (HTMLDocument) pane.getDocument();
      doc.processHTMLFrameHyperlinkEvent(evt);
    } else {
      try {
        pane.setPage(e.getURL());
      } catch (Throwable t) {
        t.printStackTrace();
      }
    }
  }
}
 
源代码4 项目: plugins   文件: UpdatePanel.java
UpdatePanel(SuppliesTrackerPanel suppliesTrackerPanel)
{
	this.panel = suppliesTrackerPanel;
	setBorder(new EmptyBorder(6, 6, 6, 6));
	setBackground(ColorScheme.DARK_GRAY_COLOR);
	setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
	JEditorPane editorPane = new JEditorPane();
	editorPane.setEditable(false);
	java.net.URL helpURL = UpdatePanel.class.getResource(
		"Info.html");

	if (helpURL != null)
	{
		try
		{
			editorPane.setPage(helpURL);
		}
		catch (IOException e)
		{
			throw new IllegalStateException("File not found");
		}
	}

	JButton close = new JButton("Close info");
	close.addActionListener(e ->
	{
		this.setVisible(false);
		panel.updateOverall();
		panel.getInfo().setVisible(true);
		panel.getLogsContainer().setVisible(true);
	});
	this.add(close);
	this.add(editorPane);

}
 
源代码5 项目: orbit-image-analysis   文件: Main.java
public Main() {
  setLayout(new BorderLayout());

  JTabbedPane tabs = new JTabbedPane();
  add("Center", tabs);

  addDemo(tabs, "JButtonBar", "ButtonBarMain");
  addDemo(tabs, "JDirectoryChooser", "ChooseDirectory");
  addDemo(tabs, "JFontChooser", "ChooseFont");
  addDemo(tabs, "JOutlookBar", "OutlookBarMain");
  addDemo(tabs, "JTaskPane", "TaskPaneMain");
  addDemo(tabs, "PropertySheet", "PropertySheetMain");
  addDemo(tabs, "JTipOfTheDay", "TOTDTest");
  
  try {
    JEditorPane pane = new JEditorPane("text/html", "<html>") {
      protected void paintComponent(java.awt.Graphics g) {
        Graphics2D g2d = (Graphics2D)g;
        g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
          RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        super.paintComponent(g);
      }
    };
    pane.setPage(Main.class.getResource("demo.html"));
    pane.setBackground(Color.white);
    pane.setEditable(false);
    pane.setOpaque(true);
    add("South", pane);
  } catch (Exception e) {
  }
}
 
源代码6 项目: littleluck   文件: DemoPanel.java
private static JComponent createDescriptionArea(URL descriptionURL) {
    JEditorPane descriptionPane = new HTMLPanel();
    descriptionPane.setEditable(false);
    descriptionPane.setMargin(margin);
    descriptionPane.setOpaque(true);
    try {
        descriptionPane.setPage(descriptionURL);
    } catch (IOException e) {
        System.err.println("couldn't load description from URL:" + descriptionURL);
    }
    return descriptionPane;
}
 
源代码7 项目: beautyeye   文件: DemoPanel.java
private static JComponent createDescriptionArea(URL descriptionURL) {
    JEditorPane descriptionPane = new HTMLPanel();
    descriptionPane.setEditable(false);
    descriptionPane.setMargin(margin);
    descriptionPane.setOpaque(true);
    try {
        descriptionPane.setPage(descriptionURL);
    } catch (IOException e) {
        System.err.println("couldn't load description from URL:" + descriptionURL);
    }
    return descriptionPane;
}
 
源代码8 项目: megamek   文件: CommonHelpDialog.java
/**
 * Create a help dialog for the given <code>parentFrame</code> by reading
 * from the indicated <code>File</code>.
 */
public CommonHelpDialog(JFrame parentFrame, File helpfile) {
    super(parentFrame);

    setLayout(new BorderLayout());
    JEditorPane helpPane = new JEditorPane();
    helpPane.setEditable(false);

    // Get the help content file if possible
    try {
        helpPane.setPage(helpfile.toURI().toURL());
        setTitle(Messages.getString("CommonHelpDialog.helpFile") + helpfile.getName()); //$NON-NLS-1$
    } catch (Exception exc) {
        helpPane.setText(Messages.getString("CommonHelpDialog.errorReading") //$NON-NLS-1$
                + exc.getMessage());
        setTitle(Messages.getString("CommonHelpDialog.noHelp.title")); //$NON-NLS-1$
        exc.printStackTrace();
    }

    // Close Button
    JButton butClose = new ButtonEsc(new CloseAction(this));

    // Add all to the dialog
    getContentPane().add(new JScrollPane(helpPane), BorderLayout.CENTER);
    getContentPane().add(butClose, BorderLayout.SOUTH);
    
    // Make the window half the screensize and center on screen
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    Dimension windowSize = new Dimension(gd.getDisplayMode().getWidth() / 2,
            gd.getDisplayMode().getHeight() / 2);
    pack();
    setSize(windowSize);
    setLocationRelativeTo(null);
}
 
源代码9 项目: SwingBox   文件: DefaultHyperlinkHandler.java
/**
 * Loads given page as HyperlinkEvent.
 * 
 * @param pane
 *            the pane
 * @param evt
 *            the event
 */
protected void loadPage(JEditorPane pane, HyperlinkEvent evt)
{
    // if some security, or other interaction is needed, override this
    // method
    try
    {
        pane.setPage(evt.getURL());
    } catch (IOException e)
    {
        System.err.println(e.getLocalizedMessage());
    }
}
 
源代码10 项目: pentaho-reporting   文件: CompoundDemoFrame.java
protected JComponent createDescriptionTextPane(final URL url)
{
  final JEditorPane editorPane = new JEditorPane();
  editorPane.setEditable(false);
  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);
}
 
源代码11 项目: pentaho-reporting   文件: SimpleDemoFrame.java
protected JComponent createDefaultContentPane()
{
  final JPanel content = new JPanel(new BorderLayout());
  content.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));

  final InternalDemoHandler demoHandler = getDemoHandler();
  final JEditorPane editorPane = new JEditorPane();
  final URL url = demoHandler.getDemoDescriptionSource();
  editorPane.setEditable(false);
  editorPane.setPreferredSize(new Dimension(400, 200));
  if (url != null)
  {
    try
    {
      editorPane.setPage(url);
    }
    catch (IOException e)
    {
      editorPane.setText("Unable to load the demo description. Error: " + e.getMessage());
    }
  }
  else
  {
    editorPane.setText("Unable to load the demo description. No such resource.");
  }

  final JScrollPane scroll = new JScrollPane(editorPane,
      JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);

  final JButton previewButton = new JButton(getPreviewAction());

  final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
  splitPane.setTopComponent(scroll);
  splitPane.setBottomComponent(demoHandler.getPresentationComponent());
  content.add(splitPane, BorderLayout.CENTER);
  content.add(previewButton, BorderLayout.SOUTH);
  return content;
}
 
源代码12 项目: stendhal   文件: UpdateProgressBar.java
private void initializeComponents() {
	JPanel contentPane = (JPanel) this.getContentPane();

	contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
	contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	if (fromVersion == null) {
		contentPane.add(new JLabel("Please wait while " + ClientGameConfiguration.get("GAME_NAME") + " is downloaded..."));
	} else {
		contentPane.add(new JLabel("Downloading updates..."));
	}
	contentPane.add(Box.createVerticalStrut(5));

	progressBar = new JProgressBar(0, max);
	progressBar.setStringPainted(false);
	progressBar.setValue(0);
	contentPane.add(progressBar);
	contentPane.add(Box.createVerticalStrut(5));

	if (urlBase != null) {
		// Set up page display.
		browser = new JEditorPane();
		browser.setContentType("text/html");
		browser.setEditable(false);
		Dimension dim = new Dimension(600, 440);
		browser.setPreferredSize(dim);
		browser.addPropertyChangeListener("page", new UpdateProgressBarMetaRefreshSupport());
		browser.addHyperlinkListener(new UpdateProgressBarHyperLinkListener());

		Dimension windowSize = new Dimension(640, 480);
		setPreferredSize(windowSize);
		// TODO: load page async?
		try {
			browser.setPage(urlBase + fromVersion + "/" + toVersion + ".html");
		} catch (IOException e) {
			System.out.println(e);
		}

		// Gige the page scroll bars if it needs them
		final JScrollPane scrollPane = new JScrollPane(browser);
		contentPane.add(scrollPane);
	}
}
 
源代码13 项目: grammarviz2_src   文件: AboutGrammarVizDialog.java
public AboutGrammarVizDialog(JFrame parentFrame) {

    super(parentFrame, true);
    if (parentFrame != null) {
      Dimension parentSize = parentFrame.getSize();
      Point p = parentFrame.getLocation();
      setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4);
    }

    JEditorPane aboutTextPane = new JEditorPane();

    aboutTextPane.setEditable(false);
    java.net.URL helpURL = AboutGrammarVizDialog.class.getResource("/AboutText.html");
    if (helpURL != null) {
      try {
        aboutTextPane.setPage(helpURL);
      }
      catch (IOException e) {
        System.err.println("Attempted to read a bad URL: " + helpURL);
      }
    }
    else {
      System.err.println("Couldn't find file: AboutText.html");
    }

    // Put the editor pane in a scroll pane.
    JScrollPane editorScrollPane = new JScrollPane(aboutTextPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);

    MigLayout mainFrameLayout = new MigLayout("fill", "[grow,center]", "[grow]5[]");

    getContentPane().setLayout(mainFrameLayout);

    getContentPane().add(editorScrollPane, "h 200:300:,w 400:500:,growx,growy,wrap");

    JPanel buttonPane = new JPanel();
    JButton okButton = new JButton(OK_BUTTON_TEXT);

    buttonPane.add(okButton);
    okButton.addActionListener(this);

    getContentPane().add(buttonPane, "wrap");

    pack();
    setVisible(true);

  }