當前位置: 首頁>>代碼示例>>Java>>正文


Java View.setSize方法代碼示例

本文整理匯總了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;
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:23,代碼來源:Utilities.java

示例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;
   }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:27,代碼來源:Utilities.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:10,代碼來源:DemoPanel.java

示例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));
}
 
開發者ID:michaelnetter,項目名稱:dracoon-dropzone,代碼行數:18,代碼來源:SettingsDialog.java

示例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));
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:16,代碼來源:HTMLTableHeader.java


注:本文中的javax.swing.text.View.setSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。