Is there a way to throw multiple jbuttons in an array?

I know in Visual Basic you could add controls into an array which was better on performance plus it cut down on code quite a bit. I was wondering if there's an array to group jbuttons, jlists, etc. in Java? I know you can with regular classes but I get the following error with a jbuttons array:
java.lang.NullPointerException
     at addbuttons.frmMain.jbInit(frmMain.java:33)
     at addbuttons.frmMain.<init>(frmMain.java:22)
     at addbuttons.AddButtons.<init>(AddButtons.java:15)
     at addbuttons.AddButtons$1.run(AddButtons.java:53)
     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
Here's the code I used:
package addbuttons;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.*;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class frmMain extends JFrame {
    JPanel contentPane;
    JButton cmdPushMe[] = new JButton[2];
    TitledBorder titledBorder1 = new TitledBorder("");
    public frmMain() {
        try {
            setDefaultCloseOperation(EXIT_ON_CLOSE);
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
    private void jbInit() throws Exception {
        contentPane = (JPanel) getContentPane();
        contentPane.setLayout(null);
        setSize(new Dimension(400, 300));
        setTitle("Frame Title");
        cmdPushMe[0].setBounds(new Rectangle(59, 23, 129, 33));
        cmdPushMe[0].setBorder(BorderFactory.createEtchedBorder());
        cmdPushMe[0].setText("jButton1");
        contentPane.add(cmdPushMe[0]);
        cmdPushMe[1].setBounds(new Rectangle(59, 93, 129, 33));
        cmdPushMe[1].setBorder(BorderFactory.createEtchedBorder());
        cmdPushMe[1].setText("jButton1");
        contentPane.add(cmdPushMe[1]);
}

See reply #1 in this thread:
http://forum.java.sun.com/thread.jspa?threadID=609839

Similar Messages

  • Is there a way to open multiple childs of Accordian at a same time

    Hi,
    Is there a way to open multiple childs of Accordain at a same time.
    My requiremnets is something like this:--
    Thanks for any help on this in Advance.
    Regards
    Munira

    You can have multiple nodes open on a tree, so I guess you could open them all up on a button click.
    Another option that might be possible is to use individual Accordians for each section and then use the click function to close the others.

  • Is there a way to delete multiple pictures at the same time from the iphone4s?

    Is there a way to deleter multiple pictures at the same time, from my iphone4s? I know how to delete one at a time. Thanks

    Open your Photos App > Camera Roll > At the top right corner you will see a rectangle with a right arrow, select that. Now you can select as many photos as you want and you can hit the red Delete button on the bottom right.

  • Is there some way to add multiple addresses to an email I am sending that doesn't close the contact list after I click on an address?  This necessitates constantly going back to click the + sign to add each address separately.

    Is there some way to add multiple addresses to an email I am sending that doesn't close the contact list after I click on an address?  This necessitates constantly going back to click the + sign to add each address separately.  Is there some way I can open the contact list, click on all of the individual addresses to which I want to send the email without the list closing between each address entry, and have all of my address entries be listed to the email at one time?  Something like it works in Gmail.  I do not want to use set lists, I want to enter different addresses each time I send an email.  And I am a very slow typist, so I don't want to type the first few letters of each recipient's name.  It is much faster for me to just click on the e-mail addresses in the list as a group.  It doesn't make any sense to me to have to reopen the contact list for each address, when it should be so easy to click on all of the addresses I want at one time and then click once to add them all to the email as a group.  If there is a solution to this, please tell me.  Thanks.

    Vatlily,
    Try this:
    1. Select Mail>File>New Message.
    2. Select Mail>Window>Address Panel.
    3. Use (command+click) on the desired addressees in the Address Panel to create the list.
    4. Click "To:" on the top left of the Address Panel.
    The group that you selected will be added to the "To" field in your New Message.

  • Is there a way to create multiple BQY output to one of the Job File ?

    Hello,
    I am using EPM11.1.2.3.501 version.
    BQY report due to the large amount of data, it is difficult to use a WebClient.
    So will share on a quarterly basis.
    However,
    If modifications are to occur,There are difficulties must modify each file.
    For example,
    Register 2014 1Q, 2014 2Q, 2014 3Q, 2014 4Q BQY Job file.
    When you run the job, the output of the job file is created.
    If the job file is changed, you must modify all four files.
    This will be only grow ations.
    Is there a way to create multiple BQY output to one of the Job File ??
    Please help me.
    Thanks

    It is not possible to have multiple BQY outpu into a job file.
    Thanks,
    KK

  • Is there a way to get multiple email accounts on the front page of my Iphone?  Also I would like to have different sounds when I receive mail in the different accounts. Is this possible?

    Is there a way to get multiple email accounts on the front page of my iphone instead of just the generic mail icon?  Also is there a way to get a different alert sound for each email?

    No.
    You need to review this (WYSISWG):
    http://manuals.info.apple.com/en_US/iPhone_iOS4_User_Guide.pdf

  • HT1918 Is there a way to consolidate multiple Apple IDs into one if they are all issued to the same persons(s)?

    Is there a way to consolidate multiple Apple IDs into one if they are all issued to the same persons(s)?

    No. Unfortunately, you can't combine Apple IDs togetehr, even if you own them all.

  • Is there a way to send multiple pdf's in one email from iBooks?  I have several that I've saved that I need to send to one person. If it can't be done directly, is there a work around?

    Is there a way to send multiple PDF documents from iBooks in one email?  I have several that need to be sent to one person and can't figure out how to send more than one at a time. If you can't, is there a workaround?

    Warehouse that PDF on your own server, then link to it from your book.
    Ken

  • Is there a way to create multiple map tile layers at once?

    Hello experts,
    I have a small problem. It's mainly a matter of saving some time. I need to create 51 map tile layers in mapviewer, and I would like to this this at one time. I can go to the admin console-->Management-->Manage Map Tile Layers-->Create, and then I can create one at a time. But it really would be nice to create them all at once!
    I tried using the XML mode interface, and I can use the following code to create one map tile layer:
    <?xml version="1.0" standalone="yes"?>
    <map_tile_server_admin_request>
      <create_map_tile_layer data_source="xxxx">
        <map_tile_layer
            name="FOUNDATION"
            http_header_expires="168"
            image_format="PNG">
          <internal_map_source base_map="FOUNDATION"/>
          <tile_storage root_path="/scratch/tilecache" />
          <coordinate_system
              srid="8265"
              minX="-180" maxX="180" minY="-90" maxY="90"/>
          <tile_image width="250" height="250" />
          <zoom_levels levels="10" min_scale="5000" max_scale="10000000">
          </zoom_levels>
        </map_tile_layer>
      </create_map_tile_layer>
    </map_tile_server_admin_request> And it creates one layer. But when I try this:
    <?xml version="1.0" standalone="yes"?>
    <map_tile_server_admin_request>
      <create_map_tile_layer data_source="xxxx">
        <map_tile_layer
            name="FOUNDATION"
            http_header_expires="168"
            image_format="PNG">
          <internal_map_source base_map="FOUNDATION"/>
          <tile_storage root_path="/scratch/tilecache" />
          <coordinate_system
              srid="8265"
              minX="-180" maxX="180" minY="-90" maxY="90"/>
          <tile_image width="250" height="250" />
          <zoom_levels levels="10" min_scale="5000" max_scale="10000000">
          </zoom_levels>
        </map_tile_layer>
      </create_map_tile_layer>
      <create_map_tile_layer data_source="xxxx">
        <map_tile_layer
            name="FOUNDATION_WY"
            http_header_expires="168"
            image_format="PNG">
          <internal_map_source base_map="FOUNDATION_WY"/>
          <tile_storage root_path="/scratch/tilecache" />
          <coordinate_system
              srid="8265"
              minX="-180" maxX="180" minY="-90" maxY="90"/>
          <tile_image width="250" height="250" />
          <zoom_levels levels="10" min_scale="5000" max_scale="10000000">
          </zoom_levels>
        </map_tile_layer>
      </create_map_tile_layer>
    </map_tile_server_admin_request>...it creates only the first map tile layer in my xml request.
    Is there any way to create multiple map tile layers at once?
    Thank you!
    John

    Michael,
    It looks like you are right! Thank you for your help.
    I still have a small concern. I looked at the documentation and it reads,
    "The configuration settings for a cache instance are stored in the USER_SDO_CACHED_MAPS metadata view. You should normally not manipulate this view directly, but should instead use the MapViewer administration tool, which uses this view to configure map cache instances."
    But, I tried inserting records into USER_SDO_CACHED_MAPS and it works, and I can't really see any reason not to directly insert records into this table, so...
    Perhaps that warning is there simply because potentially you could screw things up tinkering with the table directly.
    Cheers!
    John

  • Is there a way to display multiple iPad screens on the same television screen simultaneously?

    Is there a way to display multiple iPad screens on the same television set concurrently?  The idea is to let multiple individuals do something on their iPads in a timed window and then display the results of each iPad users answer concurrently on te same television.

    Devices that display two, four, or even eight video signals on a single monitor are available in the video security market. Maybe you could find something there that would do what you want. A quick search on "security tv screen multiplexor" (without the quotes) yielded millions of pages; several on the first page looked promising if you don't mind composite video.

  • Is there any way to create multiple users in a single shot in oracle db

    Can Any one tell me, is there any way to create multiple users in a single shot in oracle database.

    Hello Nunhum,
    I guess this was not my question.. This is not what I m asking.. I know there is not a single sql statement in oracle ,which could create multiusers alike UNIX/LINUX(OS LEVEL), Whatever you have written..is simple creating them one by one.
    What I am expecting is to have PL/SQL statement which could help us in this regard.

  • Is there a way to move multiple Calendar items from one date to another?

    Hello. I have far too many Calendar items every day in my iCal. Until I finally pare them down to a reasonable level, I need to "reschedule" all of my unfinished ToDo items and reminders, to another day, later in the week.
    There doesn't seem to be any "Select All" feature available.
    Is there a way to move multiple Calendar items from one date to another?
    Thanks in advance!

    Still no ideas? Apple, please come up with a fix. Thanks.

  • Is there a way to format multiple images at once? Change colour mode or resolution?

    Is there a way to format multiple images at once? Change colour mode or resolution?

    It's very easy to make an action.
    Go to window > actions
    In the actions panel, simply click the 'create a new action' button, it starts recording as soon as you've created it (when you've given it a name).
    Now you can apply the changes you want to make to the images on the file you have opened.
    After you've done all you need to do. You click the 'stop' button. The action is now ready to use. And you can apply the changes you made on all the other files.
    Then you can continue how gener7 explained.
    I usually include a save and close command, so that the whole batch doesn't end up opened after running the script.
    But if you do that you have to create a new file, and save it to your computer before you start recording the action, otherwise the save command will be replaced by each file. And you'll end up with one edited file in the end. At least for as far as I know!

  • Is there any way to delete multiple spams at once, right now I go through each individually and delete it, but it's time consuming, thanks

    Is there any way to delete multiple spam messages at once. Right now I go through each individual spam and delete one at a time. This is very time consuming. Any tricks out there.
    Thank you

    Hi LRagsdale517,
    You should definitely be able to upload multiple files by Shift-clicking or Ctrl-clicking the files you want to upload. Just to make sure you don't have an old version of the service cached, please clear the browser cache and then log in to https://cloud.acrobat.com/files. After clicking the File Upload icon in the upper-right corner, you should be able so select multiple files for upload.
    Please let us know how it goes.
    Best,
    Sara

  • ICloud keeps duplicating my contacts, any of which I need to delete anyways.  Is there a way to delete multiple contacts at once? I  have been deleting them one at a time, but they keep reappearing.

    ICloud keeps duplicating my contacts, any of which I need to delete anyways.  Is there a way to delete multiple contacts at once? I  have been deleting them one at a time, but they keep reappearing.

    I have exactly the same problem!  I have Outlook 2010 and it does the same thing with my contacts, and calender enteries!! Really frustrating

Maybe you are looking for

  • Cannot delete specific files.

    I am unable to delete certain files, but I can delete others. Finder says "The operation cannot be completed because the item...is in use." I have tried: *Alt+Empty Trash *Secure delete *Empty trash from the Terminal *Repair permissions *Verify disk

  • HDCP Compliance Issue, Everything is Compliant Though???

    I am having a issue playing Blu Ray disks. I continue to get a HDCP compliance error everytime I try to play a Blu Ray video.  I am using arcsoft TMT6 on windows 7. I checked to make sure my monitor and video card are both HDCP compliant, and they bo

  • Creating DVD from pictures

    Hi all Pretty new to the iMovie thing. Need to know whats the best app for creating a DVD of some vacation pics. I want to add titles, chapters (500 pics) & music. I tried exporting a slideshow from iPhoto into iDVD but it didn't play right (stopped

  • E-mail  warning: unknown error

    I just installed Photoshop 5 and e-mail doesn't work. Quit working when I had 3.0. I just get a warning (adobe) unknown error. Help does not go into detail. Could there be a setting in "my computer" that I accidentally changed? Adobe has my e-mail re

  • How do I capture an image of my screen (s/t MS "print screen)?

    the title says it all