javax.swing.JTextPane#setContentType ( )源码实例Demo

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

源代码1 项目: chipster   文件: BrowsableHtmlPanel.java
public static JTextPane createHtmlPanel() {
	JTextPane htmlPanel = new JTextPane(); 
	htmlPanel.setEditable(false);
	htmlPanel.setContentType("text/html");
	htmlPanel.addHyperlinkListener(new HyperlinkListener() {
		public void hyperlinkUpdate(HyperlinkEvent e) {
			if (e.getEventType() == EventType.ACTIVATED) {
				try {
					BrowserLauncher.openURL(e.getURL().toString());            
				} catch (Exception ioe) {
					ioe.printStackTrace();
				}
			}
		}
	});
	
	return htmlPanel;
}
 
源代码2 项目: atdl4j   文件: SwingStrategyDescriptionPanel.java
public JPanel buildStrategyDescriptionPanel(Window aParentContainer,
                                            Atdl4jOptions atdl4jOptions)
{
  setAtdl4jOptions(atdl4jOptions);

  container = new JPanel(new BorderLayout());
  container.setBorder(new TitledBorder("Strategy Description"));

  strategyDescription = new JTextPane();
  strategyDescription.setContentType("text/html");
  strategyDescription.setFont(new JLabel().getFont());
  strategyDescription.setEditable(false);

  JScrollPane tempScrollPane = new JScrollPane(strategyDescription);
  container.add(tempScrollPane, BorderLayout.CENTER);

  return container;
}
 
源代码3 项目: zap-extensions   文件: ExtensionSimpleExample.java
private AbstractPanel getStatusPanel() {
    if (statusPanel == null) {
        statusPanel = new AbstractPanel();
        statusPanel.setLayout(new CardLayout());
        statusPanel.setName(Constant.messages.getString(PREFIX + ".panel.title"));
        statusPanel.setIcon(ICON);
        JTextPane pane = new JTextPane();
        pane.setEditable(false);
        // Obtain (and set) a font with the size defined in the options
        pane.setFont(FontUtils.getFont("Dialog", Font.PLAIN));
        pane.setContentType("text/html");
        pane.setText(Constant.messages.getString(PREFIX + ".panel.msg"));
        statusPanel.add(pane);
    }
    return statusPanel;
}
 
源代码4 项目: jacamo   文件: EnvironmentInspector.java
public static void addInGui(String wksName, ArtifactId aId) {
    if (frame == null)
        initFrame();

    JTextPane txtOP  = new JTextPane();

    // state
    JPanel nsp = new JPanel(new BorderLayout());
    txtOP.setContentType("text/html");
    txtOP.setEditable(false);
    txtOP.setAutoscrolls(false);
    nsp.add(BorderLayout.CENTER, new JScrollPane(txtOP));

    String id = wksName+"."+aId.getName();
    //artsInfo.put(id, wks.getController().getArtifactInfo(aId.getName()));
    artsWrps.put(id, wksName);
    artsPane.put(id, txtOP);
    allArtsPane.add(id, nsp);

    updater.scheduleAtFixedRate(new Runnable() {
        public void run() {
            updateOP();
        }
    }, 0, 2, TimeUnit.SECONDS);
}
 
