本文整理了Java中javax.swing.JTextField.paintComponent()
方法的一些代码示例,展示了JTextField.paintComponent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTextField.paintComponent()
方法的具体详情如下:
包路径:javax.swing.JTextField
类名称:JTextField
方法名:paintComponent
暂无
代码示例来源:origin: org.icepdf.os/icepdf-viewer
@Override
protected void paintComponent(Graphics g) {
if (!active) {
return;
}
// paint the component at the scale of the page.
super.paintComponent(g);
}
代码示例来源:origin: org.orbisgis/orbisgis-view
@Override
protected void paintComponent(final Graphics g) {
super.paintComponent(g);
this.icon.paintIcon(null, g, 1, 1);
}
代码示例来源:origin: orbisgis/orbisgis
@Override
protected void paintComponent(final Graphics g) {
super.paintComponent(g);
this.icon.paintIcon(null, g, 1, 1);
}
代码示例来源:origin: com.jalalkiswani/jk-desktop
@Override
protected void paintComponent(final Graphics pG) {
super.paintComponent(pG);
if (placeholder == null || placeholder.length() == 0 || getText().length() > 0 || !isEnabled()) {
return;
}
final Graphics2D g = (Graphics2D) pG;
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.lightGray);
g.drawString(placeholder, getInsets().left, pG.getFontMetrics().getMaxAscent() + getInsets().top);
}
代码示例来源:origin: de.sciss/scisslib
/**
* Paints the text field component and
* fill its area with the specified
* paint afterwards. If no paint was
* specified, the text field will just
* look like a normal <code>JTextField</code>.
*/
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (p == null) return;
final Dimension d = getSize();
final Graphics2D g2 = (Graphics2D) g;
final Paint op = g2.getPaint();
final String lafId = UIManager.getLookAndFeel().getID();
final boolean isWebLaF = lafId.equals("submin") || lafId.equals("weblaf");
final int insets = isWebLaF ? 1 : 0;
g2.setPaint(p);
g2.fillRect(insets, insets, d.width - (insets + insets), d.height - (insets + insets));
g2.setPaint(op);
}
}
代码示例来源:origin: edu.toronto.cs.medsavant/medsavant-client
@Override
protected void paintComponent(final Graphics pG) {
super.paintComponent(pG);
if (placeholder.length() == 0 || getText().length() > 0) {
return;
}
final Graphics2D g = (Graphics2D) pG;
g.setRenderingHint(
RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(getDisabledTextColor());
g.drawString(placeholder, getInsets().left, pG.getFontMetrics()
.getMaxAscent() + getInsets().top);
}
代码示例来源:origin: com.jidesoft/jide-oss
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
Composite orgComposite = g2.getComposite();
Color orgColor = g2.getColor();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.70f));
Object o = JideSwingUtilities.setupShapeAntialiasing(g);
g2.setColor(getBackground());
g.fillRoundRect(1, 1, getWidth() - 2, getHeight() - 2, 1, 1);
JideSwingUtilities.restoreShapeAntialiasing(g, o);
g2.setColor(orgColor);
g2.setComposite(orgComposite);
super.paintComponent(g);
}
}
代码示例来源:origin: xyz.cofe/gui.swing
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
String txt = getText();
String pholder = getPlaceholder();
if( pholder!=null && pholder.length()>0 && (txt==null || txt.length()<1) ){
paintPlaceholder((Graphics2D)g);
}
if( warningIconVisible ){
paintWarningIcon((Graphics2D)g);
}
}
代码示例来源:origin: jsettlers/settlers-remake
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int x = 4;
searchIcon.paintIcon(this, g, x, (this.getHeight() - searchIcon.getIconHeight()) / 2);
// color already set by search icon...
if (getText().isEmpty()) {
x += searchIcon.getIconWidth() + 6;
int y = this.getHeight() - (this.getHeight() - g.getFontMetrics().getHeight()) / 2 - g.getFontMetrics().getDescent();
g.drawString(SEARCH, x, y);
}
}
代码示例来源:origin: UNIVALI-LITE/Portugol-Studio
@Override
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
if (podePintarPlaceholder())
{
Font fonte = getFont();
g.setFont(fonte);
g.setColor(getForeground());
FontMetrics metrics = getFontMetrics(fonte);
int textoY = getHeight()/2 + (metrics.getDescent() + metrics.getAscent())/2;
int textoX = originalInsets.left;
g.drawString(placeholder, textoX, textoY);
}
}
代码示例来源:origin: jsettlers/settlers-remake
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int x = 4;
searchIcon.paintIcon(this, g, x, (this.getHeight() - searchIcon.getIconHeight()) / 2);
// color already set by search icon...
if (getText().isEmpty()) {
x += searchIcon.getIconWidth() + 6;
int y = this.getHeight() - (this.getHeight() - g.getFontMetrics().getHeight()) / 2 - g.getFontMetrics().getDescent();
g.drawString(SEARCH, x, y);
}
}
}
代码示例来源:origin: abel533/DBMetadata
@Override
public void paintComponent(Graphics g) {
Component window = this.getTopLevelAncestor();
if (window instanceof Window && !((Window) window).isOpaque()) {
// This is a translucent window, so we need to draw to a buffer
// first to work around a bug in the DirectDraw rendering in Swing.
int w = this.getWidth();
int h = this.getHeight();
if (buffer == null || buffer.getWidth() != w || buffer.getHeight() != h) {
// Create a new buffer based on the current size.
GraphicsConfiguration gc = this.getGraphicsConfiguration();
buffer = gc.createCompatibleImage(w, h, BufferedImage.TRANSLUCENT);
}
// Use the super class's paintComponent implementation to draw to
// the buffer, then write that buffer to the original Graphics object.
Graphics bufferGraphics = buffer.createGraphics();
try {
super.paintComponent(bufferGraphics);
} finally {
bufferGraphics.dispose();
}
g.drawImage(buffer, 0, 0, w, h, 0, 0, w, h, null);
} else {
// This is not a translucent window, so we can call the super class
// implementation directly.
super.paintComponent(g);
}
}
}
代码示例来源:origin: tinyMediaManager/tinyMediaManager
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
代码示例来源:origin: leMaik/swing-material
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g2.setColor(getBackground());
g2.fillRect(0, 0, getWidth(), getHeight());
g2.translate(0, 9);
super.paintComponent(g);
g2.translate(0, -9);
if (!getHint().isEmpty() && getText().isEmpty() && (getLabel().isEmpty() || isFocusOwner()) && floatingLabel.isFloatingAbove()) {
g.setFont(Roboto.REGULAR.deriveFont(16f));
g2.setColor(Utils.applyAlphaMask(getForeground(), HINT_OPACITY_MASK));
FontMetrics metrics = g.getFontMetrics(g.getFont());
g.drawString(getHint(), 0, metrics.getAscent() + 36);
}
floatingLabel.paint(g2);
g2.setColor(Utils.applyAlphaMask(getForeground(), LINE_OPACITY_MASK));
g2.fillRect(0, getHeight() - 9, getWidth(), 1);
g2.setColor(accentColor);
g2.fillRect((int) ((getWidth() - line.getWidth()) / 2), getHeight() - 10, (int) line.getWidth(), 2);
}
代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide
public void paintComponent (Graphics g) {
//For property panel usage, allow the editor to paint
if (editor != null && !hasFocus() && editor.isPaintable()) {
Insets ins = getInsets();
Color c = g.getColor();
try {
g.setColor(getBackground());
g.fillRect(0,0,getWidth(),getHeight());
} finally {
g.setColor(c);
}
ins.left += PropUtils.getTextMargin();
editor.paintValue(g, new Rectangle(ins.left, ins.top, getWidth() -
(ins.right + ins.left), getHeight() - (ins.top + ins.bottom)));
} else {
super.paintComponent(g);
}
}
}
代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide
public void paintComponent (Graphics g) {
//For property panel usage, allow the editor to paint
if (editor != null && !hasFocus() && editor.isPaintable()) {
Insets ins = getInsets();
Color c = g.getColor();
try {
g.setColor(getBackground());
g.fillRect(0,0,getWidth(),getHeight());
} finally {
g.setColor(c);
}
ins.left += PropUtils.getTextMargin();
editor.paintValue(g, new Rectangle(ins.left, ins.top, getWidth() -
(ins.right + ins.left), getHeight() - (ins.top + ins.bottom)));
} else {
super.paintComponent(g);
}
}
}
代码示例来源:origin: org.netbeans.api/org-openide-explorer
@Override
public void paintComponent(Graphics g) {
//For property panel usage, allow the editor to paint
if ((editor != null) && !hasFocus() && editor.isPaintable()) {
Insets ins = getInsets();
Color c = g.getColor();
try {
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
} finally {
g.setColor(c);
}
ins.left += PropUtils.getTextMargin();
editor.paintValue(
g,
new Rectangle(
ins.left, ins.top, getWidth() - (ins.right + ins.left), getHeight() - (ins.top + ins.bottom)
)
);
} else {
super.paintComponent(g);
}
}
代码示例来源:origin: eu.mihosoft.vrl/vrl
super.paintComponent(g);
代码示例来源:origin: org.apache.cayenne.modeler/cayenne-modeler
@Override
public void paintComponent(Graphics g) {
if (hasFocus) {
super.paintComponent(g);
} else {
list.setEnabled(combo.isEnabled());
Component c = combo.getRenderer()
.getListCellRendererComponent(list, combo.getSelectedItem(), -1, false, false);
Insets insets = getInsets();
Color oldColor = g.getColor();
g.setColor(getBackground());
if(Boolean.TRUE.equals(getClientProperty("TextField.fullSizeBackground"))) {
g.fillRect(0, 0, getWidth(), getHeight());
} else {
g.fillRect(insets.left, insets.top,
getWidth() - insets.right - insets.left, getHeight() - insets.bottom - insets.top);
}
g.setColor(oldColor);
rendererPane.paintComponent(g, c, combo, insets.left, insets.top,
getWidth() - insets.right - insets.left, getHeight() - insets.bottom - insets.top);
}
}
代码示例来源:origin: protegeproject/protege
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
内容来源于网络,如有侵权,请联系作者删除!