Get jpanel to show

hi people
I have been trying to get a jpanel show when the main is initializes. I don't get any errors. I am using Netbeans as my IDE. The jpanel I want to show is timerPanel. I am very new to java so I am sure that it is something simple. does anyone know what I am going wrong?
public class Timer extends javax.swing.JPanel {
    public static void main(String[] args){
        new Timer().setVisible(true);
    /** Creates new form timer */
    public Timer() {
        initComponents();
        JPanel panel= new JPanel();
        panel.setVisible(true);
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
        timerPanel = new javax.swing.JPanel();
        display = new javax.swing.JLabel();
        start = new javax.swing.JButton();
        pause = new javax.swing.JButton();
        reset = new javax.swing.JButton();
        save = new javax.swing.JButton();
        exit = new javax.swing.JButton();
        timerPanel.setBackground(new java.awt.Color(232, 227, 234));
        display.setBackground(new java.awt.Color(217, 217, 62));
        display.setText("wa");
        display.setToolTipText("shows hr:mins:sec");
        start.setText("Start");
        start.setToolTipText("Starts Timer");
        start.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                startActionPerformed(evt);
        pause.setText("Pause");
        pause.setToolTipText("To Restart Press");
        pause.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pauseActionPerformed(evt);
        reset.setText("Reset");
        reset.setToolTipText("Clears Timer");
        reset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetActionPerformed(evt);
        save.setText("Save");
        save.setToolTipText("Saves Timer Amount");
        save.setActionCommand("Save");
        save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveActionPerformed(evt);
        exit.setText("Exit");
        exit.setToolTipText("Exits without saving");
        exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitActionPerformed(evt);
        javax.swing.GroupLayout timerPanelLayout = new javax.swing.GroupLayout(timerPanel);
        timerPanel.setLayout(timerPanelLayout);
        timerPanelLayout.setHorizontalGroup(
            timerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(timerPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(timerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(display, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, timerPanelLayout.createSequentialGroup()
                        .addComponent(start)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pause)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(reset)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 94, Short.MAX_VALUE)
                .addComponent(save)
                .addGap(4, 4, 4)
                .addComponent(exit)
                .addContainerGap())
        timerPanelLayout.setVerticalGroup(
            timerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, timerPanelLayout.createSequentialGroup()
                .addContainerGap(47, Short.MAX_VALUE)
                .addComponent(display, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(timerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(start)
                    .addComponent(pause)
                    .addComponent(reset)
                    .addComponent(save)
                    .addComponent(exit))
                .addContainerGap())
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(timerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addComponent(timerPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(287, Short.MAX_VALUE))
    }// </editor-fold>
    private void startActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    private void pauseActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    private void resetActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    private void saveActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    private void exitActionPerformed(java.awt.event.ActionEvent evt) {
        // TODO add your handling code here:
    // Variables declaration - do not modify
    private javax.swing.JLabel display;
    private javax.swing.JButton exit;
    private javax.swing.JButton pause;
    private javax.swing.JButton reset;
    private javax.swing.JButton save;
    private javax.swing.JButton start;
    private javax.swing.JPanel timerPanel;
    // End of variables declaration
}

gishaust wrote:
Who would I ask?The compiler and JVM!
Change your code to include a JFrame, compile it, run it. You will soon find out.

Similar Messages

  • Having problems getting JListBox to show scrollbars`

    Hi Java Experts
    I'm having problmes getting JListBox to show scrollbars -- basically it is not.
    I'm using the gridbag layout.
    here's my code.
    CollectingList = new JList(data);
    CollectingList.setVisibleRowCount(30);
    JScrollPane scrollPane3 = new JScrollPane(CollectingList, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS , JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS );
    then i add it like this
    add(CollectingList, constraints,     4, 3, 1, 1, p3);
         private void add(Component c, GridBagConstraints constraints, int y, int x, int w, int h, JPanel p2 )
              constraints.gridx = x;
              constraints.gridy = y;
              constraints.gridwidth = w;
              constraints.gridheight = h;
              p2.add(c,constraints);
    any ideas why my list box refuses to show scrollbars ?
    thanks
    stev     

    Unless it's somewhere else in your code and not posted....I don't see where you are adding your JList to your JScrollPane, then adding your scrollPane to your applet/application.
    Check out the JScrollPane in the tutorial.

  • I downloaded a WMA audiobook from library using Overdrive. It shows up on my Itunes listing of Audiobooks on my Ipod, but on the actual Ipod it only shows up on Playlists. How do I get it to show up under Audiobooks?

    I downloaded a WMA audiobook from library using Overdrive. It shows up on my Itunes listing of Audiobooks on my Ipod, but on the actual Ipod it only shows up on Playlists.  It is marked as an audiobook in Options | Media Kind.  It is also marked to Remeber Position, but it does not do that. How do I get it to show up under Audiobooks and remember the position?  I have a 4th Gen Ipod running Ios5

    Check out the instructions for a work around on this post: https://discussions.apple.com/message/18702732#18702732
    This worked for me.  I would like to see Apple fix this issue, as it isn't very fun to have to do this for every downloaded book.

  • I have audio books on my ipod, but when I hook it up to my computer they don't show up so I can't take them off or anything.  Now I am out of space.  How do I get them to show up on the itunes sync screens?

    I have audio books that are on my ipod touch, but when I hook it up to my computer to make changes they don't show up.  I can't add new music, because it keeps telling me I am out of room.  When I go to the book tab at the top it doesn't show any so I can't take them off.  How do I get them to show up?

    iDevices are not and have never been backup devices.
    Authorizing a computer does not cause media to magically appear.
    Media is only where the user puts it.
    Copy the ENTIRE iTunes folder from the old computer to the new computer.

  • I rented a movie from itunes on my ipad and now want to play it on my appletv, but cannot get it to show up.  What do I need to do?

    I rented a movie from itunes on my ipad and now want to play it on my appletv, but cannot get it to show up.  What do I need to do?

    If you download a rented movie on your iPhone 4 or later, iPad, iPod touch (4th generation or later), or Apple TV: It is not transferable to any other device or computer."
    http://support.apple.com/kb/ht1657

  • When I open an event, including flagged items, the photos appear one by one, not as thumbnails, so I can't export more than one phot at a time. How do I get iPhoto to show the thumbnails?

    When I open an event, including flagged items, the photos appear one by one, not as thumbnails, so I can't export more than one phot at a time. How do I get iPhoto to show the thumbnails?
    I've tried rebuilding the thumbnail database, but that hasn't helped.

    What version of iPhoto and system are you running?
    Try moving the Zoom slider at the bottom of the iPhoto window all the way to the left.  Does that let more than one photo display in the window?
    OT

  • When a tab is close, firefox next shows the tab to the right. How do I get firefox to show the tab to the LEFT of the closed tab?

    I have 3 tabs open named 1, 2 and 3. If I close tab 2, Firefox will automatically show tab 3. How do I get Firefox to show tab 1 instead of tab 3? Basically, move to the left instead of the right?
    I searched about:config using words like: tab, open, close, next, left and right and compared the results on
    http://kb.mozillazine.org/Firefox_:_FAQs_:_About:config_Entries to get a good idea of what each entry did. Learned a lot and reconfigured other aspects of Firefox in the process! But, I would really like to alter the way Firefox processes tab closures.
    Thank you.

    You can look at these extensions:
    *Tab Control: https://addons.mozilla.org/firefox/addon/1480
    *Tabberwocky: https://addons.mozilla.org/firefox/addon/14439
    *Tab Mix Plus: https://addons.mozilla.org/firefox/addon/1122

  • I put in my memory card to the left side of the computer, but I cannot find the file of pictures anywhere. Its not even on my desktop. What should I do and how can I get it to show up on my desktop?

    I put in my memory card to the left side of the computer, but I cannot find the file of pictures anywhere. Its not even on my desktop. What should I do and how can I get it to show up on my desktop?

    If your Mac is new-ish and has one of the Lions as its OS, the drives, cards, USB sticks no longer show up, even though they're there. Go to Finder's Preferences and tick the corresponding items in the General and Sidebar tabs.

  • HT5731 I bought a full season of a TV show. I downloaded all episodes. When I go into my iTunes library, select the episodes I get a message of: This computer is already associated with an Apple ID. I can't for the life of me get the TV show to play.

    I bought a full season of a TV show. I downloaded all episodes, I went to my  iTunes library, selected the episode I wanted to watch. I got this message: This computer is already associated with an Apple ID. I can't for the life of me get the TV shows to play. I went on iTunes and when to my purchases. Clicked on the episodes and the same message popped up. How do I get these to play? I also see my download box with an error message saying it has paused the download. I click unpause and it just pauses again. I have been able to get one of the episodes to play once through, but now it gives me the same message.

    It's been months, so you may not care anymore, but you can't download songs from multiple Apple IDs over a 90 days period.  Sorry, it's not allowed for legal reasons.

  • Ipod touch wont show up in usb or itunes help pages just bring me in circles.  how can i get it to show up.  I use windows xp at home and tried everything then tried a relatives computer using windows 7 and still nothing.  this is an older ipod touch

    the help pagers just bring me around in circles.  the ipod doesn't show up in system devices under the busses.  i've tried just about everything.  Im using windows xp at home and though maybe it was because of that. so went to a relatives and used a brand new lap top avus with windows 7 and it wont show up here either.  When i got the ipod a few days ago from a third party the only screen i could get to come up was a picture of a usb cord with an arrow pointing towards the itunes logo.  I downloaded i tunes and couldn't get it to change.  brought it to at&t store today they hooked it up with my usb cord to thier computer and suddenly the menu screens work and i could even get online with it yet when i try to hook it up to one of my computers it doesn't show up anywere where can i go to get this fixed and fixed quick jumping around the apple help pages have put me in a foul mood and im sick of it two days spent trying to get it to show now.  im sick of waiting around i need help asap so i can return this **** thing if it turns out it is broken somehow..which i dont think it is.

    What gen iPod (3,4?) did you buy?

  • How can I get firefox to show everything from left to right, without a curser that I have to move, in win-xp?

    It used to be ok. I had a firexox teeshirt from way far back, firefox 1.0. Then i had a hemorrhagic stroke, about 3 years ago. Now i'm back, in a new place, for two months now.
    (I use my left hand now...) and once again, i have a desktop, with win-xp (and five internal harddrives, and a 600w ps.) Anyway, for the first time with my new desktop, there is a cursor in the bottom of firefox, and it doesn't show everything, left to right unless i move it.
    I've been out of commission, with only a laptop, with win-7-64bit edition, that i got just 7 months before my stroke. My sister threw away all of my desktops...many of which i built. The doctor said i may die...so my sister didn't even wait, but threw away my CLOTHES AND BOOKS AND COMPUTERS (except for the laptop), but she saved most of my harddrives...i guess i taught her how to save harddrives.
    Anyway, it's been three years, since i've had no 32bit computer with win-xp, and i can't figure out how to make things go back to the way i'm used to. HELP! I was in your forums, when my e-mail was [email protected], which it will be again , soon. But for how, how do i get firefox to show all, left to right, without a bottom cursor? i know it's possible. (And while i'm asking questions, how can i, tony mendola, get another firefox 1.0 tee shirt? i would even pay for it, even though i'm on social security-disability, with only one hand working..and no work. I used to wear it, proudly when fixing computers for others.)

    Hi manni394, what version of Firefox are you running now?
    Firefox 22 has a new way of setting the default zoom level: it is based on your Windows font size setting. So, if you set Windows fonts to 125% (enlarged 25%), your Firefox pages also will be enlarged 25%. On pages that do not adjust their layout, you may get a horizontal scroll bar.
    To reduce the zoom on a page, hold Ctrl and tap the - key (the one on the numeric keypad or the one on the number row of the keyboard). The zoom should be reduced for each tap.
    If you want to globally adjust your zoom level to be lower, you can use either of these add-ons:
    * [https://addons.mozilla.org/firefox/addon/default-fullzoom-level/ Default FullZoom Level]
    * [https://addons.mozilla.org/firefox/addon/nosquint/ NoSquint]
    If you already have one of those add-ons, check the default/global zoom level in case it needs to be adjusted.

  • I want to set up my iphone to sync with my macbook but when I plug it in via USB my iphone doesn't show up under devices in itunes even though it is plugged in correctly and is charging through my computer. How do I get it to show up?

    I want to set up my iphone to sync with my macbook but when I plug it in via USB my iphone doesn't show up under devices in itunes even though it is plugged in correctly and is charging through my computer. How do I get it to show up? I've tried restarting my computer.

      If your iPhone does not appear under Devices in iTunes after you connect it to your Mac, refer to the troubleshooting suggestions here:
      http://support.apple.com/kb/ts1591

  • I purchased an app and it downloaded to my MacMini, how do I get it to show up on my iPhone and iPad?

    I purchased an app and it downloaded to my MacMini, how do I get it to show up on my iPhone and iPad?

    Sync it to the devices:
    http://support.apple.com/kb/PH12111
    Or you can download the app directly from your iPhone and iPad:
    http://support.apple.com/kb/ht2519
    Regards.

  • I want to use one apple id in my macbook and iPad but i don't want pics to get sync and show in both devices, how should i stop this ?

    I want to use one apple id in my macbook and iPad but i don't want pics to get sync and show in both devices, how should i stop this ?

    Turn off My PhotoStream in iCloud on both the iPad and the Mac. PhotoStream is what shares your photos (unless you are using iCloud Photo Library Beta, in which case, all photos uploaded are accessible from all devices signed onto the same Apple/iCloud ID).
    Cheers,
    GB

  • How can I get Expose to show only and all active windows, regardless of app

    Sometimes I have two applications running with several finder windows hidden on the dock. I'd like to know how I can (or if I can) get Expose to show only the Active windows - not the ones on the dock. With this new upgrade, it seems that all open windows that are on the dock appear in a row at the bottom of the screen, which takes up real estate - can I turn that function off so just the open, undocked windows of all apps show?

    Sounds like you opened a message in a new window. Have you tried closing that window and see what happens?
    If that is not it maybe you can post a screen shot of what you are seeing.

Maybe you are looking for

  • Executing if condition in a sql prompt with in a shell script

    Hi all, i need to write a shell script where i need to execute a sql statement. if the count from the above sql is greater than certain value i need to execute a another sql statement.After some time i need to check the count again using above sql an

  • How to download pdf files right away?

    Background: Our company(Jinisys Software Inc.) targets hotel owners to download our brochure(pdf) about hotel management system. We have different pdf files on few of our webpages. I'd like to point out that adobe did a great job in displaying the pd

  • How to Edit Comment Tag in DW CS3?

    I would like to customize the HTML comment tag for my own preferences. I know how to edit the colors and font under Preferences, but I would like to change the whole tag and add some more spaces and dashes. How do I edit this in DW CS3? Thanks..

  • Flushing the log file....

    Hello, Is there a way to force weblogic to flush the log file more frequently. Currently, it appears that there is a delay between the log output in the console versus the contents of the log file. It would be helpful to be able to see updated log in

  • After 1.6.2 update, I have hd picture but no sound, tv says hdmi audio unavailabl​e

    I have hd picture but no sound, tv says hdmi audio unavailable , this happened right after update 1.6.2 my television is an HP PL4260N, I saw on other post in fixya.com other people with same problem after update too. Any ideas on fixing this? I alre