源代码5 项目: arcusplatform   文件: ModelController.java
private Window createAttributeDialog(Model model, String attributeName, String label) {
   JDialog window = new JDialog((Window) null, model.getAddress() + ": " + attributeName, ModalityType.MODELESS);
   
   JPanel panel = new JPanel(new BorderLayout());
   panel.add(new JLabel(label), BorderLayout.NORTH);
   // TODO make this a JsonField...
   JTextPane pane = new JTextPane();
   pane.setContentType("text/html");
   pane.setText(JsonPrettyPrinter.prettyPrint(JSON.toJson(model.get(attributeName))));
   
   ListenerRegistration l = model.addListener((event) -> {
      if(event.getPropertyName().equals(attributeName)) {
         // TODO set background green and slowly fade out
         pane.setText(JsonPrettyPrinter.prettyPrint(JSON.toJson(event.getNewValue())));
      }
   });
   
   panel.add(pane, BorderLayout.CENTER);
   
   window.addWindowListener(new WindowAdapter() {
      /* (non-Javadoc)
       * @see java.awt.event.WindowAdapter#windowClosed(java.awt.event.WindowEvent)
       */
      @Override
      public void windowClosed(WindowEvent e) {
         l.remove();
         attributeWindows.remove(model.getAddress() + ":"  + attributeName);
      }
   });
   
   return window;
}
 
源代码6 项目: arcusplatform   文件: InfoPanel.java
@Override
protected JComponent createComponent() {
   Table<T> table = new Table<>(model);
   table.getModel().addTableModelListener((event) -> {
      if(event.getType() == TableModelEvent.INSERT) {
         int viewRow = table.convertRowIndexToView(event.getLastRow());
         table.scrollRectToVisible(table.getCellRect(viewRow, 0, true));
      }
   });

   JTextPane message = new JTextPane();
   message.setEditable(false);
   message.setContentType("text/html");
   
   JSplitPane contents = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
   contents.add(new JScrollPane(table), JSplitPane.TOP);
   contents.add(new JScrollPane(message), JSplitPane.BOTTOM);
   
   table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
      @Override
      public void valueChanged(ListSelectionEvent e) {
         // wait for it to finish
         if(e.getValueIsAdjusting()) {
            return;
         }
         
         int selectedRow = table.getSelectedRow();
         T value = selectedRow > -1 && selectedRow < model.getRowCount() ? model.getValue(selectedRow) : null;
         if(value != null) {
            message.setText(getMessageValue(value));
            message.setCaretPosition(0);
         }
         contents.revalidate();
      }
   });
   return contents;
}
 
源代码7 项目: rest-client   文件: AboutDialog.java
/**
* 
* @Title: init 
* @Description: Component Initialization 
* @param
* @return void 
* @throws
 */
private void init()
{
    this.setTitle(RESTConst.ABOUT_TOOL);
    this.setLayout(new BorderLayout(RESTConst.BORDER_WIDTH, RESTConst.BORDER_WIDTH));

    JPanel pnlDialog = new JPanel();
    pnlDialog.setLayout(new BorderLayout());

    JLabel lblTitle = new JLabel("<html><h3>" + RESTConst.REST_CLIENT_VERSION + "</h3></html>");
    JPanel pnlNorth = new JPanel();
    pnlNorth.setLayout(new FlowLayout(FlowLayout.CENTER));
    pnlNorth.add(lblTitle);
    pnlDialog.add(pnlNorth, BorderLayout.NORTH);

    JPanel pnlCenter = new JPanel();
    pnlCenter.setLayout(new GridLayout(1, 1));
    JTextPane tp = new JTextPane();
    tp.setEditable(false);
    tp.setContentType("text/html");
    tp.setText(UIUtil.contents(RESTConst.WISDOM_TOOL_ORG));
    pnlCenter.add(new JScrollPane(tp));
    pnlDialog.add(pnlCenter, BorderLayout.CENTER);

    JPanel pnlSouth = new JPanel();
    pnlSouth.setLayout(new FlowLayout(FlowLayout.CENTER));
    JButton btnOK = new JButton(RESTConst.OK);
    btnOK.addActionListener(this);
    btnOK.requestFocus();
    getRootPane().setDefaultButton(btnOK);
    pnlSouth.add(btnOK);
    pnlDialog.add(pnlSouth, BorderLayout.SOUTH);

    this.setContentPane(pnlDialog);
    this.setIconImage(UIUtil.getImage(RESTConst.LOGO));
    this.pack();
}
 
