473,569 Members | 2,870 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 2147
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
3672
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 div sizes to fit the text but not the image. I want the div to size in height to fit the height of the image. After searching google I found a...
2
2436
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 in the DataGrid-Cell's, but a black background... Does anybody has any idea what I am doing wrong? Thanks a lot in advance,
0
3128
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 much data for field' or the query just runs on and on til I have to restart the postmaster. I have found rules to compare mine to but people limit...
0
2203
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 Graphics.DrawString method. I am finding that the strings I am passing to the drawstring method are being manipulated: text suffixed with a "?" or...
1
4953
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. Neither way was successful. The overridden OnPaint method is not being called at all. WndProc is being called but my changes have no effect, even though...
3
6825
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 code to reduce the image in proponate ratio. if(iImageWidth > 400 || iImageHeight > 300){ while(!(iImageWidth <= 400 && iImageHeight...
7
2220
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 it to the JTabbedPane. I get a 'cannot find symbol' error, and it points to the pane.addTab method. The program works fine when I remove the nested...
5
8794
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"); req.Method = "POST"; req.ContentType = "application/x-www-form-urlencoded"; string postData = "login=value1&pwd=value2&file=filename" req.ContentLength =...
0
1546
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
1131
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 everything is okay till here. but when I Edit only textboxes and not selecting another image to upload(because I only wantto change textboxes not image)...
0
7703
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7679
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7983
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5223
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2117
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 we have to send another system
0
946
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.