本文整理了Java中javax.swing.text.JTextComponent.getMargin()
方法的一些代码示例,展示了JTextComponent.getMargin()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextComponent.getMargin()
方法的具体详情如下:
包路径:javax.swing.text.JTextComponent
类名称:JTextComponent
方法名:getMargin
暂无
代码示例来源:origin: bobbylight/RSyntaxTextArea
Insets margin = editor.getMargin();
if (margin==null) {
editor.setMargin(new InsetsUIResource(2, 2, 2, 2));
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
JTextComponent comp = getComponent();
if (hint != null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))) {
if (color != null) {
g.setColor(color);
} else {
g.setColor(comp.getForeground().brighter().brighter().brighter());
}
Insets margin = comp.getMargin();
g.drawString(hint, margin.left + 2, margin.top + comp.getFont().getSize() + 1);
}
}
代码示例来源:origin: net.java.abeille/abeille
public void updateTextMargin() {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateTextMargin();
}
});
}
Insets orig = textMargin;
Insets cm = (component != null) ? component.getMargin() : null;
int leftWidth = lineNumberWidth + textLeftMarginWidth;
if (cm != null) {
textMargin = new Insets(cm.top, cm.left + leftWidth, cm.bottom, cm.right);
}
else {
textMargin = new Insets(0, leftWidth, 0, 0);
}
if (orig.top != textMargin.top || orig.bottom != textMargin.bottom) {
((BaseTextUI) component.getUI()).invalidateStartY();
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib
public void updateTextMargin() {
if (!SwingUtilities.isEventDispatchThread()) {
SwingUtilities.invokeLater(
new Runnable() {
public void run() {
updateTextMargin();
}
}
);
}
Insets orig = textMargin;
Insets cm = (component != null) ? component.getMargin() : null;
int leftWidth = lineNumberWidth + textLeftMarginWidth;
if (cm != null) {
textMargin = new Insets(cm.top, cm.left + leftWidth,
cm.bottom, cm.right);
} else {
textMargin = new Insets(0, leftWidth, 0, 0);
}
if (orig.top != textMargin.top || orig.bottom != textMargin.bottom) {
((BaseTextUI)component.getUI()).invalidateStartY();
}
}
代码示例来源:origin: crashinvaders/gdx-texture-packer-gui
@Override
protected void paintSafely(Graphics g) {
super.paintSafely(g);
JTextComponent comp = getComponent();
if (hint != null && comp.getText().length() == 0 && (!(hideOnFocus && comp.hasFocus()))) {
if (color != null) {
g.setColor(color);
} else {
g.setColor(comp.getForeground().brighter().brighter().brighter());
}
Insets margin = comp.getMargin();
int padding = (comp.getHeight() - comp.getFont().getSize()) / 2;
//TODO Apply vertical margin as well
g.drawString(hint, margin.left + 2, comp.getHeight() - padding - 1);
}
}
代码示例来源:origin: com.jidesoft/jide-oss
public Insets getBorderInsets(Component c, Insets insets) {
Insets margin = null;
//
// Ideally we'd have an interface defined for classes which
// support margins (to avoid this hackery), but we've
// decided against it for simplicity
//
if (c instanceof AbstractButton) {
margin = ((AbstractButton) c).getMargin();
}
else if (c instanceof JToolBar) {
margin = ((JToolBar) c).getMargin();
}
else if (c instanceof JTextComponent) {
margin = ((JTextComponent) c).getMargin();
}
insets.top = (margin != null ? margin.top : 0) + thickness;
insets.left = (margin != null ? margin.left : 0) + thickness;
insets.bottom = (margin != null ? margin.bottom : 0) + thickness;
insets.right = (margin != null ? margin.right : 0) + thickness;
return insets;
}
}
代码示例来源:origin: jsettlers/settlers-remake
/**
* Install the border
*
* @param txt
* Text component
*/
public static void installUi(JTextComponent txt) {
txt.setOpaque(false);
Insets margin = txt.getMargin();
if (margin == null) {
margin = new Insets(5, 5, 5, 5);
}
Border marginBorder = BorderFactory.createEmptyBorder(margin.top + 3, margin.left, margin.bottom + 3, margin.right);
CompoundBorder border = new CompoundBorder(BorderFactory.createLineBorder(Color.WHITE), marginBorder);
txt.setBorder(border);
txt.setBackground(Color.BLUE);
txt.setForeground(Color.WHITE);
txt.setSelectionColor(SELECTION_COLOR);
}
代码示例来源:origin: com.jidesoft/jide-oss
margin = ((JTextComponent) c).getMargin();
代码示例来源:origin: khuxtable/seaglass
|| region == Region.TEXT_AREA || region == Region.TEXT_FIELD || region == Region.TEXT_PANE)
&& (c instanceof JTextComponent)) {
margin = ((JTextComponent) c).getMargin();
} else if (region == Region.TOOL_BAR && (c instanceof JToolBar)) {
margin = ((JToolBar) c).getMargin();
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
@Override
public void paintComponent( Graphics g )
{
super.paintComponent( g );
g.setColor( Scheme.active().getLineNumberColor() );
g.setFont( _editor.getFont() );
FontMetrics fm = g.getFontMetrics( _editor.getFont() );
int iLineHeight = fm.getHeight();
iLineHeight += getLineSpacingAttr( iLineHeight );
int iMargin = _editor.getMargin().top + getLineSpacingAttr( iLineHeight );
int iLines = getHeight() / iLineHeight;
int borderWidth = getBorder().getBorderInsets( this ).right;
Rectangle clipBounds = g.getClipBounds();
for( int i = 1; i <= iLines; i++ )
{
String strLine = String.valueOf( i );
int iWidth = fm.stringWidth( strLine );
int x = getWidth() - iWidth - getLineInfoRequiredWidth() - borderWidth;
int y = i * iLineHeight - fm.getDescent() + iMargin;
if( inClipBounds( clipBounds, y ) || inClipBounds( clipBounds, y + iLineHeight ) )
{
g.drawString( strLine, x, y );
renderLineInfo( g, i, iLineHeight, getWidth() - getLineInfoRequiredWidth() - borderWidth, (i - 1) * iLineHeight + iMargin );
}
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-lab
public Insets getBorderInsets( Component c, Insets insets )
{
Insets margin = null;
if( c instanceof AbstractButton )
{
margin = ((AbstractButton)c).getMargin();
}
else if( c instanceof JToolBar )
{
margin = ((JToolBar)c).getMargin();
}
else if( c instanceof JTextComponent )
{
margin = ((JTextComponent)c).getMargin();
}
else if( c instanceof JComboBox )
{
margin = ((JTextField)((JComboBox)c).getEditor().getEditorComponent()).getMargin();
}
insets.top = (margin != null ? margin.top : 0) + thickness;
insets.left = (margin != null ? margin.left : 0) + thickness;
insets.bottom = (margin != null ? margin.bottom : 0) + thickness;
insets.right = (margin != null ? margin.right : 0) + thickness;
return insets;
}
}
代码示例来源:origin: org.gosu-lang.gosu/gosu-editor
public Insets getBorderInsets( Component c, Insets insets )
{
Insets margin = null;
if( c instanceof AbstractButton )
{
margin = ((AbstractButton)c).getMargin();
}
else if( c instanceof JToolBar )
{
margin = ((JToolBar)c).getMargin();
}
else if( c instanceof JTextComponent )
{
margin = ((JTextComponent)c).getMargin();
}
else if( c instanceof JComboBox )
{
margin = getBorderInsets( ((JComboBox)c).getEditor().getEditorComponent() );
}
insets.top = (margin != null ? margin.top : 0) + thickness;
insets.left = (margin != null ? margin.left : 0) + thickness;
insets.bottom = (margin != null ? margin.bottom : 0) + thickness;
insets.right = (margin != null ? margin.right : 0) + thickness;
return insets;
}
}
代码示例来源:origin: com.fifesoft/rsyntaxtextarea
Insets margin = editor.getMargin();
if (margin==null) {
editor.setMargin(new InsetsUIResource(2, 2, 2, 2));
代码示例来源:origin: org.swinglabs.swingx/swingx-all
promptComponent.setSelectionColor(txt.getSelectionColor());
promptComponent.setEditable(txt.isEditable());
promptComponent.setMargin(txt.getMargin());
代码示例来源:origin: com.haulmont.thirdparty/swingx-core
promptComponent.setSelectionColor(txt.getSelectionColor());
promptComponent.setEditable(txt.isEditable());
promptComponent.setMargin(txt.getMargin());
代码示例来源:origin: org.bidib.jbidib.swinglabs.swingx/swingx-core
promptComponent.setSelectionColor(txt.getSelectionColor());
promptComponent.setEditable(txt.isEditable());
promptComponent.setMargin(txt.getMargin());
代码示例来源:origin: org.swinglabs.swingx/swingx-core
promptComponent.setSelectionColor(txt.getSelectionColor());
promptComponent.setEditable(txt.isEditable());
promptComponent.setMargin(txt.getMargin());
代码示例来源:origin: khuxtable/seaglass
Insets margin = c.getMargin();
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
Insets margin = editor.getMargin();
if (margin == null || margin instanceof UIResource) {
editor.setMargin(plaf.getInsets(prefix + ".margin"));
代码示例来源:origin: org.opentcs.thirdparty.jhotdraw/jhotdraw
Insets margin = editor.getMargin();
if (margin == null || margin instanceof UIResource) {
editor.setMargin(plaf.getInsets(prefix + ".margin"));
内容来源于网络,如有侵权,请联系作者删除!