JTabbedPane question

Hi all,
I need a piece of advice about how using JTabbedPane. I create a JTabbedPane within there are 3 tabs grouped in a undertabpane component and added to YearPane ( the main JTabbedPane) by the addTab method.
class YearPane extends JTabbedPane {
public YearPane() {
setBorder(BorderFactory.createLoweredBevelBorder());
public void addYearTab() {
JTabbedPane undertabpane = new JTabbedPane();
undertabpane.setBorder(BorderFactory.createEtchedBorder());
undertabpane.addTab("euro", null);
undertabpane.addTab("dollar", null);
undertabpane.addTab("chf", null);
undertabpane.addTab("graphic", null);
this.addTab(title, undertabpane);
So, My question is how can I interact with the added tabs like "euro", "dollar" or "chf" ? How can I put or get informations to or from only one of this tab ? By example, is it possible to put a JTextField only inside the "euro" tab ?
Thanks for your help.

undertabpane.addTab("euro", null);
undertabpane.addTab("dollar", null);
undertabpane.addTab("chf", null);
undertabpane.addTab("graphic", null);
this.addTab(title, undertabpane);
So, My question is how can I interact with the added
tabs like "euro", "dollar" or "chf" ? How can I put or
get informations to or from only one of this tab ? By
example, is it possible to put a JTextField only
inside the "euro" tab ?Instead of passing null for the component to the addTab() method calls create a component and pass it to addTab(). E.G. Create a JPanel that contains the JTextField objects that you want to display on the "euro" tab and pass ito the the "euro" addTab() call.

Similar Messages

  • JMenu and JTabbedPane questions

    Hello I got 2 questions :
    1) Is it possible to change the icon of JMenu when the mouse cursor is on it ? setRolloverIcon function doesnt work in this case, like it does for the JButton.
    2) When I create my application I got 1 JTabbedPane object visible. Now, every time I click a selected JMenuItem, I wanna add another JTabbedPane object to the window. So in the class MyMenu I got this code in actionListener:
    if(arg.equals("menu1")) {
         JTabbedPane tabbedPane = new JTabbedPane();
         tabbedPane.addTab("tab", null, null, "nothing");
         frame.getContentPane().add(tabbedPane);
    The problem is that it doesnt appear on the window, but instead when I resize it, there is a vertical line in the place where the right "edge" of the old window was.
    Can anyone tell me what do I do wrong ?
    Thx in advance.

    Actually I dont know but the simpliest way seems to be subclassing the menu Item, and listen for mouse events. When you learn a better way to do it you can change your code :)
    Java always allowed me to do such tricks :)

  • JTable and JTabbedPane questions

    I have an application which has some JTabbedPanes setup, one of which has a table on it.
    What i'm after is a way of having a user select a row from the table and in doing so this will send them to another tabbedpane.
    So what i need is a way of assigning each row an ID number, then being able to extract this ID, and being able to switch to a new tab without having to click on the tab itself.
    I hope someone can point me in the right direction.
    One more question as well.
    I'm designing a networked bulletinboard application (using javaspaces) and i'm having an implementation issue.
    At the moment I can list all the topics in a table which just contains |the author, topic title and date created|.
    I'm having trouble thinking of a good way of displaying the actuall topic itself (and multiple follow-up posts).
    I was thinking of doing this in another table, but i couldnt find a way of customizing the layout enough to display formatted text. So i thought I would just do a loop of JTextAreas for each topic.
    Something along the lines of:
    while (i < number_of_posts)
    Create_JTextArea(post[i]);
    Do you think this would be a suitable way of implementing this? Or is there a better way that i'm missing?

    So what i need is a way of assigning each row an ID numberStore the ID number in the TableModel. You then just remove the TableColumn from the TableColumnModel and the ID will not be displayed in the table. You then simply use model.getValueAt(...) to reference the ID.

  • JTabbedPane questions

    Hi Everyone,
    I understand the JTabbedPane in Swing is rather basic, but I have the need to add some more extended functionality:
    1) Flash a given tab
    2) Add a clickable button to a tab (maybe in addition to an icon)
    3) Not display the tabs if there is only one item in the tabbed pane
    4) Popup menu on a per-tab basis
    5) Add button(s) in the "trough" of the tab (the area in the tabbed pane, outside of the tab but not in the content pane)
    6) ... ? Maybe others
    What is the best way to achieve these kinds of things? Are there any JTabbedPane extensions out there? If not, how would I do it myself?

    If not, how would I do it myself? Search the forums for examples and modify the suggestions.
    1) Flash a given tab
    Use a timer to change the background color of a selected tab.
    2) Add a clickable button to a tab (maybe in addition to an icon)
    I'm not sure if I've seen any solutions with buttons, but I have seen solutions with clickable icons to close a tab. I think the search keywords where "jtabbedpane close icon"
    3) Not display the tabs if there is only one item in the tabbed pane
    Simple programming problem. Use the removeTab method
    4) Popup menu on a per-tab basis
    Add a MouseListener to the tabbed pane:
    http://forum.java.sun.com/thread.jspa?threadID=615004&tstart=75
    5) Add button(s) in the "trough" of the tab (outside of the tab but not in the content pane)
    I'm sure there's a better way, but here is one way to get you started:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.plaf.*;
    public class TabbedPaneWithText extends JFrame
         public TabbedPaneWithText()
              JTabbedPane tabbedPane = new JTabbedPane()
                   public void paintComponent(Graphics g)
                        super.paintComponent(g);
                        Rectangle lastTab = getUI().getTabBounds(this, getTabCount() - 1);
                        int tabEnd = lastTab.x + lastTab.width;
                        String text = "Some Text";
                        FontMetrics fm = getFontMetrics( getFont() );
                        int stringWidth = fm.stringWidth( text ) + 10;
                        int x = getSize().width - stringWidth;
                        if (x < tabEnd)
                             x = tabEnd;
                        g.drawString(text, x + 5, 18);
              tabbedPane.add("1", new JTextField("one"));
              tabbedPane.add("2", new JTextField("two"));
              getContentPane().add(tabbedPane);
         public static void main(String args[])
            TabbedPaneWithText frame = new TabbedPaneWithText();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo( null );
            frame.setVisible(true);
    }

  • Simple JTabbedPane question

    This should be simple:
    I use a JTabbedPane in my application. On one tab I have everything correctly laid out (tables, lables, ...). The other
    tab is currently empty.
    I would now like to get a JPanel from a different application to this second tab.
    This should be easy by importing necessary class files and then pointing to the JPanel.
    Like this:
    myTabbedPane.addTab("ABC", myPanel);where "myPanel" is located in a different application in a different directory on my PC.
    How to get it done?
    I can also post the whole code here if necessary.
    OK!
    AUlo

    Not actually.
    The case:
    I have a project where there are different inner-frames in one JFrame. Each innerframe is a separate appliacation, doing different things. I first created two separate applications which now need to be united. I therefore modified the second one to have a CardLayout, JTabbedPane. The first Tab of the pane includes the original second application, but the second Tab is empty.
    I would now like to get the first app displayed on the second tab. And the first app is located in a physically different place in my computer than the second one.
    So I import the classes to the first app to the second one, but how do I refer to a specific JPane when I would like to include it on the JTabbedPane?

  • JTabbedPane question. Please give advice.

    I am writing some applicaiton which includes a jTabbedPane.(with 4 tabs)
    Say I have tab A,B,C,D. Which contains panelA, panelB, panelC and panelD under each tab.
    I would like to refresh corresponding panel when user click on the tab.
    I tried panelB's focusGained event, but it doesn't work right. I would have to click on some control of other panel for it to work.
    How do I trigger a function which user click on B tab? not some control in panelB.
    I am new to swing. please give some advice.
    Thanks

    Add a changeListener to your JTabbedPane which forwards an update to your panels when the current tab is changed,
    ... or ...
    put your updating in a overridden setVisible() in your panels, since the JTabbedPane uses visibility to control which tab gets shown.

  • Sharing objects across Tabs of a JTabbedPane

    I don't know whether this is an Object-Oriented design question or a JTabbedPane question.
    I'm pretty new to Java, so be patient!
    I wish to have a JTabbedPane with a tab to do 'Import' of data, and a tab to do 'Export' of data (the SAME data which was imported).
    How do I share the data between the 2 tabs? It seems the data belongs at the JFrame level, but then how does the data in each tab access it? In other languages I would pass a reference to the data object in the window to each tab. Or how do I get (or set) the data when the tab changes? And how do I know when the tab changes?
    I know if I had one tab with an import/export functionality then I could declare the Collection within that panel.
    Help!!!
    Thanks ;)

    here's a starter
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.*;
    class Testing
      int selectedIndex = 0;
      public void buildGUI()
        final JTabbedPane tp = new JTabbedPane();
        tp.setUI(new javax.swing.plaf.metal.MetalTabbedPaneUI(){
          protected void paintTab(Graphics g,int tabPlacement,Rectangle[] rects,int tabIndex,Rectangle iconRect,Rectangle textRect){
            if(tabIndex == selectedIndex) super.paintTab(g,tabPlacement,rects,tabIndex,iconRect,textRect);
        tp.addChangeListener(new ChangeListener(){
          public void stateChanged(ChangeEvent ce){
            selectedIndex = tp.getSelectedIndex();
        for(int x = 0; x < 5; x++) tp.addTab(""+(char)(x+65),new JPanel());
        tp.setPreferredSize(new Dimension(200,200));
        JFrame f = new JFrame();
        f.getContentPane().add(tp);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }

  • Using events (?) to share data between tab pages

    I don't know whether this is an event question or an Object-Oriented design question or a JTabbedPane question.
    I'm pretty new to Java, so be patient!
    I wish to have a JTabbedPane with a tab to do 'Import' of data, and a tab to do 'Export' of data (the SAME data which was imported). Now, how do I share the data between the 2 tabs?
    It seems the data belongs at the JFrame level, but then how does the data in each tab access it? In other languages I would pass a reference to the data object in the window to each tab.
    Or how do I get (or set) the data when the tab changes? And how do I know when the tab changes?
    I think I need to set trigger some sort of event to the parent window, who I suppose has a listener, and then it can then query the appropriate pane? If so, I'm not sure what sort of event trigger I should be using, where etc.
    I know if I had one tab with an import/export functionality then I could declare the Collection within that panel.
    Help!!!
    Thanks ;)

    I think this is an OO design question.
    You basically have two views (the two panes) of the same data. So I'd suggest the Observer pattern (see the Design Patterns book) where one model holds the data and the model is observed by several views.

  • A question about JTabbedPane?

    jScrollPane1.getViewport().add(jTextArea, null);
    jScrollPane1.setRowHeaderView(jLineArea);
    jTabbedPane1.add(jScrollPane1, "File");
    I use JTabbedPane to show more than 1 files, each tab includes one JScrollPane,which in turn contains a JTextArea (show file content) and the other JTextArea(show line).
    Now i want to insert a comment in one of the files. First of all,i want to get the object of the JTextArea, then i can use JTextArea method "insert" to do this. However, I don't know how to get the object of the JTextArea in the JScrollPane of the JTab? i wish someone can help me to solve this problem.
    thanks in advance!

    You could try something like this to get the textarea in the scrollPane;
    JPanel panel = new JPanel();
    JTextArea ta = new JTextArea(int, int);
    JScrollPane sp = new JScrollPane(ta);
    panel.add(sp);
    tp.addTab("tab", null, panel);
    ...

  • A few questions regarding BorderLayout, JTabbedPane and JFrame.

    Hello,
    I'm after a little help. I want to know the following:
    1)
    How to you add a gap on the far left and far right so that the components at PAGE_START and PAGE_END when using BorderLayout have visible borders. I have tried the Constructor which lets you specific hGap and vGap but this does not work, I assume it is only when butting components together.
    2)
    When using JTabbedPanes with option
    setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT );is there a way to control painting of the Scroller which scrolls through the tabs? I am currently using a custom UI (subclassing BasicTabbedPaneUI) to paint my tabs however I can not work out how to paint the Scroller.
    3)
    How to I add a custom JFrame Border and remove the blue XP border? Do I need to setUndectored and add my own Icons? I want to achieve something along the lines of what you can see here
    https://substance.dev.java.net/images/screenshots/themes/skins/business1.png
    I will be using a custom L&F although not Substance and currently my L&F does not paint the border/Decorations on the Frame.
    Here is a picture of my app, outlining my problems.
    http://img91.imageshack.us/my.php?image=exampletz1.jpg
    A nudge in the right direction on any of these would be great.
    Thanks

    Hello,
    I'm after a little help. I want to know the
    following:
    1)
    How to you add a gap on the far left and far right so
    that the components at PAGE_START and PAGE_END when
    using BorderLayout have visible borders. I have
    tried the Constructor which lets you specific hGap
    and vGap but this does not work, I assume it is only
    when butting components together. agree vgap and hgap increase the vertical and horizontal distances between objects added to the panel that uses border layout.
    Why not do setBorder(BorderFactory.createEmptyBorder(.....) to do this for you?

  • JTabbedPane focus question with buttons

    Hi. I have a JTabbedPane with an OK button on each pane. clicking the OK button will remove that pane from the JTabbedPane. But if I don't move the mouse, and click the OK button to remove the next pane, I have to click TWICE, OR move the mouse just a little bit before clicking, then it will go away. Here's the code. How can I make this work so one click will do it? Thanks...
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class TabbedFocusTest extends JPanel implements ActionListener {
    private JTabbedPane tabbedPane;
    private JPanel panel1;
    private JPanel panel2;
    private JPanel panel3;
    private JPanel panel4;
    public TabbedFocusTest() {
    ImageIcon icon = new ImageIcon("images/middle.gif");
    tabbedPane = new JTabbedPane();
         panel1 = new JPanel();
    Component text1 = makeTextPanel("Blah");
         JButton button1 = new JButton("OK");
         button1.setActionCommand("1");
         panel1.setLayout(new BorderLayout());
         panel1.add(text1, BorderLayout.NORTH);
         panel1.add(button1, BorderLayout.SOUTH);
    tabbedPane.addTab("One", icon, panel1, "Does nothing");
    tabbedPane.setSelectedIndex(0);
         panel2 = new JPanel();
    Component text2 = makeTextPanel("Blah 2");
         JButton button2 = new JButton("OK");
         button2.setActionCommand("2");
         panel2.setLayout(new BorderLayout());
         panel2.add(text2, BorderLayout.NORTH);
         panel2.add(button2, BorderLayout.SOUTH);
    tabbedPane.addTab("Two", icon, panel2, "Does twice as much nothing");
         panel3 = new JPanel();
    Component text3 = makeTextPanel("Blah 3");
         JButton button3 = new JButton("OK");
         button3.setActionCommand("3");
         panel3.setLayout(new BorderLayout());
         panel3.add(text3, BorderLayout.NORTH);
         panel3.add(button3, BorderLayout.SOUTH);
    tabbedPane.addTab("Three", icon, panel3, "nothing 3");
         panel4 = new JPanel();
    Component text4 = makeTextPanel("Blah 4");
         JButton button4 = new JButton("OK");
         button4.setActionCommand("4");
         panel4.setLayout(new BorderLayout());
         panel4.add(text4, BorderLayout.NORTH);
         panel4.add(button4, BorderLayout.SOUTH);
    tabbedPane.addTab("Four", icon, panel4, "Nothing 4");
         button1.addActionListener(this);
         button2.addActionListener(this);
         button3.addActionListener(this);
         button4.addActionListener(this);
    //Add the tabbed pane to this panel.
    setLayout(new GridLayout(1, 1));
    add(tabbedPane);
    protected Component makeTextPanel(String text) {
    JPanel panel = new JPanel(false);
    JLabel filler = new JLabel(text);
    filler.setHorizontalAlignment(JLabel.CENTER);
    panel.setLayout(new GridLayout(1, 1));
    panel.add(filler);
    return panel;
    public void actionPerformed(ActionEvent e) {
         System.out.println(e.getActionCommand());
         if (e.getActionCommand().equals("1"))
         tabbedPane.remove(panel1);
         if (e.getActionCommand().equals("2"))
         tabbedPane.remove(panel2);
         if (e.getActionCommand().equals("3"))
         tabbedPane.remove(panel3);
         if (e.getActionCommand().equals("4"))
         tabbedPane.remove(panel4);
    public static void main(String[] args) {
    JFrame frame = new JFrame("TabbedFocusTest");
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {System.exit(0);}
    frame.getContentPane().add(new TabbedFocusTest(),
    BorderLayout.CENTER);
    frame.setSize(400, 125);
    frame.setVisible(true);

    Thanks for the suggestion - I added this line at the end of actionPerformed() but it did not help:
    tabbedPane.getSelectedComponent().requestFocus();

  • Questions on events in a multi-class GUI

    I have a GUI application that is constructed as follows:
    1. Main Class - Actually creates the JFrame, contains main method, etc.
    2. MenuBar Class - Constructor creates a new JMenuBar structure and populates it with various JMenus and JMenuItems. A new instance of this class is instantiated in the Main Class to be used in the setMenuBar() method.
    3. ContentPane Class - Constructor creates a vertical JSplitPane. A new instance of this class is instantiated in the Main Class to be used in the setContentPane() method.
    4. BottomPane Class - Constructor creates a JPanel and populates it with various stuff. A new instance of this class is instantiated in the Content Pane Class to be used as the bottom pane in the vertical JSplitPane.
    5. TopPane Class - Constructor creates a horizontal JSplitPane and populates the left pane with a JScrollPane containing a JList. A new instance of this class is instantiated in the Content Pane Class to be used as the top pane in the vertical JSplitPane.
    6. TabbedPane Class - Constructor creates a JTabbedPane. A new instance of this class is instantiated in the Top Pane Class to be used as the right pane in the horizontal JSplitPane.
    7. DisplayPane Class - Constructor creates a JPanel. A new instance of this class is instantiated in the Tabbed Pane Class as the first tab. The user has the ability to click at points in this pane and a dialog box will pop up prompting the user for a string. Once the user enters something and clicks "OK", an instance of a custom Java2D component that I've created will be added to the DisplayPane where the user had clicked, with the string the user inputted being used as its name. The user can then drag the component around, enter a key combination to display all the names, etc.
    8. Custom Java2D Component Class - Constructor creates my custom Java2D component. Instances of this are added to the Display Pane Class, as I have described.
    Now, originally, I was going to ask "How do you work with events between these multiple classes?" but I have solved half of that problem myself with the following class:
    9. Listener Class - A new instance of this class is declared in the constructor of the Main Class, and is thus passed down through the GUI hierachy via the constructors of the various classes. I then use the addActionListener() method on various components in the other classes, and then the Listener Class can capture an event using the getActionCommand() method to figure out what fired the event.
    So that covers the "How do I capture events in multiple classes?" question. Now I'm left with "How do I affect changes on those classes based on events?"
    For example: In my MenuBar class, I have a "Save" menu item. When this is clicked, I want to declare a new JFileChooser and then use the showSaveDialog() method, which throws up a dialog for saving a file. The problem is, the showSaveDialog() method takes a Component which is the parent frame. Obviously the Listener Class is not a frame. I want to use the Main Class as the parent frame. How would I do this sort of thing?
    Another example: In my MenuBar class, I have a "New" menu item. For now, I want this to invoke a method in the DisplayPane Class that erases all of my custom Java2D components that have been made, thus giving the user a clean slate. How would I give my Listener Class access to that method?
    A final example: Every time the user adds one of my custom Java2D components, I want that component's name to be added to the JList that is in my TopPane class. Vice versa with deleting a component: its name should be removed from the JList. How would I listen for new components being added? (A change listener on the pane? One on the ArrayList<> that contains all of the components? Something else?) And, of course, how would I give the Listener Class the ability to change the contents of the JList?
    One idea I've come up with so far is to instantiate a new instance of each of my GUI classes in the Listener class, but that doesn't really make much sense. Wouldn't those be new instances that are totally separate from the instances the rest of my program is using? Another thought is to make the Listener Class an internal class inside the Main Class so that it can use the accessor methods of the GUI classes, but a.) I would like to avoid stuffing everything in one class and b.) this brings up the question of "How would I get an accessor method that is in a class that is two or three deep in the hierarchy?" (.getSomething().getSomethingInsideThat().getSomethingInsideTheInsideThing()?)
    Help with answering any or all of my questions would be much appreciated.

    Hrm. At the moment, for my first attempt, I'm doing something similar, it just strikes me as quite unwieldy.
    Start of Listener class, with method for setting what it listens to. (I can't use a constructor for this because the MenuBar and the ContentPane take an instance of
    this Listener class in through their constructors. You can't pass the Listener in through their constructors while simultaneously passing them in through this
    Listener's constructor. That would be an endless cycle of failure. So I just instantiate an instance of this Listener class, then pass it in through the MenuBar and
    ContentPane constructors when I instantiate instances of them, and then call this setListensTo() method.)
    public class Listener implements ActionListener
      private MenuBar menuBar;
      private ContentPane contentPane;
      public void setListensTo(MenuBar menuBar, ContentPane contentPane)
        this.menuBar = menuBar;
        this.contentPane = contentPane;
      }The part of my actionPerformed() method that does some rudimentary saving, which I will make more complicated later:
    else if (evt.getActionCommand() == "saveMenuItem")
      JFileChooser fileChooser = new JFileChooser();
      int returnVal = fileChooser.showSaveDialog(menuBar.getTopLevelAncestor());
      if (returnVal == JFileChooser.APPROVE_OPTION)
        File file = fileChooser.getSelectedFile();
        ArrayList<Node> nodes = contentPaneClass.getTopPaneClass().getTabbedPane().getDisplayPane().getNodes();
        try
          BufferedWriter out = new BufferedWriter(new FileWriter(file));
          for (int i = 0; i < nodes.size(); i++)
            Node node = nodes.get(i);
            out.write(node.getIndex() + "," + node.getXPos() + "," + node.getYPos() + "," + node.getName());
            out.newLine();
          out.close();
        catch (IOException e)
          //To be added                    
    }That part that seems unwieldy is the
    ArrayList<Node> nodes = contentPaneClass.getTopPaneClass().getTabbedPane().getDisplayPane().getNodes();The reason I'm using a separate Listener class is because if I put, say, the actions for the MenuBar in the MenuBar class, and then want to save stuff in the JPanel
    at the bottom of the hierachy, I would have to go up from the MenuBar into the JFrame, and then back down the hierachy to the JPanel, and vice versa. Kind of like
    walking up a hill and then down the other side. I imagine this would be even more unwieldy than what I'm doing now.
    On the plus side, I am making progress, so thanks all for the help so far!

  • Urgent - How to add a new control instead of tabs in JTabbedPane

    Hi,
    Please give me an idea or a sample program for how to add a new control
    in JTabbedpane instead of tabs that means overlay any Java controls or pane
    in the tabpane empty place next to tabs

    "Urgent" is not relevant to the question. Your question is no more important than anybody elses.
    My answer in this posting show a limited solution:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=636289
    Otherwise I suggest you try using a layered pane approach:
    http://java.sun.com/docs/books/tutorial/uiswing/components/layeredpane.html

  • How to address a component in a background tab in a JTabbedPane

    Hello and greetings for everybody, this is my first post here. I have a question:
    I want to write a simple little chat program, which makes use of a JTabbedpane, and if the user gets a private message from another user, it would open a new tab with the given user's nick in the tab title, and would create a JTextArea on the opened tab and write the message to that specific JTextarea. My question: Is it possible to write on the JTextarea, while the given tab is in the background? How can I address that specific JTextarea on the specified tab?
    Thank you very much in advance for the answers, and I wis you all a nice day!

    // create a Map<String, JTextArea>
    public static void privMsg(String nick) {
            if (mainwindow.tabpane.indexOfTab(nick)==-1) {  // look for the nick in the map, not on the tabbedpane (if map.get(nick) != null
                javax.swing.JScrollPane panel=new javax.swing.JScrollPane();
                javax.swing.JTextArea msgBox=new javax.swing.JTextArea();
                msgBox.setEditable(false);
                msgBox.setAutoscrolls(true);
                msgBox.setLineWrap(true);
                panel.setViewportView(msgBox);
                mw.tabpane.addTab(nick,panel);
                mw.tabpane.setSelectedIndex(mw.tabpane.indexOfTab(nick));
                msgBox.append("Private conversation: "+nick+"\n");
                // add the nick and the msgBox to the map
            // if the nick already has been added to the map, (meaning there's already a tab open for that nick), then get that textpane and write to it. That's the basic idea behind MVC, which you'd do yourself a huge favor by reading into. You separate the display of the data from the data itself. That way when you update the data (Model), you don't have to deal with gui code (View). The actions the user takes are also separated into the Controller.

  • JTabbedPane: Components before and after the tabs themselves.

    I want to make Google Chrome..!
    Well, really, I want to have GUI stuff up in the title pane. In particular, I want the tabs of a TabbedPane up there.
    I've concluded that the easiest way to accomplish this (hopefully in a somewhat LaF-neutral way) is to set the frame to be undecorated, and instead implement my own frame with handling and all. I'd set a JFrame undecorated, and put a JTabbedPane over the entire thing, sticking the application icon to the left of the tabs, and the minimize, maximize, close buttons to the far right of the tabs themselves.
    If anyone have any other suggestions to this initial problem, I would seriously appreciate to hear about them.
    But given the above solution: How would I go about getting a component to the left of the tabs, and some other components to the right of the tabs, of a JTabbedPane? A LaF-neutral solution would be very much appreciated - but I have faint hopes here, so pointers for how to accomplish this using LaF-tricks will be appreciated too.
    I've seen that laf-widget from kirill, https://laf-widget.dev.java.net/, does something like it (the magnifying-glass icon to the left of the tabs) for several LaFs. However, I must admit that I'm not yet well enough versed to understand how he does it - and also it seems like a somewhat complicated process, whereby one "physically" change the LaF in question (bytecode manipulates it), injecting the laf-widget stuff (and I still don't know how the JTabbedPane or TabbedPaneUI is modulated to inject that icon).
    Any help or pointers will be much appreciated!
    Thanks,
    Endre.

    Could you elaborate slightly on that? I don't get your "what's left" idea..?
    I think the JTabbedPane should have this functionality built-in. It is a truly obvious need, to the extent that it has had to be solved several times by others.
    From an answer to this problem on StackOverflow: The JideTabbedPane from the Jide open source parts have an setTabLeadingComponent. However, Jide doesn't manage to follow the active LaF (the installs its own UI delegate), so I don't instantly want to jump on it.

Maybe you are looking for