Solved

Icon for JTabbedPane

Posted on 2004-04-15
5
1,650 Views
Last Modified: 2008-03-17
JTabbedPane tabbedPane = new JTabbedPane();
ImageIcon icon = createImageIcon("images/middle.gif");

JComponent panel1 = makeTextPanel("Panel #1");
tabbedPane.addTab("Tab 1", icon, panel1,
                  "Does nothing");

The above code will display the image beside the text but is't possible to display the image above or below the text?

thanks
0
Comment
Question by:Kennywen
  • 3
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 50 total points
ID: 10838745
Not without writing your own UI implementation.
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10840790
It has to work...


Try the following sample,


import java.awt.BorderLayout;
import java.awt.FlowLayout;

import javax.swing.*;

public class TabPaneTest extends JFrame
{
      public TabPaneTest()
      {
            super();
      
            initialize();      
      }
      
      private void initialize()
      {
            JPanel panel = (JPanel)getContentPane();
            panel.setLayout(new BorderLayout());
            
            JTabbedPane pane = new JTabbedPane();
            panel.add(pane, BorderLayout.CENTER);
            
            JPanel childPanel = new JPanel();
            childPanel.setLayout(new FlowLayout());
            childPanel.add(new JTextField(10));
            childPanel.add(new JLabel("Hellow how are you?"));
            
            Icon icon = new ImageIcon("C:\\Smiley.gif");
            pane.addTab("Test Pane", icon, childPanel, "Testting of image icon on tab pane");
            
            setSize(300, 300);
            setVisible(true);
            
            setDefaultCloseOperation(EXIT_ON_CLOSE);
      }

      public static void main(String[] args)
      {
            new TabPaneTest();
      }
}


>> C:\\Smiley.gif
change this to some other image which you have


I am suspecting your "createImageIcon" method.


Regards,
Muruga
0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10840798
Oops!  I misunderstood the question!

0
 
LVL 9

Expert Comment

by:mmuruganandam
ID: 10840807
U can't do that way
0
 
LVL 92

Expert Comment

by:objects
ID: 10856278
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
servlet example 11 49
hibernate example using maven 12 59
Why doesn't this text field show up on my Applet frame? 2 20
Cisco ASA: Java web start no go, asdm launcher no go 3 37
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question