源代码8 项目: knopflerfish.org   文件: Desktop.java
void showInfo()
{
  final JTextPane html = new JTextPane();

  html.setContentType("text/html");

  html.setEditable(false);

  html.setText(Util.getSystemInfo());

  final JScrollPane scroll = new JScrollPane(html);
  scroll.setPreferredSize(new Dimension(420, 300));
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run()
    {
      final JViewport vp = scroll.getViewport();
      if (vp != null) {
        vp.setViewPosition(new Point(0, 0));
        scroll.setViewport(vp);
      }
    }
  });

  JOptionPane.showMessageDialog(frame, scroll, "Framework info",
                                JOptionPane.INFORMATION_MESSAGE, null);
}
 
源代码9 项目: zap-extensions   文件: ClientsPanel.java
private JTextPane getInitialMessage() {
    JTextPane initialMessage = new JTextPane();
    initialMessage.setEditable(false);
    initialMessage.setFont(FontUtils.getFont("Dialog"));
    initialMessage.setContentType("text/html");
    initialMessage.setText(Constant.messages.getString("plugnhack.label.initialMessage"));
    return initialMessage;
}
 
源代码10 项目: SubTitleSearcher   文件: AboutDialog.java
private void initComponents() {

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
		setIconImage(MainWin.icon);
		setSize(500, 300);
		setResizable(false);

		setLocationRelativeTo(this.getParent());
		setTitle("About " + AppConfig.appTitle);

		JPanel mainPanel = new JPanel(new BorderLayout());
		add(mainPanel);

		JPanel leftPanel = new JPanel();
		mainPanel.add(leftPanel, BorderLayout.WEST);

		ImageIcon iconImg = new ImageIcon(MainWin.icon);
		iconImg.setImage(iconImg.getImage().getScaledInstance((int) (iconImg.getIconWidth() * 0.5), (int) (iconImg.getIconHeight() * 0.5), Image.SCALE_SMOOTH));
		JLabel iconLabel = new JLabel(iconImg);
		iconLabel.setBorder(BorderFactory.createEmptyBorder(6, 10, 6, 10));
		leftPanel.add(iconLabel);

		HyperlinkListener hlLsnr = new HyperlinkListener() {
			@Override
			public void hyperlinkUpdate(HyperlinkEvent e) {
				if (e.getEventType() != HyperlinkEvent.EventType.ACTIVATED)
					return;
				// 超链接标记中必须带有协议指定,e.getURL()才能得到,否则只能用e.getDescription()得到href的内容。
				// JOptionPane.showMessageDialog(InfoDialog.this, "URL:"+e.getURL()+"\nDesc:"+ e.getDescription());
				URL linkUrl = e.getURL();
				if (linkUrl != null) {
					try {
						Desktop.getDesktop().browse(linkUrl.toURI());
					} catch (Exception e1) {
						e1.printStackTrace();
						JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "无法打开超链接:" + linkUrl + "\n详情:" + e1, JOptionPane.ERROR_MESSAGE);
					}
				} else {
					JOptionPane.showMessageDialog(AboutDialog.this, "超链接错误", "超链接信息不完整:" + e.getDescription() + "\n请确保链接带有协议信息,如http://,mailto:", JOptionPane.ERROR_MESSAGE);
				}
			}
		};

		JTextPane infoArea = new JTextPane();
		//设置css单位(px/pt)和chrome一致
		infoArea.putClientProperty(JTextPane.W3C_LENGTH_UNITS, true);
		infoArea.addHyperlinkListener(hlLsnr);
		infoArea.setContentType("text/html");
		infoArea.setText(getInfo());
		infoArea.setEditable(false);
		infoArea.setBorder(BorderFactory.createEmptyBorder(2, 10, 6, 10));
		infoArea.setFocusable(false);

		JScrollPane infoAreaScrollPane = new JScrollPane(infoArea);
		infoAreaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
		infoAreaScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
		infoAreaScrollPane.getViewport().setBackground(Color.WHITE);
		mainPanel.add(infoAreaScrollPane, BorderLayout.CENTER);

	}
 
