473,506 Members | 17,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problem with tabbed pane containing an image - never calls paint method on tab select

1 New Member
I am using a tabbed pane with four tabs - three of which work perfectly - the fourth one is supposed to display an image but does NOT ever call the
paint method. When I use the same ImagePanel code but add it to a JFrame of its own everything works perfectly.
ANY ideas would be welcome.

setup of ImagePanel:

Expand|Select|Wrap|Line Numbers
  1.   public ImagePanel(BufferedImage image)
  2.    {
  3.     fImage = image;
  4.    }
  5.  
  6.   public void paint(Graphics g)
  7.    {
  8.      System.out.println("Entering paint for image");
  9.     if (getSize().width <= 0 || getSize().height <= 0)
  10.      {
  11.       return;
  12.      }
  13.  
  14.     Graphics2D g2 = (Graphics2D) g;
  15.  
  16.     if (fImage != null && isShowing())
  17.      {
  18.       g2.drawImage(fImage, 0, 0, this);
  19.      }
  20.    }
  21.  
setup of tabbed pane:

Expand|Select|Wrap|Line Numbers
  1.   public JTabbedPane createTabbedPane()
  2.    {
  3.     JTabbedPane tPane = new JTabbedPane();
  4.     tPane.setSize(600, 450);
  5.  
  6.     JComponent panel1 = makeTextPanel();
  7.     tPane.addTab("Text Content", panel1);
  8.  
  9.     JComponent panel2 = makeImagePanel();
  10.     tPane.addTab("Image Content", panel2);
  11.  
  12.     JComponent panel3 = makePropsPanel();
  13.     tPane.addTab("Properties", panel3);
  14.  
  15.     JComponent panel4 = makeKeysPanel();
  16.     tPane.addTab("Keys", panel4);
  17.  
  18.     return tPane;
  19.  
  20.    }
  21.   public JComponent makeImagePanel()
  22.    {
  23.     JPanel panel = new JPanel(false);
  24.     panel.setLayout(null);
  25.     panel.setBounds(100, 100, 400, 400);
  26.     BufferedImage img = null;
  27.     if (fSheet.fImageBuffer != null)
  28.      {
  29.       try
  30.        {
  31.         img = ImageImport.makeBufferImage(fSheet.fImageBuffer);
  32.        }
  33.       catch (Exception e)
  34.        {
  35.          System.out.println("Unable to make buffer for image " + e);
  36.          Displays.ShowErrorDialog("Unable to make buffer for image");
  37.        }
  38.       //ImagePanel.createAndShowGUI(img, fSheet.getFName());
  39.       panel.add(new ImagePanel(img));
  40.      }
  41.     return panel;
  42.    }
  43.  
Nov 7 '10 #1
1 2143
Although I have solved the problem for myself I do NOT like the solution.
Apparently a NULL layout will cause the painting not to be done. By specifying a GridLayout 1x1 the thing works.
Nov 7 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

11
3666
by: Tony Benham | last post by:
I have a main div on a page that contains some text plus an img which is floated right, causing the image to be placed on the right of the div with the text on the left. However the height of the...
2
2426
by: DraguVaso | last post by:
Hi, In the override of the Paint-method of a DataGridTextBoxColumn I want to show an image with BitBlt, to see what I can gain there on performance. The problem is: It doesn't show me the image...
0
3119
by: jtocci | last post by:
I'm having a big problem with CREATE RULE...ON INSERT...INSERT INTO...SELECT...FROM...WHERE when I want to INSERT several (20~50) records based on a single INSERT to a view. Either I get a 'too...
0
2198
by: John Richardson | last post by:
I have a DataGridLabelColumn I've made by overriding a DataGridColumnStyle object. (based on an MSDN article by Chris Sano). In the Paint method, I use a StringFormat object, and pass that to a...
1
4945
by: James Ramaley | last post by:
I am trying to modify the way a NumericUpDown control draws itself. I just need to hide the up/down arrows. I tried overriding both the OnPaint method and the wm_paint message inside WndProc....
3
6822
by: athirai | last post by:
Hi, I am having a Image of size width=700 and height=500, I want to reduce the image and display it within the allocated space of width=400 and height=300. I am using the following javascript...
7
2219
by: HxRLxY | last post by:
I posted a different question (Help with non-static/static problem) which was answered. I changed my inner class to a static nested class, but now I cannot create an object using that class and add...
5
8755
by: kamlesh20J | last post by:
Hello, I am trying to use HttpWebRequest to send some POST data I have accomplished this using: HttpWebRequest req = (HttpWebRequest) WebRequest.Create("http://mysite.com/index.php");...
0
1542
Sl1ver
by: Sl1ver | last post by:
Does anyone know how to cutomize the look of a standard tabbed pane or know of any other free tabbed pane .dll's i can use?
0
1129
by: hcetiner | last post by:
Hi, I downloaded CSASPNETFormViewUpload example (you can google.download.run.within a minute.database is ready to use) everything seems good. uploading an image to a sqlserver record...
0
7105
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7371
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7479
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5037
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3188
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3178
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1534
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
410
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.