Solved

Icon for JTabbedPane

Posted on 2004-04-15
5
1,646 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groupSum5 challenge 5 85
Java Jpanels and Jframe 8 33
couple of eclipse 5 38
login form jsp example 2 26
For customizing the look of your lightweight component and making it look opaque like it was made of plastic.  This tip assumes your component to be of rectangular shape and completely opaque.   (CODE)
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

803 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