源代码11 项目: btdex   文件: CancelOrderDialog.java
public CancelOrderDialog(JFrame owner, Market market, AssetOrder order, ContractState state) {
	super(owner, ModalityType.APPLICATION_MODAL);
	setDefaultCloseOperation(DISPOSE_ON_CLOSE);
	
	setTitle(tr("canc_cancel_order"));

	isToken = market.getTokenID()!=null;

	this.market = market;
	this.order = order;
	this.state = state;

	conditions = new JTextPane();
	conditions.setContentType("text/html");
	conditions.setPreferredSize(new Dimension(80, 160));
	conditions.setEditable(false);

	acceptBox = new JCheckBox(tr("dlg_accept_terms"));

	// Create a button
	JPanel buttonPane = new JPanel(new FlowLayout(FlowLayout.RIGHT));

	pin = new JPasswordField(12);
	pin.addActionListener(this);

	calcelButton = new JButton(tr("dlg_cancel"));
	okButton = new JButton(tr("dlg_ok"));
	getRootPane().setDefaultButton(okButton);

	calcelButton.addActionListener(this);
	okButton.addActionListener(this);

	if(Globals.getInstance().usingLedger()) {
		ledgerStatus = new JTextField(26);
		ledgerStatus.setEditable(false);
		buttonPane.add(new Desc(tr("ledger_status"), ledgerStatus));
		LedgerService.getInstance().setCallBack(this);
	}
	else
		buttonPane.add(new Desc(tr("dlg_pin"), pin));
	buttonPane.add(new Desc(" ", calcelButton));
	buttonPane.add(new Desc(" ", okButton));

	// set action listener on the button

	JPanel content = (JPanel)getContentPane();
	content.setBorder(new EmptyBorder(4, 4, 4, 4));

	JPanel conditionsPanel = new JPanel(new BorderLayout());
	conditionsPanel.setBorder(BorderFactory.createTitledBorder(tr("dlg_terms_and_conditions")));
	conditionsPanel.add(new JScrollPane(conditions), BorderLayout.CENTER);

	conditionsPanel.add(acceptBox, BorderLayout.PAGE_END);

	JPanel centerPanel = new JPanel(new BorderLayout());
	centerPanel.add(conditionsPanel, BorderLayout.PAGE_END);

	content.add(centerPanel, BorderLayout.CENTER);
	content.add(buttonPane, BorderLayout.PAGE_END);

	suggestedFee = Globals.getInstance().getNS().suggestFee().blockingGet();

	boolean isBuy = false;
	if(order!=null && order.getType() == AssetOrder.OrderType.BID)
		isBuy = true;
	if(state!=null && state.getType() == ContractType.BUY)
		isBuy = true;
	
	StringBuilder terms = new StringBuilder();
	terms.append(PlaceOrderDialog.HTML_STYLE);
	terms.append("<h3>").append(tr("canc_terms_brief", isBuy ? tr("token_buy") : tr("token_sell"), market,
			isToken ? order.getId() : state.getAddress().getRawAddress())).append("</h3>");
	if(isToken) {
		terms.append("<p>").append(tr("canc_terms_token",
				NumberFormatting.BURST.format(suggestedFee.getPriorityFee().longValue()))).append("</p>");
	}
	else {
		terms.append("<p>").append(tr("canc_terms_contract",
				state.getBalance().toUnformattedString(),
				NumberFormatting.BURST.format(state.getActivationFee() + suggestedFee.getPriorityFee().longValue()))
				).append("</p>");
	}
	
	conditions.setText(terms.toString());
	conditions.setCaretPosition(0);
	
	pack();
}
 
