Help on JtabbedPane and JFrame

Hi everyone, i am self studying java and I am following tutorials I got from Sun developer (the Divelog application). However, i can't figure out the following problem:
1. The field DiveLog.dllframe is never read locally
2. The field DiveLog.tabbedPane is never read locally
3. The import java.awt is never used
And here's my code...
package divelog;
import javax.swing.*;
import java.awt.*;
//import java.awt.event.*;
//class defining application framework
public class DiveLog
private JFrame dlframe; //not assigned yet
private final JTabbedPane tabbedPane; //not assigned yet
public DiveLog()
{ // Opens constructor
// Creates a frame object to add to
// the application GUI components.
dlframe = new JFrame("A Java Technology Dive Log");
} // Closes main method
} //Ends class DiveLog
I hope guys that you can help me out... Thanks!

when you declare the final variables, it should be initialized otherwise you will get error
private final JTabbedPane tabbedPane; //not assigned yet should be
private final JTabbedPane tabbedPane = new JTabbedPane()

Similar Messages

  • 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?

  • Help with JDialog and JFrame

    I have a class that extends JDialog to display images in a slide show. I use the action performed method of a button in my main Jframe Application to start the slideshow .
    When the button is clicked the JDialog opens multiple windows and the images arent displayed properly at all . But when I tested the slideshow of Jdialog separately , it works.
    Here is the code of the Jdialog part
    import java.awt.*;
    import javax.swing.*;
    import java.util.*;
    import java.awt.event.*;
    public class Test extends JDialog implements ActionListener
    {  private Image img; 
    private     JMenuBar     menuBar;
    private     JMenu          menuStart;
    public Vector images = new Vector();
    public Test()
    for (int i = 1; i < 8; i++)
    {      images.add(new ImageIcon("gty"+i+".jpg").getImage());  
    menuBar = new JMenuBar();
         setJMenuBar( menuBar );
         menuStart = new JMenu( "Start" );
         menuStart.setMnemonic( 'S' );
         menuStart.addActionListener(this);
         menuBar.add( menuStart );
    setSize(600, 600);
    setVisible(true);
    showImages(images);
    private void showImages(Vector images) {
    for (int i = 1; i < images.size(); i++)
    img = (Image) (images.elementAt(i));
    int imgWidth = img.getWidth(this);
    int imgHeight = img.getHeight(this);
    setSize( imgWidth, imgHeight );
    JLabel temp=new JLabel(new ImageIcon(img));
    this.getContentPane().add(temp);
    pack();
    setVisible(true);
    try { Thread.sleep(2000);
    } catch (Exception e) {} //do nothing
    getContentPane().remove(temp);
    pack();
    setVisible(true);
    public void actionPerformed( ActionEvent event )
    public static void main(String[] arghs)
    {//new Test(null,true);
    In the main application I just gave created an object of this type test
    i.e new Test();
    I have tried changing the constructor of the Jdialog to include parent frame and modal , but it still dosen't work . Help !

    when you declare the final variables, it should be initialized otherwise you will get error
    private final JTabbedPane tabbedPane; //not assigned yet should be
    private final JTabbedPane tabbedPane = new JTabbedPane()

  • JTabbedPane and JFrame

    Hi Friends
    In my application i have a tabbed pane in which can change its content dynamically.
    Their is one senario in which i have replace a tab-panel from a JFrame only.
    But my question is , is it possible to add JFrame in JTabbedPane.
    Thanks in advance
    Sunny Jain

    In my application i have a tabbed pane in which can
    change its content dynamically.ok
    Their is one senario in which i have replace a
    tab-panel from a JFrame only.
    I don't understand that statement.
    But my question is , is it possible to add JFrame in
    JTabbedPane.I think that I may understand this, but am confused as to why anyone would want to do this. Are you trying to display a JFrame from within a JTabbedPane? I don't think that this can be done, and more importantly, I don't think that this SHOULD be done. A JFrame is a top-level pane that must stand on its own. Again, why would you even want to consider this?

  • JTabbedPane and InsertTab method

    Hi at all!!!Sorry for my bad english!!
    For a university project I want to implement a copy of notepad. Only I want to manage a more document and I think that it is possible through the JTabbedPane and it works.
    But I don't know how I can implement a button that add/remove a tab during the runtime.
    Is there someone that can help me???
    thank u
    giuliano

    Your main window should have [AddNewTab] and [RemoveTab] buttons.
    In their event handler, launch a dialog and accept required user inputs.
    After you dispose the dialog, call JTabbedPane#add(), addTab() or remove().

  • JTabbedPane and removeTabAt() method

    Hello,
    I use in my application a JTabbedPane and i want allow the user to remove a tab of this JTabbedPane. When the JTabbedPane change i need to perform some traitement.
    So i use a ChangeListener to be informed of all changes of my JTabbedPane.
    But, when i removed a tab which is not in last or first position i'm not informed by the change.
    Thanks for your help.
    Guiguch

    I had the same problem. I fixed it by overriding the remove() method to fire a StateChanged event:
    tabbedPane = new JTabbedPane()
         public void remove(int tab)
              super.remove( tab );
              int after = getSelectedIndex();
              //  The selected tab remained the same after this remove, consider
              //  it a state changed
              if (after == tab)
                   fireStateChanged();
    };

  • Dynamic resize of JButton and JFrame in response to Font

    Im supposed to increase the font size of the text with JButton by 1 within each click.
    Eventually the text becomes shorter and less visible like WORD becomes WOR... then WO... etc
    How to make the button always resize with text so that the text is fully visible and JFrame always resize with button so that the button doesn't change its position within the Frame ?
    edit:
    I managed to make buttons resize with increasing font
    by making
    JButton b = new JButton("button");
    b.setHorizontalTextPosition(CENTER);
    b.setVerticalTextPosition(CENTER);However the window size doesnt increase with components ;[
    any help would be appretiated.
    Edited by: pimpcane on Dec 11, 2007 12:16 PM

    Ok I managed to get it working moreless by
    adding pack() to the actionPerformed(...) function
    public void actionPerformed(ActionEvent e)
                 int index = Integer.parseInt(e.getActionCommand());
              int size = buttons[index].getFont().getSize();
              size++;
              buttons[index].setFont(new Font(name, style, size));
              pack();
    }The problem is in the task im given it is forbidden to use pack();
    Is there any other method to obtain the same result of JFrame resizing dynamically in response to components resize ?
    Edited by: pimpcane on Dec 12, 2007 12:13 PM
    Edited by: pimpcane on Dec 12, 2007 12:15 PM

  • JTabbedPane and focus problem.

    Hello. I currently have a JTabbedPane which contains the various panels that make up different tabs. These tabs are extensions of panels, and are seperate classes imported into the class which contains my JTabbedPane and then added. The frame which conatins my JTabbedPane also has a button, which when pressed I wish it to look at the tab which is currently active, and call a method from the class which this tab refers to. The problem is that I don't know how to get my button to determine which tab is currently active. Any help will be gratefully recieved.

    Use getSelectedComponent() or getSelectedIndex() of your JTabbedPane object.

  • JTabbedPane, and JPanel.

    Hi im going thrue swing tutorials here on sun. And wonder a bit about hierarchy. I use JTabbedPane and every class have there own JPanel that i add to the extended JPanel. I show below with example.
    In Main class
      public JFrame mstFrame() {
            JFrame frame = new JFrame("Main Frame");
            JTabbedPane mstPane = new JTabbedPane();
            mstPane.addTab("Start", new StartPage());
            frame.add(mstPane);
            frame.setVisible(true);
            return frame;
        }In StartPage Class
    public class StartPage extends JPanel {
        JPanel createProjectPanel = new JPanel(new GridBagLayout());
         GridBagConstraints c = new GridBagConstraints();
         JScrollPane createCustomerPane = new JScrollPane();
         c.gridy = 1; // second row
         c.gridx = 0; // first cell
         createProjectPanel.add(createCustomerPane ,c);
    add(createProjectPanel);Does this destory the hierarchy, or is it okey to do it this way?

    It makes sense to have each tab represented by a panel, so I don't reallly understand the question.
    public class StartPage extends JPanel
        JPanel createProjectPanel = new JPanel(new GridBagLayout());
        add( createProjectPanel );However, it is unecessary to create a second panel since your class already extends JPanel. Just add the scrollPane directly to the class.
    setLayout( new GridBagLayout() ):
    JScrollPane createCustomerPane = new JScrollPane();
    add(createCustomerPane, c);

  • Need help with JTabbedPane

    hi please i need some help with JTabbedPane i've commented the line giving me the problem i'm trying to initialize Tabs but there's an error on it
    import java.awt.BorderLayout;
    import java.util.Vector;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTabbedPane;
    import model.ContactModel;
    import view.ContactAddView;
    import controller.ContactController;
    public class PersonalContact extends JFrame
         private ContactModel          contactModel;
         private ContactAddView     contactAddView;
         private ContactController     contactController;
         public PersonalContact()
              super ("Personal Contact Manager Demo");
              setSize(580,300);
              getContentPane().setLayout(new BorderLayout());
              contactModel          = new ContactModel();
              contactModel.generateTestData(10);
              Vector searchTest = contactModel.searchMultipleContacts("Surname7");
              contactModel.printAllFoundContactSet(searchTest);
              contactAddView     = new ContactAddView();
              contactController     =     new ContactController(contactModel, contactAddView);
              //JTabbedPane Tabs = JTabbedPane(JTabbedPane.TOP);
              JTabbedPane Tabs = JTabbedPane();
              Tabs.addTab("Add", contactAddView);
              Tabs.addTab("Update", new JPanel());
              Tabs.addTab("View", new JPanel());
              Tabs.addTab("Search", new JPanel());
              Tabs.addTab("Delete", new JPanel());
              getContentPane().add(Tabs);
              getContentPane().add(contactController, BorderLayout.SOUTH);
              setResizable(false);
              show();
         public static void main (String [] argv)
              PersonalContact     Application = new PersonalContact();
    }

    You're missing the new keyword in a couple of places.

  • Difference Frame and JFrame

    can somebody help me to explain the difference between Frame and JFrame OR maybe you can put a link of (java.sun.com) so that i may understand it!
    thanx!

    Start here,
    [url http://java.sun.com/docs/books/tutorial/uiswing/start/swingIntro.html#awt]How Are Swing Components Different from AWT Components?
    continue with [url http://java.sun.com/docs/books/tutorial/uiswing/converting/index.html]Converting to Swing

  • I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    I need help to find and open a job app that I exported, was able to fill out and sign and saved and now can't open it? What did I do wrong?

    What file format did you export it to?

  • HT4623 please help - installed IOS7 and now I am having problems playing Words Free on my Iphone.  It gives me a pop up telling me to connect to ITunes but will not connect.  Cannot get out and have to continually shut down my phone and start over.

    please help - installed IOS7 and now I am having problems playing Words Free on my Iphone.  It gives me a pop up telling me to connect to ITunes but will not connect.  Cannot get out and have to continually shut down my phone and start over.

    Hi, jeantwin.
    Thank you for visiting Apple Support Communities.
    The steps in the article below may help you resolve the issue with push notifications.
    iPad and iPod touch: Unable to use YouTube or Push notifications
    http://support.apple.com/kb/ts3305
    If the issue persists, try signing out of your Apple ID and then sign back in.
    iOS: Changing the signed-in iTunes Store Apple ID account
    http://support.apple.com/kb/HT1311
    Cheers,
    Jason H.

  • Does any update help to install and run myFaces components?

    Hi.
    I have JSC trial. And didn't make update.
    I can't install myFaces component library. Why?
    Does any update help to install and run myFaces components, and other component library?
    Thanks.

    Hi,
    The following thread could be of help for you:
    http://swforum.sun.com/jive/thread.jspa?forumID=123&threadID=48666
    Cheers :-)
    Creator Team

  • Need help to import and syncronize HCM pagelets with Interaction Hub, how can I do that?

    Hi,
    I need help to import and synchronize HCM pagelets with Interaction Hub, how can I do that? The default page "Select Remote Content" of the WorkCenter "Unified Navigation WorkCenter" is not working as well, when I run the import/sync button I get the following error message:
    Integration Gateway: General Connection Failed (158,10836)
    This error is thrown when there is no valid response.
    Possible errors include:
    Bad gateway URL
    Sync Service Timeout set and Service actually timed out.
    Java exception thrown - Check Application Server for possible Java exception

    Do you have integration configured between the two systems?  It sounds like you don't from the error.  Here is a walk-through on setting up Unified Navigation although it assumes you have integration already working.  If you haven't done that, it's documented a hundred different places.
    http://remotepsadmins.com/2013/03/04/peoplesoft-unified-navigation-with-peoplesoft-applicatations-portal-interaction-hub/

Maybe you are looking for

  • How can i unlock my iphone from the us

    how can i unlock my iphone from the us?? please help

  • Can't figure out what's wrong.

    i have a 20gb 4g ipod. ok i'll start at the beginning. a few months ago random songs started disapearing from my ipod. i restored the ipod and put all the songs back on without a problem. it worked fine for about 2-3 months. the other day i turn the

  • LDAP CUA problem -- Could not logon to directory

    Hi Experts, I'm facing difficulties in accessing Active directory from SAP. The LDAP Connectors were setup correctly  (status with Green light). The System User were also setup as: UserID :DirectoryUser; Distinguished Name:"cn=DirectoryManager" (Dire

  • Add Outgoing Payment

    This is my code for creating Outgoing Payment. Dim payment As SAPbobsCOM.Payments = SBO_Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oVendorPayments) payment.DocDate = Date.Now payment.CardCode = "Testing" payment.PayToCode = "Testing PTD" paym

  • Mysap ERP and BW  in one instance

    Hello, in the mySAP ERP 2004, Master Guide", chapter "Technical Overview" it is said that "ERP und BW in the same system ... can only be supported on a project basis". This is difficult to understand for customers who are told that with mySAP ERP the