當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。