当前位置: 首页>>代码示例>>Java>>正文


Java JEditorPane.setBorder方法代码示例

本文整理汇总了Java中javax.swing.JEditorPane.setBorder方法的典型用法代码示例。如果您正苦于以下问题:Java JEditorPane.setBorder方法的具体用法?Java JEditorPane.setBorder怎么用?Java JEditorPane.setBorder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JEditorPane的用法示例。


在下文中一共展示了JEditorPane.setBorder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContentHeight

import javax.swing.JEditorPane; //导入方法依赖的package包/类
/**
 * Calculates the preferred height of an editor pane with the given fixed width for the
 * specified string.
 *
 * @param comment
 *            the annotation comment string
 * @param width
 *            the width of the content
 * @return the preferred height given the comment
 */
public static int getContentHeight(final String comment, final int width) {
	if (comment == null) {
		throw new IllegalArgumentException("comment must not be null!");
	}
	JEditorPane dummyEditorPane = new JEditorPane("text/html", "");
	dummyEditorPane.setText(comment);
	dummyEditorPane.setBorder(null);
	dummyEditorPane.setSize(width, Short.MAX_VALUE);

	// height is not exact. Multiply by magic number to get a more fitting value...
	if (SystemInfoUtilities.getOperatingSystem() == OperatingSystem.OSX
			|| SystemInfoUtilities.getOperatingSystem() == OperatingSystem.UNIX
			|| SystemInfoUtilities.getOperatingSystem() == OperatingSystem.SOLARIS) {
		return (int) (dummyEditorPane.getPreferredSize().getHeight() * 1.05f);
	} else {
		return (int) dummyEditorPane.getPreferredSize().getHeight();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:29,代码来源:AnnotationDrawUtils.java

示例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);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:20,代码来源:AnnotationDrawer.java

示例3: 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);

	}
 
开发者ID:igr,项目名称:swingspy,代码行数:43,代码来源:SwingSpyPanel.java

示例4: 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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:56,代码来源:ToolTipSupport.java


注:本文中的javax.swing.JEditorPane.setBorder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。