本文整理汇总了Java中javax.swing.JEditorPane.setForeground方法的典型用法代码示例。如果您正苦于以下问题:Java JEditorPane.setForeground方法的具体用法?Java JEditorPane.setForeground怎么用?Java JEditorPane.setForeground使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JEditorPane
的用法示例。
在下文中一共展示了JEditorPane.setForeground方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: createComponent
import javax.swing.JEditorPane; //导入方法依赖的package包/类
public JComponent createComponent() {
JPanel panel = new JPanel();
JPanel console = new JPanel();
panel.setLayout(new BorderLayout());
final JEditorPane text = new JTextPane();
text.setMargin(new Insets(8, 8, 8, 8));
text.setCaretColor(new Color(0xa4, 0x00, 0x00));
text.setBackground(new Color(0xf2, 0xf2, 0xf2));
text.setForeground(new Color(0xa4, 0x00, 0x00));
Font font = findFont("Monospaced", Font.PLAIN, 14, new String[]{
"Monaco", "Andale Mono"});
text.setFont(font);
JScrollPane pane = new JScrollPane();
pane.setViewportView(text);
pane.setBorder(BorderFactory.createLineBorder(Color.darkGray));
panel.add(pane, BorderLayout.CENTER);
console.validate();
final TextAreaReadline tar = new TextAreaReadline(text,
getString("Wellcom") + " \n\n");
RubyInstanceConfig config = new RubyInstanceConfig() {
{
//setInput(tar.getInputStream());
//setOutput(new PrintStream(tar.getOutputStream()));
//setError(new PrintStream(tar.getOutputStream()));
setObjectSpaceEnabled(false);
}
};
Ruby runtime = Ruby.newInstance(config);
tar.hookIntoRuntimeWithStreams(runtime);
run(runtime);
return panel;
}
示例3: 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;
}