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
My 160GB iPod Classic (6th Generation) cannot be recovered by iTunes 12. I plug the iPod into my Macbook Pro and it shows up in Finder. Then an iTunes message appears: "iTunes needs to prepare your iPod for recovery. Please leave your iPod connected. [More]
hi i am using DBAdapter with wizard(select operation),where i have to call a pl/sql function like this msi.organization_idcs_std.get_item_valdn_orgzn_id how can we implment the pl/sql func in the select query using DBAdapter wizard(select operation) [More]
good morning I upgraded from OS 10.9 APP STORE Mavericks are performing a clean install, I understand that like millions of others, I had installed on my Macbook Pro OS Mountain Lion. Everything seemed right, a normal update, but to my surprise as be [More]
I am under the impression that the number of photos that can be seen in My Photo Stream should be the same, no matter which device I use, as long as I am logged in these devices with the same Apple ID.  Is this assumption wrong? My wife and I use the [More]
Hi, I'm really new to TestStand, so this is probably an easy question: I'm using TestStand 4.5 and I'm trying to convert the name of a variable, Locals.MaxArrayIndex, which is a numeric variable, into a String, Locals.VarString. I know that the Str() [More]
I am trying to export a short film in 16.9, its no propblem to do as a large file but I need to have it as a smaller file. Less than 150g. So when I select in export using qt, chose my codec, everything is fine, but when I select encode for broadband [More]
hi, iv just got my ipod back from repair and they have sent me a new one and since i sent it i purchased a new pc, does anyone know where i can download the installation disk? iv downloaded the latest itunes and ipod update and my pc recognises the i [More]
Guys, Attached is an instrument .vi that I have been working on.  I was wondering if someone could open it and make the following changes.  I need the following things to turn on when the program is run: 2nd LED of the "Wheel" Button 3rd LED of [More]
Software Update failed and I had to archive/install back to 10.5 - just download the Combo Updater and you should be ok.To close this thread - the Combo update worked perfectly and my machine is exactly how it was before starting the update process - [More]
Hello, I don't have administrator rights on my computer, and I would like to know if there is a way to install the Power Map add-in without it, e.g. via an xlam file in the add-ins menu, instead of trying to launch the exe file that you can download [More]