Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Can anyone suggest a way of going about drawing my own lines and everything on a JLabel?</p> </blockquote> <p>Draw to the <code>Graphics2D</code> of a <code>BufferedImage</code>. Display the image (in an <code>ImageIcon</code>) in the label.</p> <h2>E.G.</h2> <ol> <li><a href="https://stackoverflow.com/a/6296381/418556">Drawing text to an image</a>.<br> <img src="https://i.stack.imgur.com/ET1EH.png"></li> <li><a href="https://stackoverflow.com/a/9772978/418556">Drawing a border</a> (animated).<br> <img src="https://i.stack.imgur.com/DnzXV.gif"></li> <li><a href="https://stackoverflow.com/a/13440543/418556">Another text demo.</a>, this one using scaling &amp; fading.<br> <img src="https://i.stack.imgur.com/zy2q4.png" ></li> <li>Oh, and here's <a href="https://stackoverflow.com/a/10628553/418556">one with simple lines</a> (..and dots, ..and it is animated).<br> <img src="https://i.stack.imgur.com/eAgUn.png" ></li> </ol> <hr> <blockquote> <p>I am trying to make an rpg using swing (yes it is stupid I agree, but I am doing this for learning ..</p> </blockquote> <p>I don't think it is stupid at all. Swing components are the only way to go if the choice is Swing or AWT. Not only is the toolkit much richer (show me the AWT equivalent of <code>ImageIcon</code>, <code>JTree</code>, <code>JTable</code>,..) but has double buffering by default, and is directly <strong>built on</strong> the AWT. I stressed that last part because it is often the case with games, where we override paint and 'go for it' - paint every pixel. </p> <p>Once that is done, it is typically 'all AWT'. The examples I posted use no AWT Components, yet all use a <code>BufferedImage</code>, some use <code>GlyphVector</code> or <code>AffineTransform</code>, either <code>Graphics</code> (when I' feeling lazy) or <code>Graphics2D</code> (for those wonderful rendering hints..).</p> <p>But taking it a step even further and a 'Swing' splash screen or full screen window is also pure AWT.</p> <p>For the clickable/editable components, use Swing. For custom rendering, and corner cases like the splash or FSW, reach for the AWT classes.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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