本文整理汇总了Java中javax.swing.JEditorPane.setOpaque方法的典型用法代码示例。如果您正苦于以下问题:Java JEditorPane.setOpaque方法的具体用法?Java JEditorPane.setOpaque怎么用?Java JEditorPane.setOpaque使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JEditorPane
的用法示例。
在下文中一共展示了JEditorPane.setOpaque方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureEditor
import javax.swing.JEditorPane; //导入方法依赖的package包/类
void configureEditor(JEditorPane editor) {
final Dictionary<URL, Image> imageCache = ((SwingPlatform) document.getPlatform()).imageCache;
editor.setEditorKit(new HTMLEditorKit() {
@Override
public javax.swing.text.Document createDefaultDocument() {
HTMLDocument result = (HTMLDocument) super.createDefaultDocument();
try {
result.setBase(document.getUrl().toURL());
} catch (MalformedURLException e) {
e.printStackTrace();
}
result.putProperty("imageCache", imageCache);
return result;
}
});
editor.setMargin(new Insets(0,0,0,0));
editor.setOpaque(false);
editor.setEditable(false);
}
示例2: AnnotationDrawer
import javax.swing.JEditorPane; //导入方法依赖的package包/类
/**
* Creates a new drawer for the specified model and decorator.
*
* @param model
* the model containing all relevant drawing data
* @param rendererModel
* the process renderer model
*/
public AnnotationDrawer(final AnnotationsModel model, final ProcessRendererModel rendererModel) {
this.model = model;
this.rendererModel = rendererModel;
this.displayCache = new HashMap<>();
this.cachedID = new HashMap<>();
pane = new JEditorPane("text/html", "");
pane.setBorder(null);
pane.setOpaque(false);
}
示例3: 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%");
}
示例4: mxCellEditor
import javax.swing.JEditorPane; //导入方法依赖的package包/类
/**
*
*/
public mxCellEditor(mxGraphComponent graphComponent)
{
this.graphComponent = graphComponent;
// Creates the plain text editor
textArea = new JTextArea();
textArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
textArea.setOpaque(false);
// Creates the HTML editor
editorPane = new JEditorPane();
editorPane.setOpaque(false);
editorPane.setBackground(new Color(0,0,0,0));
editorPane.setContentType("text/html");
// Workaround for inserted linefeeds in HTML markup with
// lines that are longar than 80 chars
editorPane.setEditorKit(new NoLinefeedHtmlEditorKit());
// Creates the scollpane that contains the editor
// FIXME: Cursor not visible when scrolling
scrollPane = new JScrollPane();
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.getViewport().setOpaque(false);
scrollPane.setVisible(false);
scrollPane.setOpaque(false);
// Installs custom actions
editorPane.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
// Remembers the action map key for the enter keystroke
editorEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
textEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
}
示例5: mxCellEditor
import javax.swing.JEditorPane; //导入方法依赖的package包/类
/**
*
*/
public mxCellEditor(mxGraphComponent graphComponent) {
this.graphComponent = graphComponent;
// Creates the plain text editor
textArea = new JTextArea();
textArea.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
textArea.setOpaque(false);
// Creates the HTML editor
editorPane = new JEditorPane();
editorPane.setOpaque(false);
editorPane.setBackground(new Color(0, 0, 0, 0));
editorPane.setContentType("text/html");
// Workaround for inserted linefeeds in HTML markup with
// lines that are longar than 80 chars
editorPane.setEditorKit(new NoLinefeedHtmlEditorKit());
// Creates the scollpane that contains the editor
// FIXME: Cursor not visible when scrolling
scrollPane = new JScrollPane();
scrollPane.setBorder(BorderFactory.createEmptyBorder());
scrollPane.getViewport().setOpaque(false);
scrollPane.setVisible(false);
scrollPane.setOpaque(false);
// Installs custom actions
editorPane.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
textArea.getActionMap().put(CANCEL_EDITING, cancelEditingAction);
editorPane.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
textArea.getActionMap().put(SUBMIT_TEXT, textSubmitAction);
// Remembers the action map key for the enter keystroke
editorEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
textEnterActionMapKey = editorPane.getInputMap().get(enterKeystroke);
}
示例6: createMessagePane
import javax.swing.JEditorPane; //导入方法依赖的package包/类
private JEditorPane createMessagePane( String htmlMessage ) {
JEditorPane messagePane = new JEditorPane("text/html", htmlMessage);
messagePane.setEditable(false);
messagePane.setOpaque(false);
messagePane.addHyperlinkListener( (HyperlinkEvent hyperLink) -> {
if (HyperlinkEvent.EventType.ACTIVATED.equals(hyperLink.getEventType())) {
try {
Desktop.getDesktop().browse( hyperLink.getURL().toURI() );
} catch (URISyntaxException | IOException ex) {
LOGGER.log( Level.WARNING, "Failed to open URL: " + hyperLink.getURL(), ex );
}
}
});
return messagePane;
}
示例7: createHtmlTextToolTip
import javax.swing.JEditorPane; //导入方法依赖的package包/类
private JEditorPane createHtmlTextToolTip() {
class HtmlTextToolTip extends JEditorPane {
public @Override void setSize(int width, int height) {
Dimension prefSize = getPreferredSize();
if (width >= prefSize.width) {
width = prefSize.width;
} else { // smaller available width
super.setSize(width, 10000); // the height is unimportant
prefSize = getPreferredSize(); // re-read new pref width
}
if (height >= prefSize.height) { // enough height
height = prefSize.height;
}
super.setSize(width, height);
}
@Override
public void setKeymap(Keymap map) {
//#181722: keymaps are shared among components with the same UI
//a default action will be set to the Keymap of this component below,
//so it is necessary to use a Keymap that is not shared with other components
super.setKeymap(addKeymap(null, map));
}
}
JEditorPane tt = new HtmlTextToolTip();
// setup tooltip keybindings
filterBindings(tt.getActionMap());
tt.getActionMap().put(HIDE_ACTION.getValue(Action.NAME), HIDE_ACTION);
tt.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), HIDE_ACTION.getValue(Action.NAME));
tt.getKeymap().setDefaultAction(NO_ACTION);
Font font = UIManager.getFont(UI_PREFIX + ".font"); // NOI18N
Color backColor = UIManager.getColor(UI_PREFIX + ".background"); // NOI18N
Color foreColor = UIManager.getColor(UI_PREFIX + ".foreground"); // NOI18N
if (font != null) {
tt.setFont(font);
}
if (foreColor != null) {
tt.setForeground(foreColor);
}
if (backColor != null) {
tt.setBackground(backColor);
}
tt.setOpaque(true);
tt.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(tt.getForeground()),
BorderFactory.createEmptyBorder(0, 3, 0, 3)
));
tt.setContentType("text/html"); //NOI18N
return tt;
}