Sitemap

Amicuk Programming Answers

Two problems with displaying images in JPanel

2015-10-11   Views:0

Advertisement

Hi, I need to display some small rectangular images inside a JPanel. These images also need to be componenents as they will have listeners associated with them. I have never had any experience with images, so I might totally be down the wrong path. I

Hi,
I need to display some small rectangular images inside a JPanel. These images also need to be componenents as they will have listeners associated with them. I have never had any experience with images, so I might totally be down the wrong path. I was thinking of just creating a class which extends JComponent, and using the graphics drawImage method. However, I don't want each image component to have to know exactly where to draw the image associated with itself. Rather, I want the JPanel which holds all of the images to know how to lay them out.
Is there an easier way to use images?
Which brings me to my second problem. I want these images to overlap each other, so that only a small portion of each is showing (this way I can fit more on the screen), then when the user clicks on one, I can show more of it.
Unfortunately, I don't know of any layout managers which will allow me to overlap components. I could use the drawImage method mentioned above, but like I said, I would like to try to not have each image object try and figure out its location.
any help is greatly appreciated. Thanks!

The replay answer
Advertisement
Hi
there is a better way ; it is called a JLabel ;-)
JLabel myJLabel = new JLabel(new ImageIcon("img/myLogo.gif"));for your second problem, don't use any layout manager like in this code :
myJPanel.setLayout(null);
myJPanel.add(myJLabel);
myJLabel.setBounds(new Rectangle(x, y, width, height);hope it helps
Nico

Go to See the other 4 answers

Two problems with displaying images in JPanel

Category:DefaultRelease time:2015-10-11Views:130

Hi, I need to display some small rectangular images inside a JPanel. These images also need to be componenents as they will have listeners associated with them. I have never had any experience with images, so I might totally be down the wrong path. I[More]

Help Please, Problem in displaying same  JTables on two JPanels

Category:DefaultRelease time:-0001-11-30Views:130

Problem in displaying same JTables on two JPanels. In an application, I have a dynamic display of JTables on one JPanel. After a print preview button action, I have to bring same JTables on another JPanels, while taking this the previous JPanels cont[More]

Problem with display of JScrollPane

Category:DefaultRelease time:2015-10-11Views:130

I have made a small GUI. It has a JFrame and four JPanels are added to the frame. The placement is done by program and hence layout manager is set to null. Two of the panels contain JScrollPane. One scroll pane is associated with a JList. Another scr[More]

Need to display image on JPanel

Category:DefaultRelease time:-0001-11-30Views:130

Hello I am trying to implement a graphical version of the Knights Tour. I am done with the algorithm part of the problem itself. I am having problem with displaying the chess board. Although seemingly straightforward the images will not display on th[More]

Problem in displaying the TaxRate columns .

Category:DefaultRelease time:2015-10-11Views:130

Hi Experts,                         I am having a problem in displaying the 'TaxRate', in this Query there are some different Taxrate's columns  like-  ' 'Basic Excise Duty [email protected] %',  ' Education [email protected]% ' , 'Secondary Education Cess @1%',    etc.  [More]

Problem with displaying BLOB images on JSP page using a servlet

Category:DefaultRelease time:2015-10-11Views:130

hi. I have a big problem with displaying BLOB images using JSP. I have a servlet that connects to the oracle database, gets a BLOB image , reads it, and then displays it using a BinaryStream. The problem is , this works only when i directly call that[More]

Problem with display of Buttons in ADF

Category:DefaultRelease time:2015-10-11Views:130

Hi All, I had a strange problem in display of the ADF Page in one of the server.I had two buttons inside ToolBars, The UI was coming fine in the two WLS, But when I deployed the application in third WLS, I was seeing that Buttons are coming in the to[More]

Problem with display driver

Category:DefaultRelease time:2015-10-11Views:130

Hello, Im using Photoshop CC and when it starts up it sometimes gives me this error message: 'Problem with display driver and has temporary disabled enhancements which use graphics hardware.' What does this mean? Then it tells me to download the lats[More]

I have a early 2011 Macbook pro 13 inch, I'm running Lion 10.7.4, and i want to upgrade to 10.8 Mountain Lion. Is it safe for my computer or are people experiencing problems with displays and Battery life?

Category:DefaultRelease time:2015-10-11Views:130

I have a early 2011 Macbook pro 13 inch, I'm running Lion 10.7.4, and i want to upgrade to 10.8 Mountain Lion. Is it safe for my computer or are people experiencing problems with displays and Battery life? Do Not post stuff about how Airplay doesnt w[More]

Authorization problem when displaying icons in BW Report

Category:DefaultRelease time:2015-10-11Views:130

Hi All I have the following problem when display BW Report as iView: The report data itself is displayed perfectly but to display the icons (like DrillDown arrows, Hierarhy level open arrows) the Windows login message "Connect to <my BW server.com[More]

Problem to display a negative number in XML Publisher output in excel

Category:DefaultRelease time:2015-10-11Views:130

Hi All, I am facing problem in displaying a negative number in XML Publisher output in excel. My requirement is that I have to display a negative number in brackets when the output is taken in excel format. Eg: If the value is -123 then i have to dis[More]

Hot
I've got Windows 7 RC 64-bit installed on a 2.53 GHz MacBook Pro (dual boot using Boot Camp) with an ExpressCard slot. I also got a FileMate SolidGO 3FMS4D48M-WR 48GB ExpressCard SSD; the drive works beautifully under OS X, but is not recognized at a [More]
in 4.6c cancel and filename is passed in importing in  download .after unicode checks how to pass cancel in gui_upload and how ever filename is present in exporting parameters in gui_downlaod there is no cancel parameter in gui_download. plz any one [More]
Im using iphone 4 uk unlock , it has ios 4.2.1 and it does not have software update option.Now i want to update the phone with latest ios is it possible and tel me how ?The update to iOS 5.0 & higher is an erase/restore deal, so make sure you follow [More]
Hii All I have this issue wherein I have maintained number ranges for shipments from 30000 - 60000. The current shipment number is in the range of 59000. So it is getting near to exhaustion. I need to changes the number range for the shipments say fr [More]
Hi guys, what are the parameters to be imported in using BAPI_SALESORDER_SIMULATE? thanks a lot!Hi Mark, These are the Importing Parametres ORDER_HEADER_IN CONVERT_PARVW_AUART ORDER_HEADER_IN  is of structure BAPISDHEAD CONVERT_PARVW_AUART is of  typ [More]
Hi We have an interface in XI which posts IDoc to SAP . In the inbound side XI polls the database and executes a query. But during SAP outages ( Planned/unplanned) though XI executes SQL and process the messages successfully the message fails in the [More]
I have a few mp3s that won't play on my iPod. They are DRM-free and play perfectly fine in iTunes. However, when I try to play it on my iPod, the first 30 seconds will play fine and then it'll stop and go all the way back to the beginning. If I go to [More]
Starting a few days ago, when one OSXS system is accessed with Server Admin, the servermgrd process immediately crashes. Could there be some file that somehow got corrupted? I've run 'repair disk' and 'repair permissions', and even did a full Disk Wa [More]
Hello I have been trying to update to OS 10.9.2 (from 10.9.1) following a software update notice, but the upgrade froze after just a few minutes and nothing has happened for about 5 hours. How can I quit?? What can I do to restart? I'm not sure when [More]
i have my new iPhone and i play game called iron force its working normal suddenly i find message connection lost becouse i login from other device its my old device iPad i lost so the person who use my old device he kick me from the game not from ga [More]