Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>As shown <a href="https://stackoverflow.com/a/11924118/230513">here</a>, "<code>drawString()</code> expects the coordinates to represent the <a href="http://docs.oracle.com/javase/6/docs/api/java/awt/FontMetrics.html" rel="nofollow noreferrer">baseline</a> of the <code>String</code>."</p> <pre><code>FontMetrics fm = g.getFontMetrics(); g.drawString(texto, 0, fm.getAscent()); </code></pre> <p><img src="https://i.stack.imgur.com/hm4l6.png" alt="ventana"></p> <p>In addition,</p> <ul> <li><p>Use a <code>JTextComponent</code> for editable text.</p></li> <li><p>Use <a href="http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html" rel="nofollow noreferrer">Key Bindings</a>, rather than <code>KeyListener</code>.</p></li> <li><p>Use <code>pack()</code> on the enclosing <code>Window</code>.</p></li> <li><p>"Swing programs should override <code>paintComponent()</code> instead of overriding <code>paint()</code>."—<a href="http://www.oracle.com/technetwork/java/painting-140037.html#callbacks" rel="nofollow noreferrer"><em>Painting in AWT and Swing: The Paint Methods</em></a>.</p></li> <li><p>Swing GUI objects should be constructed and manipulated <em>only</em> on the <a href="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html" rel="nofollow noreferrer">event dispatch thread</a>.</p></li> <li><p>Use appropriate <a href="http://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html" rel="nofollow noreferrer">access control</a>.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload