Solved

Icon for JTabbedPane

Posted on 2004-04-15
5
1,640 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
Comment Utility
Not without writing your own UI implementation.
0
 
LVL 9

Expert Comment

by:mmuruganandam
Comment Utility
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
Comment Utility
Oops!  I misunderstood the question!

0
 
LVL 9

Expert Comment

by:mmuruganandam
Comment Utility
U can't do that way
0
 
LVL 92

Expert Comment

by:objects
Comment Utility
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now