源代码12 项目: btdex   文件: ChatPanel.java
public ChatPanel() {
  	super(new BorderLayout());

JPanel addressPanel = new JPanel(new BorderLayout());
addressPanel.setBorder(BorderFactory.createTitledBorder("Your contacts"));
addressList = new JList<>();
addressList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
addressList.setPreferredSize(new Dimension(300, 300));
addressPanel.add(addressList, BorderLayout.CENTER);		
add(addressPanel, BorderLayout.LINE_START);
addressList.addListSelectionListener(this);

pinField = new JPasswordField(12);
pinField.addActionListener(this);

  	JPanel panelSendMessage = new JPanel(new BorderLayout());
      inputField = new JTextField();
      inputField.setToolTipText("Enter your message");
      panelSendMessage.add(new Desc("Enter your message", inputField), BorderLayout.CENTER);
      inputField.addActionListener(this);
      inputField.setEnabled(false);

      btnSend = new JButton("");
Icon sendIcon = IconFontSwing.buildIcon(FontAwesome.PAPER_PLANE_O, 24, btnSend.getForeground());
      btnSend.setIcon(sendIcon);
      btnSend.setToolTipText("Send your message");
      btnSend.addActionListener(this);
      btnSend.setEnabled(false);
      panelSendMessage.add(new Desc(" ", btnSend), BorderLayout.EAST);

      displayField = new JTextPane();
      displayField.setContentType("text/html");
      displayField.setEditable(false);
      displayField.setText(HTML_FORMAT);

      scrollPane = new JScrollPane(displayField);
      scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
      
      JPanel panelCenter = new JPanel(new BorderLayout());
      panelCenter.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
      add(panelCenter, BorderLayout.CENTER);
      
      panelCenter.add(scrollPane, BorderLayout.CENTER);
      panelCenter.add(panelSendMessage, BorderLayout.SOUTH);
      
      setSize(280, 400);
  }
 
源代码13 项目: EchoSim   文件: HistoryTransactionPanel.java
private void initInstantiate()
{
    mClient = new JTextPane();
    mClient.setEditable(false);
    mClient.setContentType("text/html");
}
 
