Results 1 to 2 of 2
  1. #1
    greenhorn is offline Member
    Join Date
    Feb 2011
    Posts
    22
    Rep Power
    0

    Default In TabbedPane Diagrams do not appear

    I wanted to create 2 tabs and on each tab should be four diagrams. The diagrams itself works fine on a single page, but now I need to distribute them, since they are too many. I tried the following thing, but it did not seem to work.
    Java Code:
    public JPanel createDemoPanel() {
            JFrame demoPanel = new JFrame("TabbedPaneDemo");
    		JTabbedPane tabbedPane = new JTabbedPane();
    		ImageIcon icon = new ImageIcon("Month01.gif");
            JComponent panel1 = makeTextPanel("Panel #1");
            tabbedPane.addTab("Tab 1", icon, panel1,
                    "Does nothing");
            tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
            JPanel demoPanel1 = new JPanel(new GridLayout(2, 2));
    		demoPanel1.add(new DemoPanelA());
    		demoPanel1.add(new DemoPanelB());
    
            JComponent panel2 = makeTextPanel("Panel #2");
            tabbedPane.addTab("Tab 1", icon, panel2,
                    "Does nothing");
            tabbedPane.setMnemonicAt(0, KeyEvent.VK_1);
            JPanel demoPanel2 = new JPanel(new GridLayout(2, 2));
    		demoPanel2.add(new DemoPanelE());
    		demoPanel2.add(new DemoPanelF());
            return demoPanel1;
    	}
    
    protected JComponent 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;
        }
    I do not get any error message - so it should work, but it does not? :confused: I assume something pretty fundamental is not working.
    I would appreciate any hint - Thanks for your support.

  2. #2
    ozzyman's Avatar
    ozzyman is offline Senior Member
    Join Date
    Mar 2011
    Location
    London, UK
    Posts
    797
    Blog Entries
    2
    Rep Power
    4

    Default

    This is really easy with an IDE. If you download NetBeans IDE you can drag the tabbed panel on from the Tools box, add 4 JPanels to it, and edit each panel to add your diagrams. 5 minute job?

Similar Threads

  1. drag and drop for diagrams - help!
    By zoz in forum AWT / Swing
    Replies: 10
    Last Post: 12-20-2009, 07:59 PM
  2. Exporting UML diagrams to MS Visio
    By lettyh in forum NetBeans
    Replies: 0
    Last Post: 10-30-2008, 06:19 PM
  3. Another Color TabbedPane Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-26-2008, 07:37 PM
  4. Eclipse plugin for UML diagrams
    By nitingupta183 in forum Eclipse
    Replies: 3
    Last Post: 03-26-2008, 11:08 AM
  5. Help with tabbedpane
    By carl in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 07:06 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •