本文整理匯總了Java中javax.swing.JEditorPane.setEditable方法的典型用法代碼示例。如果您正苦於以下問題:Java JEditorPane.setEditable方法的具體用法?Java JEditorPane.setEditable怎麽用?Java JEditorPane.setEditable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JEditorPane
的用法示例。
在下文中一共展示了JEditorPane.setEditable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setEditable
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void setEditable(boolean b) {
JEditorPane editor = editor();
if (editor.isEditable() == b) return;
editor.setEditable(b);
if (b) {
if (lastBgColor != null) editor.setBackground(lastBgColor);
if (lastCaret != null) editor.setCaret(lastCaret);
} else {
lastBgColor = editor.getBackground();
lastCaret = editor.getCaret();
editor.setBackground(disabledBgColor);
editor.setCaret(nullCaret);
}
}
示例2: HelpDialog
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public HelpDialog() {
setTitle(StringResource.getString("DEFAULT_TITLE"));
setSize(640, 480);
htmlPane = new JEditorPane();
JPanel panel = new JPanel(new BorderLayout(5, 5));
panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
panel.add(new JScrollPane(htmlPane));
add(panel);
model = new HelpListModel();
helpList = new JList(values);
JPanel p = new JPanel(new BorderLayout());
p.add(createToolBar(), BorderLayout.NORTH);
p.add(new JScrollPane(helpList));
panel.add(p, BorderLayout.WEST);
setIconImage(XDMIconMap.getIcon("APP_ICON").getImage());
helpList.addListSelectionListener(this);
htmlPane.setEditable(false);
map.put(keys[0], getClass().getResource(
"/help/browser_integration.html"));
map.put(keys[1], getClass().getResource("/help/video_download.html"));
map.put(keys[2], getClass().getResource("/help/refresh_link.html"));
}
示例3: createComponent
import javax.swing.JEditorPane; //導入方法依賴的package包/類
@Override
public JComponent createComponent() {
JScrollPane pane = new JScrollPane();
editorPane = new JEditorPane();
pane.setViewportView(editorPane);
if (scriptPath.endsWith(".js"))
editorPane.setContentType("text/javascript");
byte[] bs = framework.getEngine().getStream(scriptPath);
if (bs == null)
bs = new byte[]{};
try {
editorPane.setText(new String(bs, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
if (!saveScriptAction.isEnabled())
editorPane.setEditable(false);
return pane;
}
示例4: buildDetail
import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
* {@inheritDoc}
*/
@Override
public void buildDetail(String id, JPanel panel) {
if (this.id.equals(id)) return;
panel.setLayout(new MigLayout("wrap 1, center"));
JLabel header = Utility.localizedHeaderLabel(Messages.nameKey(id),
SwingConstants.LEADING, FontLibrary.FontSize.SMALL);
panel.add(header, "align center, wrap 20");
JEditorPane editorPane = new JEditorPane("text/html",
Messages.getDescription(id)) {
@Override
public void paintComponent(Graphics g) {
Graphics2D graphics2d = (Graphics2D) g;
graphics2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
/*
graphics2d.setRenderingHint(RenderingHints.KEY_RENDERING,
RenderingHints.VALUE_RENDER_QUALITY);
graphics2d.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
*/
super.paintComponent(graphics2d);
}
};
editorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES,
Boolean.TRUE);
editorPane.setFont(panel.getFont());
editorPane.setOpaque(false);
editorPane.setEditable(false);
editorPane.addHyperlinkListener(colopediaPanel);
panel.add(editorPane, "width 95%");
}
示例5: FlickrSettingsPanel
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public FlickrSettingsPanel()
{
apiKey = new JTextField();
apiSharedSecret = new JTextField();
// Yuck, this seems to be the minimal amount of code to get a clickable
// and styled link
// (copied from the Cron link in the scheduler)
JEditorPane apiKeyHelp = new JEditorPane();
apiKeyHelp.setEditorKit(new HTMLEditorKit());
apiKeyHelp.setDocument(new HTMLDocument());
apiKeyHelp.setEditable(false);
apiKeyHelp.setText("<html><head><style>" + "<!--a{color:#0000cc;text-decoration: none;}//--></style></head>"
+ "<body>" + getString("settings.label.apikeyhelp"));
apiKeyHelp.addHyperlinkListener(new HyperlinkListener()
{
@Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
if( e.getEventType() == HyperlinkEvent.EventType.ACTIVATED )
{
getClientService().showDocument(e.getURL(), null);
}
}
});
apiKeyHelp.setBackground(new JPanel().getBackground());
add(apiKeyHelp, "span 2");
add(new JLabel(getString("settings.label.apikey")));
add(apiKey);
add(new JLabel(getString("settings.label.apisharedsecret")));
add(apiSharedSecret);
}
示例6: LongMessageDialog
import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
* Creates a dialog to display a long message.
*
* @param owner
* the owner window in which the dialog is displayed
* @param i18nKey
* the i18n key
* @param message
* the actual message
* @param i18nArgs
* additional i18n arguments
* @since 6.5.0
*/
public LongMessageDialog(Window owner, String i18nKey, String message, Object... i18nArgs) {
super(owner, i18nKey, ModalityType.APPLICATION_MODAL, i18nArgs);
JEditorPane textComponent = new ExtendedHTMLJEditorPane("text/html", message);
// so it does not steel ENTER from the default button
textComponent.setFocusable(false);
StyleSheet css = ((HTMLEditorKit) textComponent.getEditorKit()).getStyleSheet();
css.addRule("body { margin : 0; font-family : sans-serif; font-size : 9px; font-style : normal; }");
css.addRule(".error { font-weight:bold; color:red; font-style:plain; }");
css.addRule("code { font-weight:bold; color:#000088; }");
textComponent.setEditable(false);
JScrollPane scrollPane = new ExtendedJScrollPane(textComponent);
scrollPane.setBorder(createBorder());
layoutDefault(scrollPane, NORMAL, makeCloseButton());
}
示例7: redraw
import javax.swing.JEditorPane; //導入方法依賴的package包/類
@Override
public void redraw() {
// Redraws only if data has changed - Bertoli Marco
if (!redrawNeeded)
return;
if (data.hasResults() && data.areResultsOK()
&& data.getResults().getSaturationSectors().size() > 0) {
if (data.getClasses() == 2) {
this.removeAll();
s2dp = new Sectors2DGraph(data);
this.setLayout(new BorderLayout());
this.add(new JabaCanvas(s2dp), BorderLayout.CENTER);
this.add(new JLabel(JabaConstants.DESCRIPITION_GRAPH),
BorderLayout.PAGE_END);
repaint();
} else if (data.getClasses() == 3) {
this.removeAll();
Sectors3DGraph s3dp = new Sectors3DGraph(data);
this.setLayout(new BorderLayout());
this.add(new JabaCanvas(s3dp), BorderLayout.CENTER);
this.add(new JLabel(JabaConstants.DESCRIPITION_GRAPH),
BorderLayout.PAGE_END);
repaint();
}
} else {
this.removeAll();
JEditorPane synView = new JTextPane();
synView.setContentType("text/html");
synView.setEditable(false);
JScrollPane synScroll = new JScrollPane(synView);
synScroll
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
synScroll
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
synView.setText("<html><body><center><font face=\"bold\" size=\"3\">Saturation Sectors will be here displayed once you solve the model.</font></center></body></html>");
this.add(synScroll, BorderLayout.CENTER);
}
redrawNeeded = false;
}
示例8: redraw
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void redraw() {
// We redraw only if data has changed - Sebastiano Spicuglia
if (!redrawNeeded)
return;
this.removeAll();
if (data.hasResults() && data.areResultsOK()
&& data.getResults().getSaturationSectors().size() > 0) {
if (data.getClasses() == 2) {
this.removeAll();
this.setLayout(new GridLayout(2, 1));
JPanel tmp = new JPanel(new GridLayout(1, 2));
tmp.add(new JabaCanvas(new Sectors2DGraph(data)));
tmp.add(new JabaCanvas(new Convex2DGraph(data, mainWin)));
this.add(tmp);
this.add(new JabaCanvas(new PerformanceIndices2DGraph(data)));
repaint();
} else if (data.getClasses() == 3) {
this.removeAll();
this.setLayout(new GridLayout(1, 2));
this.add(new JabaCanvas(new Sectors3DGraph(data)));
this.add(new JabaCanvas(new Convex3DGraph(data, mainWin)));
repaint();
}
} else {
JEditorPane synView = new JTextPane();
synView.setContentType("text/html");
synView.setEditable(false);
JScrollPane synScroll = new JScrollPane(synView);
synScroll
.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
synScroll
.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
synView.setText("<html><body><center><font face=\"bold\" size=\"3\">Graphs will be here displayed once you solve the model.</font></center></body></html>");
this.add(synScroll);
repaint();
}
redrawNeeded = false;
}
示例9: aboutMenuItemActionPerformed
import javax.swing.JEditorPane; //導入方法依賴的package包/類
private void aboutMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutMenuItemActionPerformed
Font font = new JLabel().getFont();
// Load HTML and set style to match the application's style
String html
= Translations.get(
"RaceFrame.help.about",
font.getFamily(),
(font.isBold() ? "bold" : "normal"),
"" + font.getSize() + "pt");
// Create HTML content pane
JEditorPane ep = new JEditorPane("text/html", html);
// Handle link clicks
ep.addHyperlinkListener((HyperlinkEvent e) -> {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
try {
Desktop.getDesktop().browse(e.getURL().toURI());
} catch (IOException | URISyntaxException ex) {
Logger.getLogger(RaceFrame.class.getName()).log(Level.SEVERE, null, ex);
}
}
});
ep.setEditable(false);
ep.setBackground(new JOptionPane().getBackground());
// Show dialog
JOptionPane.showMessageDialog(null, ep);
}
示例10: SwingSpyPanel
import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
* Initialization.
*/
public SwingSpyPanel() {
setPreferredSize(new Dimension(INITIAL_WIDTH, INITIAL_HEIGHT));
setLayout(new BorderLayout());
root = new DefaultMutableTreeNode();
componentTree = new JTree(root);
componentTree.setRootVisible(false);
componentTree.setCellRenderer(new SwingComponentRenderer());
componentTree.addTreeSelectionListener(new CustomSelectionListener());
// add(new JScrollPane(componentTree), BorderLayout.CENTER);
detailsData = new JEditorPane();
detailsData.setBackground(new Color(250, 250, 250));
detailsData.setForeground(new Color(33, 33, 33));
detailsData.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 244), 1));
detailsData.setPreferredSize(new Dimension(150, INITIAL_HEIGHT));
detailsData.setEditable(false);
detailsData.setContentType("text/html");
SwingUtil.enforceJEditorPaneFont(detailsData, font);
detailsScrollPane = new JScrollPane(detailsData);
// add(detailsScrollPane, BorderLayout.EAST);
JSplitPane hPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(componentTree), detailsScrollPane);
hPane.setContinuousLayout(true);
hPane.setOneTouchExpandable(true);
hPane.setDividerLocation(INITIAL_WIDTH - 200);
add(hPane, BorderLayout.CENTER);
componentData = new JEditorPane();
componentData.setBackground(new Color(250, 250, 250));
componentData.setForeground(new Color(33, 33, 33));
componentData.setBorder(BorderFactory.createLineBorder(new Color(100, 100, 244), 1));
componentData.setPreferredSize(new Dimension(INITIAL_WIDTH, 36));
componentData.setEditable(false);
componentData.setContentType("text/html");
SwingUtil.enforceJEditorPaneFont(componentData, font);
add(componentData, BorderLayout.SOUTH);
}
示例11: HelpWindow
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public HelpWindow(String title, URL contents) {
super(title);
setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
setJMenuBar(MenuManager.getInstance().getMenuBarFor(this));
pane = new JEditorPane();
pane.setEditable(false);
pane.addHyperlinkListener(this);
/*
* Allow <src> tag to display images from the module DataArchive
* where no pathname included in the image name.
*/
pane.setContentType("text/html"); //$NON-NLS-1$
XTMLEditorKit myHTMLEditorKit = new HtmlChart.XTMLEditorKit();
pane.setEditorKit(myHTMLEditorKit);
JScrollPane scroll = new ScrollPane(pane);
add(scroll);
update(contents);
pack();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int width = Math.max(d.width / 2, getSize().width);
int height = Math.max(d.height / 2, getSize().height);
width = Math.min(width, d.width * 2 / 3);
height = Math.min(height, d.height * 2 / 3);
setSize(width, height);
setLocation(d.width / 2 - width / 2, 0);
}
示例12: DialogHelpWindow
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public DialogHelpWindow(String title, URL contents, Dialog parent) {
super(parent);
setTitle(title);
setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
//setJMenuBar(MenuManager.getInstance().getMenuBarFor(this));
pane = new JEditorPane();
pane.setEditable(false);
pane.addHyperlinkListener(this);
/*
* Allow <src> tag to display images from the module DataArchive
* where no pathname included in the image name.
*/
pane.setContentType("text/html"); //$NON-NLS-1$
XTMLEditorKit myHTMLEditorKit = new HtmlChart.XTMLEditorKit();
pane.setEditorKit(myHTMLEditorKit);
JScrollPane scroll = new ScrollPane(pane);
add(scroll);
update(contents);
pack();
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int width = Math.max(d.width / 2, getSize().width);
int height = Math.max(d.height / 2, getSize().height);
width = Math.min(width, d.width * 2 / 3);
height = Math.min(height, d.height * 2 / 3);
setSize(width, height);
setLocation(d.width / 2 - width / 2, 0);
}
示例13: makeEditorPane
import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
* Create a JEditorPane that will convert the text into html with working hyperlinks.
* This can be included in a messageDialog with, e.g.
* JOptionPane.showMessageDialog(null, ep)
* @param text
* @return
*/
public static JEditorPane makeEditorPane(String text) {
// for copying style
JLabel label = new JLabel();
Font font = label.getFont();
// create some css from the label's font
StringBuffer style = new StringBuffer("font-family:" + font.getFamily() + ";");
style.append("font-weight:" + (font.isBold() ? "bold" : "normal") + ";");
style.append("font-size:" + font.getSize() + "pt;");
//need to use editor pane and hyperlink listener so that we can include hyperlinks in help text
JEditorPane ep = new JEditorPane("text/html", "<html><body style=\"" + style + "\">" //
+ text //
+ "</body></html>");
ep.addHyperlinkListener(new HyperlinkListener()
{
@Override
public void hyperlinkUpdate(HyperlinkEvent e)
{
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED))
BrowseURL.browseURL(e.getURL().toString());
}
});
ep.setEditable(false);
ep.setBackground(label.getBackground());
return ep;
}
示例14: redraw
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public void redraw() {
// Redraws only if data has changed - Bertoli Marco
if (old_data == data) {
return;
} else {
old_data = data;
}
if (data.hasResults() && data.areResultsOK() && data.getResults().size() > 0) {
if (data.getClasses() == 2) {
this.removeAll();
PanelConvex2D s2dp = new PanelConvex2D(data, mainWin);
this.add(new JScrollPane(s2dp));
repaint();
} else if (data.getClasses() == 3) {
this.removeAll();
// Under costruction
repaint();
}
} else {
this.removeAll();
JEditorPane synView = new JTextPane();
synView.setContentType("text/html");
synView.setEditable(false);
JScrollPane synScroll = new JScrollPane(synView);
synScroll.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
synScroll.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
synView
.setText("<html><body><center><font face=\"bold\" size=\"3\">Saturation Sectors will be here displayed once you solve the model.</font></center></body></html>");
this.add(synScroll);
}
}
示例15: getHardwareReportComponent
import javax.swing.JEditorPane; //導入方法依賴的package包/類
public static JComponent getHardwareReportComponent(CLPlatform platform) {
List<Map<String, Object>> list = listInfos(platform);
final String html = toHTML(list);
JEditorPane ed = new JEditorPane();
ed.setContentType("text/html");
ed.setText(html);
ed.setEditable(false);
JPanel ret = new JPanel(new BorderLayout());
ret.add("Center", new JScrollPane(ed));
final String fileName = "HardwareReport.html";
JButton bWrite = new JButton("Save " + fileName + "...");
bWrite.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
FileDialog fd = new FileDialog((Frame)null, "Save " + fileName, FileDialog.SAVE);
fd.setFile(fileName);
fd.setVisible(true);
if (fd.getFile() == null)
return;
try {
File file = new File(new File(fd.getDirectory()), fd.getFile());
file.getParentFile().mkdirs();
Writer w = new OutputStreamWriter(new FileOutputStream(file), "utf-8");
w.write(html);
w.close();
Platform.show(file);
} catch (Throwable ex) {
SetupUtils.exception(ex);
}
}
});
ret.add("South", bWrite);
return ret;
}