源代码14 项目: ChickenChunks   文件: PlayerChunkViewer.java
public TicketInfoDialog(LinkedList<TicketInfo> tickets)
{
    super(PlayerChunkViewer.this);
    setModalityType(ModalityType.DOCUMENT_MODAL);
    this.tickets = tickets;

    infoPane = new JTextPane();
    infoPane.setEditable(false);
    infoPane.setOpaque(false);
    infoPane.setContentType("text/html");
    
    infoScrollPane = new JScrollPane(infoPane);
    infoScrollPane.setOpaque(false);
    add(infoScrollPane);
    
    chunkPane = new JTextPane();
    chunkPane.setEditable(false);
    chunkPane.setOpaque(false);
    chunkPane.setContentType("text/html");
    
    chunkScrollPane = new JScrollPane(chunkPane, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
    add(chunkScrollPane);

    ticketComboBox = new JComboBox<String>();
    for(TicketInfo ticket : tickets)
    {
        String ident = ticket.modId;
        if(ticket.player != null)
            ident += ", " + ticket.player;
        ident += " #" + ticket.ID;
        ticketComboBox.addItem(ident);
    }
    add(ticketComboBox);

    addWindowListener(new WindowAdapter()
    {
        @Override
        public void windowClosing(WindowEvent e)
        {
            dialog = null;
        }
    });

    setLayout(this);
    setSize(getPreferredSize());
    setLocationRelativeTo(null);
    pack();

    dialog = this;

    setVisible(true);
}
 
源代码15 项目: megamek   文件: ReportDisplay.java
public static void setupStylesheet(JTextPane pane) {
    pane.setContentType("text/html");
    Font font = UIManager.getFont("Label.font");
    ((HTMLEditorKit) pane.getEditorKit()).getStyleSheet().addRule(
           "pre { font-family: " + font.getFamily() + "; font-size: 12pt; font-style:normal;}");
}
 
源代码16 项目: WorldGrower   文件: JTextPaneFactory.java
public static JTextPane createHmtlJTextPane(ImageInfoReader imageInfoReader) {
	JTextPane textPane = createJTextPane(imageInfoReader);
	textPane.setContentType("text/html");
	textPane.putClientProperty(JTextPane.HONOR_DISPLAY_PROPERTIES, true);
	return textPane;
}
 
源代码17 项目: dualsub   文件: AboutDialog.java
private void initComponents() {
	setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
	setTitle(I18N.getText("Window.name.text"));

	// Features
	this.setResizable(false);
	getContentPane().setLayout(null);
	this.getContentPane().setBackground(parent.getBackground());

	// Tabs
	JTabbedPane tabs = new JTabbedPane();
	tabs.setBounds(10, 11, 474, 351);
	this.getContentPane().add(tabs);

	// About tab
	JPanel aboutTab = new JPanel();
	aboutTab.setBackground(parent.getBackground());
	tabs.addTab(I18N.getHtmlText("About.about.text"), aboutTab);
	aboutTab.setLayout(null);

	JLabel lblDualSub = new JLabel();
	lblDualSub.setIcon(new ImageIcon(ClassLoader
			.getSystemResource("img/dualsub-about.png")));
	lblDualSub.setBounds(66, 0, 330, 140);
	aboutTab.add(lblDualSub);

	scrollPane = new JScrollPane();
	scrollPane.setBounds(0, 139, 470, 187);
	aboutTab.add(scrollPane);

	JTextPane txtrDualSub = new JTextPane();
	scrollPane.setViewportView(txtrDualSub);
	txtrDualSub.setContentType("text/html");
	addTextContentToArea(txtrDualSub, "README.md", true);
	txtrDualSub.setEditable(false);

	tabs.setVisible(true);

	// Changelog tab
	JPanel changelogTab = new JPanel();
	changelogTab.setBackground(parent.getBackground());
	changelogTab.setLayout(null);
	tabs.addTab(I18N.getHtmlText("About.changelog.text"), null,
			changelogTab, null);

	scrollChangelog = new JScrollPane();
	scrollChangelog.setBounds(0, 0, 470, 327);
	changelogTab.add(scrollChangelog);

	JTextPane txtChangelog = new JTextPane();
	scrollChangelog.setViewportView(txtChangelog);
	addTextContentToArea(txtChangelog, "changelog", false);
	txtChangelog.setEditable(false);

	// License tab
	JPanel licenseTab = new JPanel();
	licenseTab.setBackground(parent.getBackground());
	licenseTab.setLayout(null);
	tabs.addTab(I18N.getHtmlText("About.license.text"), null, licenseTab,
			null);

	scrollLicense = new JScrollPane();
	scrollLicense.setBounds(0, 0, 470, 327);
	licenseTab.add(scrollLicense);

	JTextPane txtLicense = new JTextPane();
	scrollLicense.setViewportView(txtLicense);
	addTextContentToArea(txtLicense, "LICENSE", false);
	txtLicense.setEditable(false);

	JButton btnOk = new JButton(I18N.getHtmlText("About.ok.text"));
	btnOk.setBounds(203, 373, 89, 23);
	btnOk.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			setVisible(false);
		}
	});
	this.getContentPane().add(btnOk);
}
 
