Path: csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.alt.net!news-in-01.newsfeed.easynews.com!easynews.com!easynews!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail From: "Andrew Thompson" Subject: Re: trouble creating resi Message-ID: <7351f4bebd9f9@uwe> X-Comment-To: comp.lang.java.gui Newsgroups: comp.lang.java.gui In-Reply-To: <1181144282.851041.219850@q66g2000hsg.googlegroups.com> References: <1181144282.851041.219850@q66g2000hsg.googlegroups.com> Content-Type: text/plain; charset=IBM437 Content-Transfer-Encoding: 8bit X-Gateway: time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92] Lines: 116 Date: Wed, 27 Apr 2011 15:35:12 GMT NNTP-Posting-Host: 96.60.20.240 X-Complaints-To: news@tds.net X-Trace: newsreading01.news.tds.net 1303918512 96.60.20.240 (Wed, 27 Apr 2011 10:35:12 CDT) NNTP-Posting-Date: Wed, 27 Apr 2011 10:35:12 CDT Organization: TDS.net Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.gui:1762 To: comp.lang.java.gui E.D.I wrote: Sub: trouble creating resizable jlabel with an image?? Please find your shift key and apply it once at the start of each sentence, for every use of the word 'I' and any reference to J2SE classes (it is a JLabel, unless you are talking about some completely unrelated class). Also note that one question mark denotes a question, whereas two indicates that the person asking, is impatient and needy - please restrict yourself to one. >...how can i create the icon >to work as a background image? This code probably answers the question of why it is not wise to do this, better than it answers the actual question. import java.net.*; import java.awt.*; import java.awt.image.*; import javax.swing.*; class BackgroundImageLabel extends JPanel { Image image; JLabel label; BackgroundImageLabel(URL imgURL, String text) { super( new BorderLayout() ); image = Toolkit.getDefaultToolkit() .createImage( imgURL ); MediaTracker mt = new MediaTracker(this); mt.addImage( image, 0 ); try { mt.waitForAll(); } catch(InterruptedException e) { // wake and continue.. } label = new JLabel(text); add( label, BorderLayout.CENTER ); } public void paintComponent(Graphics g) { g.drawImage( image, 0,0,getWidth(),getHeight(), this ); label.repaint(); } public Dimension getMinimumSize() { Dimension labelSize = label.getMinimumSize(); int imageWidth = image.getWidth(this); int imageHeight = image.getHeight(this); int width = ( (imageWidth/2) -- Andrew Thompson http://www.athompson.info/andrew/ Message posted via http://www.javakb.com --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24