本文整理匯總了Java中javax.swing.text.View.setSize方法的典型用法代碼示例。如果您正苦於以下問題:Java View.setSize方法的具體用法?Java View.setSize怎麽用?Java View.setSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.View
的用法示例。
在下文中一共展示了View.setSize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: modelToView
import javax.swing.text.View; //導入方法依賴的package包/類
static Rectangle2D modelToView(JTextComponent tc, int pos, Position.Bias bias) throws BadLocationException {
Document doc = tc.getDocument();
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).readLock();
}
try {
Rectangle alloc = getVisibleEditorRect(tc);
if (alloc != null) {
View rootView = tc.getUI().getRootView(tc);
rootView.setSize(alloc.width, alloc.height);
Shape s = rootView.modelToView(pos, alloc, bias);
if (s != null) {
return s.getBounds2D();
}
}
} finally {
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).readUnlock();
}
}
return null;
}
示例2: viewToModel
import javax.swing.text.View; //導入方法依賴的package包/類
static int viewToModel(JTextComponent tc, double x, double y, Position.Bias[] biasReturn) {
int offs = -1;
Document doc = tc.getDocument();
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).readLock();
}
try {
Rectangle alloc = getVisibleEditorRect(tc);
if (alloc != null) {
View rootView = tc.getUI().getRootView(tc);
View documentView = rootView.getView(0);
if (documentView instanceof EditorView) {
documentView.setSize(alloc.width, alloc.height);
offs = ((EditorView) documentView).viewToModelChecked(x, y, alloc, biasReturn);
} else {
rootView.setSize(alloc.width, alloc.height);
offs = rootView.viewToModel((float) x, (float) y, alloc, biasReturn);
}
}
} finally {
if (doc instanceof AbstractDocument) {
((AbstractDocument)doc).readUnlock();
}
}
return offs;
}
示例3: setTipText
import javax.swing.text.View; //導入方法依賴的package包/類
@Override
public void setTipText(String tipText) {
super.setTipText(tipText);
if( getPreferredSize().width > 400 ) {
View v = (View) getClientProperty("html"); //NOI18N
if( null != v )
v.setSize(300.0f, 300.0f);
}
}
示例4: getPreferredSize
import javax.swing.text.View; //導入方法依賴的package包/類
/**
* Returns the preferred size to set a component at in order to render an
* html string. You can specify the size of one dimension.
*/
private static Dimension getPreferredSize(String html, boolean width, int prefSize) {
RESIZER.setText(html);
View view = (View) RESIZER.getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey);
view.setSize(width ? prefSize : 0, width ? 0 : prefSize);
float w = view.getPreferredSpan(View.X_AXIS);
float h = view.getPreferredSpan(View.Y_AXIS);
return new java.awt.Dimension((int) Math.ceil(w), (int) Math.ceil(h));
}
示例5: getPreferredSize
import javax.swing.text.View; //導入方法依賴的package包/類
public static java.awt.Dimension getPreferredSize(String text,
boolean width, int prefSize) {
JLabel resizer = new JLabel(text);
View view = (View) resizer
.getClientProperty(javax.swing.plaf.basic.BasicHTML.propertyKey);
view.setSize(width ? prefSize : 0, width ? 0 : prefSize);
float w = view.getPreferredSpan(View.X_AXIS);
float h = view.getPreferredSpan(View.Y_AXIS) + 2;
return new java.awt.Dimension((int) Math.ceil(w), (int) Math.ceil(h));
}