源代码18 项目: procamtracker   文件: MainFrame.java
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
    String version = MainFrame.class.getPackage().getImplementationVersion();
    if (version == null) {
        version = "unknown";
    }
    JTextPane textPane = new JTextPane();
    textPane.setEditable(false);
    textPane.setContentType("text/html");
    textPane.setText(
            "<font face=sans-serif><strong><font size=+2>ProCamTracker</font></strong> version " + version + "<br>" +
            "Copyright (C) 2009-2014 Samuel Audet &lt;<a href=\"mailto:[email protected]%28Samuel%20Audet%29\">[email protected]</a>&gt;<br>" +
            "Web site: <a href=\"http://www.ok.ctrl.titech.ac.jp/~saudet/procamtracker/\">http://www.ok.ctrl.titech.ac.jp/~saudet/procamtracker/</a><br>" +
            "<br>" +
            "Licensed under the GNU General Public License version 2 (GPLv2).<br>" +
            "Please refer to LICENSE.txt or <a href=\"http://www.gnu.org/licenses/\">http://www.gnu.org/licenses/</a> for details."
            );
    textPane.setCaretPosition(0);
    Dimension dim = textPane.getPreferredSize();
    dim.height = dim.width*3/4;
    textPane.setPreferredSize(dim);

    textPane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent e) {
            if(e.getEventType() == EventType.ACTIVATED) {
                try {
                    Desktop.getDesktop().browse(e.getURL().toURI());
                } catch(Exception ex) {
                    Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE,
                            "Could not launch browser to \"" + e.getURL()+ "\"", ex);
                }
            }
        }
    });

    // pass the scrollpane to the joptionpane.
    JDialog dialog = new JOptionPane(textPane, JOptionPane.PLAIN_MESSAGE).
            createDialog(this, "About");

    if ("com.sun.java.swing.plaf.gtk.GTKLookAndFeel".equals(UIManager.getLookAndFeel().getClass().getName())) {
        // under GTK, frameBackground is white, but rootPane color is OK...
        // but under Windows, the rootPane's color is funny...
        Color c = dialog.getRootPane().getBackground();
        textPane.setBackground(new Color(c.getRGB()));
    } else {
        Color frameBackground = this.getBackground();
        textPane.setBackground(frameBackground);
    }
    dialog.setVisible(true);
}
 
源代码19 项目: EchoSim   文件: HistoryTransactionPanel.java
private void initInstantiate()
{
    mClient = new JTextPane();
    mClient.setEditable(false);
    mClient.setContentType("text/html");
}
 
源代码20 项目: knopflerfish.org   文件: JCMInfo.java
JHTML(String s)
{
  super(new BorderLayout());

  html = new JTextPane();
  html.setEditable(false); // need to set this explicitly to fix swing 1.3 bug
  html.setCaretPosition(0);
  html.setContentType("text/html");

  // Enable posting of form submit events to the hyper link listener
  final HTMLEditorKit htmlEditor
  = (HTMLEditorKit)html.getEditorKitForContentType("text/html");
  try {
    // Call htmlEditor.setAutoFormSubmission(false); if available (Java 5+)
    final Method setAutoFormSubmissionMethod = htmlEditor.getClass()
      .getMethod("setAutoFormSubmission", new Class[]{ Boolean.TYPE});
    setAutoFormSubmissionMethod.invoke(htmlEditor,
                                       new Object[]{Boolean.FALSE});
  } catch (final Throwable t) {
    Activator.log.warn("Failed to enable auto form submission for JHTMLBundle.", t);
  }

  html.setText(s);
  html.setCaretPosition(0);

  html.addHyperlinkListener(new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent ev)
    {
      if (ev.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
        final URL url = ev.getURL();
        try {
          if (Util.isBundleLink(url)) {
            final long bid = Util.bidFromURL(url);
            Activator.disp.getBundleSelectionModel().clearSelection();
            Activator.disp.getBundleSelectionModel().setSelected(bid, true);
          } else if (Util.isImportLink(url)) {
            JCMInfo.importCfg(JHTML.this);
          } else {
            Util.openExternalURL(url);
          }
        } catch (final Exception e) {
          Activator.log.error("Failed to show " + url, e);
        }
      }
    }
  });

  scroll =
    new JScrollPane(html, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);

  html.setPreferredSize(new Dimension(300, 300));

  add(scroll, BorderLayout.CENTER);
}