?
Solved

Icon for JTabbedPane

Posted on 2004-04-15
5
Medium Priority
?
1,665 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 92

Accepted Solution

by:
objects earned 200 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

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…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
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…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month8 days, 1 hour left to enroll

765 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