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


Java BasicTextUI类代码示例

本文整理汇总了Java中javax.swing.plaf.basic.BasicTextUI的典型用法代码示例。如果您正苦于以下问题:Java BasicTextUI类的具体用法?Java BasicTextUI怎么用?Java BasicTextUI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: getNextVisualPositionFrom

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
public int getNextVisualPositionFrom(final JTextComponent c, final int pos,
        final Position.Bias bias, final int direction, final Position.Bias[] biasRet)
        throws BadLocationException {
    if (c == null)
        return 0;
    BasicTextUI ui = (BasicTextUI)c.getUI();
    View rootView = ui.getRootView(c);
    Rectangle rect = c.getVisibleRect();
    if (rect == null)
        return 0;
    Insets insets = c.getInsets();
    rect.x += insets.left;
    rect.y += insets.top;
    rect.width -= insets.left + insets.right;
    rect.height -= insets.top + insets.bottom;
    return rootView.getNextVisualPositionFrom(pos,bias,rect,direction, biasRet);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:NavigationFilter.java

示例2: getCharacterBounds

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
public Rectangle getCharacterBounds(final int i) {
    Rectangle forward = null;
    Rectangle backward = null;
    try {
        forward = ((BasicTextUI) ui).modelToView(JTextComponent.this, i,
                Position.Bias.Forward);
        backward = ((BasicTextUI) ui).modelToView(JTextComponent.this,
                Math.min(document.getLength(), i + 1),
                Position.Bias.Backward);
    } catch (final BadLocationException e) {
    }
    if (forward == null || backward == null) {
        return null;
    }
    forward.width = Math.abs(forward.x - backward.x) + 1;
    forward.x = Math.min(forward.x, backward.x);
    return forward;
}
 
开发者ID:shannah,项目名称:cn1,代码行数:19,代码来源:JTextComponent.java

示例3: setUp

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    bWasException = false;
    length = content.length();
    jf = new JFrame();
    pf = new JPasswordField(content);
    view = (PasswordView) ((BasicTextUI) pf.getUI()).getRootView(pf).getView(0);
    fm = pf.getFontMetrics(pf.getFont());
    assertNotNull(fm);
    text = new Segment();
    pf.getDocument().getText(0, length, text);
    echoChars = new Segment(new char[] { '*', '*', '*', '*', '*', '*', '*', '*' }, 0,
            length);
    textWidth = Utilities.getTabbedTextWidth(text, fm, 0, view, 0);
    echoCharsWidth = Utilities.getTabbedTextWidth(echoChars, fm, 0, view, 0);
    height = fm.getHeight();
    assertNotNull(text);
    jf.getContentPane().add(pf);
    pf.setForeground(Color.RED);
    pf.setSelectedTextColor(Color.GREEN);
    jf.setSize(200, 300);
    jf.pack();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:PasswordViewTest.java

示例4: testJTextComponent

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
public void testJTextComponent() {
    jtComp = new JTextComp();
    assertNotNull(jtComp);
    assertTrue(jtComp.getUI() instanceof TextCompUI);
    assertTrue(jtComp.getCaret() instanceof BasicTextUI.BasicCaret);
    assertEquals("Dot=(0, Forward) Mark=(0, Forward)", jtComp.getCaret().toString());
    assertTrue(jtComp.getHighlighter() instanceof BasicTextUI.BasicHighlighter);
    assertEquals(ComponentOrientation.UNKNOWN, jtComp.getComponentOrientation());
    assertTrue(jtComp.isEditable());
    assertFalse(jtComp.getDragEnabled());
    assertEquals('\0', jtComp.getFocusAccelerator());
    assertEquals("TextCompUI", jtComp.getKeymap().getName());
    assertEquals(0, jtComp.getKeymap().getBoundActions().length);
    assertEquals(0, jtComp.getKeymap().getBoundKeyStrokes().length);
    assertEquals(new InsetsUIResource(0, 0, 0, 0), jtComp.getMargin());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:JTextComponent_byAuxiliaryComponentTest.java

示例5: setUp

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
    super.setUp();
    jf = new JFrame();
    jtf = new JTextField("JTextField for FieldView testing");
    jf.getContentPane().add(jtf);
    fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf).getView(0);
    jf.setSize(200, 100);
    jf.pack();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:FieldViewTest.java

示例6: testGetPreferredSpan

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
public void testGetPreferredSpan() {
    FontMetrics fm = fv.getFontMetrics();
    assertEquals(fm.getHeight(), (int) fv.getPreferredSpan(View.Y_AXIS));
    assertEquals(fm.stringWidth(jtf.getText()), (int) fv.getPreferredSpan(View.X_AXIS));
    jtf.setFont(new java.awt.Font("SimSun", 0, 12));
    fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf).getView(0);
    fm = jtf.getFontMetrics(jtf.getFont());
    assertEquals(fm.stringWidth(jtf.getText()), (int) fv.getPreferredSpan(View.X_AXIS));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:10,代码来源:FieldViewTest.java

示例7: getXsd

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
protected JComponent getXsd(JsonNode type, boolean editable) {
	DocumentFilter filter = null;

	if(type != null && type.getNodeType() == JsonNodeType.STRING) {
		switch (type.asText()) {
		case "xsd:unsignedLong":
			filter = new IntegerRangeDocumentFilter(BigInteger.ZERO, MAX_UNSIGNED_LONG);
			break;
		case "xsd:unsignedInt":
			filter = new IntegerRangeDocumentFilter(BigInteger.ZERO, MAX_UNSIGNED_INT);
			break;
		case "xsd:unsignedShort":
			filter = new IntegerRangeDocumentFilter(BigInteger.ZERO, MAX_UNSIGNED_SHORT);
			break;
		case "xsd:unsignedByte":
			filter = new IntegerRangeDocumentFilter(BigInteger.ZERO, MAX_UNSIGNED_BYTE);
			break;
		case "xsd:long":
			filter = new IntegerRangeDocumentFilter(MIN_LONG, MAX_LONG);
			break;
		case "xsd:int":
			filter = new IntegerRangeDocumentFilter(MIN_INT, MAX_INT);
			break;
		case "xsd:short":
			filter = new IntegerRangeDocumentFilter(MIN_SHORT, MAX_SHORT);
			break;
		case "xsd:byte":
			filter = new IntegerRangeDocumentFilter(MIN_BYTE, MAX_BYTE);
			break;
		case "xsd:boolean":
			filter = new BooleanDocumentFilter();
			break;
		}
	}


	JTextField XsdComponent = new JTextField();

	JTextComponent textComponent = (JTextComponent) XsdComponent;
	textComponent.setEditable(editable);
	if(type != null) {
		BasicTextUI textFieldUI = new HintTextFieldUI(" " + type, editable, Color.GRAY);
		textComponent.setUI(textFieldUI);
		textComponent.setToolTipText(type.toString());
	}


	if (filter == null) {
		log.warn("TextField created without input control for type: " + type);
	} else {
		PlainDocument pd = (PlainDocument) textComponent.getDocument();
		pd.setDocumentFilter(filter);
		log.info("TextField created with input control for type: " + type + ", " + filter);
	}

	return XsdComponent;
}
 
开发者ID:thingweb,项目名称:thingweb-gui,代码行数:58,代码来源:ThingPanelUI.java

示例8: viewToModel

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
public int viewToModel(final Point p, final Position.Bias[] biasRet) {
    return ((BasicTextUI)ui).viewToModel(JTextComponent.this,
                                         p, biasRet);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:5,代码来源:JTextComponent.java

示例9: modelToView

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
public Rectangle modelToView(final int pos, final Position.Bias bias)
    throws BadLocationException {
    return ((BasicTextUI)ui).modelToView(JTextComponent.this,
                                         pos, bias);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:6,代码来源:JTextComponent.java

示例10: getToolTipText

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
public String getToolTipText(final MouseEvent me) {
    String toolTipText = super.getToolTipText();
    return (toolTipText != null) ? toolTipText
            : ((BasicTextUI) ui).getToolTipText(this, new Point(me.getX(),
                    me.getY()));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:7,代码来源:JTextComponent.java

示例11: testGetFontMetrics

import javax.swing.plaf.basic.BasicTextUI; //导入依赖的package包/类
public void testGetFontMetrics() {
    assertEquals(jtf.getFontMetrics(jtf.getFont()), fv.getFontMetrics());
    jtf.setFont(new java.awt.Font("SimSun", 0, 12));
    fv = (FieldView) ((BasicTextUI) jtf.getUI()).getRootView(jtf).getView(0);
    assertEquals(jtf.getFontMetrics(jtf.getFont()), fv.getFontMetrics());
}
 
开发者ID:shannah,项目名称:cn1,代码行数:7,代码来源:FieldViewTest.java


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