本文整理了Java中javax.swing.JEditorPane.getInsets()
方法的一些代码示例,展示了JEditorPane.getInsets()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getInsets()
方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getInsets
暂无
代码示例来源:origin: nroduit/Weasis
protected static Shape getAllocation(View v, JEditorPane edit) {
Insets ins = edit.getInsets();
View vParent = v.getParent();
int x = ins.left;
int y = ins.top;
while (vParent != null) {
int i = vParent.getViewIndex(v.getStartOffset(), Position.Bias.Forward);
Shape alloc = vParent.getChildAllocation(i, new Rectangle(0, 0, Short.MAX_VALUE, Short.MAX_VALUE));
x += alloc.getBounds().x;
y += alloc.getBounds().y;
vParent = vParent.getParent();
}
return new Rectangle(x, y, (int) v.getPreferredSpan(View.X_AXIS), (int) v.getPreferredSpan(View.Y_AXIS));
}
}
代码示例来源:origin: stackoverflow.com
MouseListener sentenceCollapse = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
JEditorPane src = (JEditorPane)e.getSource();
View v = src.getUI().getRootView(src);
Insets ins = src.getInsets();
int x = ins.left;
int y = ins.top;
Point p = e.getPoint();
p.translate(-x, -y);
Rectangle alloc = new Rectangle(0,0,Short.MAX_VALUE,Short.MAX_VALUE);
while (v != null && !(v instanceof SentenceView)) {
View vChild = null;
int n = v.getViewCount();
for (int i = 0; i < n; i++) {
Rectangle r = v.getChildAllocation(i, alloc).getBounds();
if (r.contains(p)) {
vChild = v.getView(i);
alloc = (Rectangle) r.clone();
}
}
v = vChild;
}
if (v != null && v instanceof SentenceView) {
<<< unfold or fold the Sentence View >>>
src.repaint();
}
};
代码示例来源:origin: de.sciss/syntaxpane
@Override
public void install(final JEditorPane editor) {
this.editor = editor;
setFont(editor.getFont());
// setMinimumDisplayDigits(3);
Insets ein = editor.getInsets();
if (ein.top != 0 || ein.bottom != 0) {
Insets curr = getInsets();
setBorder(BorderFactory.createEmptyBorder(ein.top, curr.left, ein.bottom, curr.right));
}
editor.getDocument().addDocumentListener(this);
editor.addCaretListener(this);
editor.addPropertyChangeListener(this);
JScrollPane sp = getScrollPane(editor);
if (sp != null) sp.setRowHeaderView(this);
mouseListener = new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
GotoLineDialog.showForEditor(editor);
}
};
addMouseListener(mouseListener);
setPreferredWidth(false); // required for toggle-lines to correctly repaint
status = Status.INSTALLING;
}
内容来源于网络,如有侵权,请联系作者删除!