Button Allocation Help

Hi all,
I am working on a java gui application that will have free-floating-button-boxes. In other words, there will be selections from a JFrame that will allow the user to select an option from a
frame that is not connected to the main application frame. Because
there are potentially several different button boxes that will change
as the functionality of the application is increased, I wanted to make
a generic frame that would dynamically allocate the button box based
upon an array of Strings input to the constructor. When I hard code the
string array, I have no problem constructing the box. (This is not the hard coded example ) but when I attempt to allocate and label the buttons "on the fly" I always get a null pointer exception thrown. I have tested the logic and I am not going off the end of the array (IllegalIndexException) but I cannot determine why this doesn't work.
I have cut the code down to what I believe is the minimum logic, without event handlers or other extraneous code and it is below along with the output and resultant exception. If anyone has an idea, I'd appreciate it.
Sincerely,
John
import javax.swing.*;
public class ButtonTest extends JFrame {
public ButtonTest( String[] args ){
init( args );
public void init( String[] args ){
JButton[] aButtonArray = new JButton[ args.length ];
getContentPane().setLayout( new java.awt.GridLayout( args.length , 1
for ( int i = 0; i < args.length; i++ ) {
aButtonArray[ i ].setLabel( args[ i ] );
getContentPane().add( aButtonArray[ i ] );
pack();
setSize( 100, 100 );
show();
public static void main( String[] args ){
String[] arr = new String[ args.length ];
for ( int i = 0; i < args.length; i++ ) {
arr[ i ] = args[ i ];
System.out.println( args[ i ] );
ButtonTest button = new ButtonTest( arr );
C:\Code_PlayGround\Java>java -cp . ButtonTest label1 label2 label3
label1
label2
label3
Exception in thread "main" java.lang.NullPointerException
at ButtonTest.init(ButtonTest.java:14)
at ButtonTest.<init>(ButtonTest.java:7)
at ButtonTest.main(ButtonTest.java:29)

You get a NPE because you've not populated the aButtonArray array.
for ( int i = 0; i < args.length; i++ ) {
  aButtonArray[ i ] = new JButton(args);
getContentPane().add( aButtonArray[ i ] );

Similar Messages

  • How to create authorisation object for save button please help in abap

    how to create authorisation object for save button please help in abap

    Hi
    In general different users will be given different authorizations based on their role in the orgn.
    We create ROLES and assign the Authorization and TCODES for that role, so only that user can have access to those T Codes.
    USe SUIM and SU21 T codes for this.
    Much of the data in an R/3 system has to be protected so that unauthorized users cannot access it. Therefore the appropriate authorization is required before a user can carry out certain actions in the system. When you log on to the R/3 system, the system checks in the user master record to see which transactions you are authorized to use. An authorization check is implemented for every sensitive transaction.
    If you wish to protect a transaction that you have programmed yourself, then you must implement an authorization check.
    This means you have to allocate an authorization object in the definition of the transaction.
    For example:
    program an AUTHORITY-CHECK.
    AUTHORITY-CHECK OBJECT <authorization object>
    ID <authority field 1> FIELD <field value 1>.
    ID <authority field 2> FIELD <field value 2>.
    ID <authority-field n> FIELD <field value n>.
    The OBJECT parameter specifies the authorization object.
    The ID parameter specifies an authorization field (in the authorization object).
    The FIELD parameter specifies a value for the authorization field.
    The authorization object and its fields have to be suitable for the transaction. In most cases you will be able to use the existing authorization objects to protect your data. But new developments may require that you define new authorization objects and fields.
    http://help.sap.com/saphelp_nw04s/helpdata/en/52/67167f439b11d1896f0000e8322d00/content.htm
    To ensure that a user has the appropriate authorizations when he or she performs an action, users are subject to authorization checks.
    Authorization : An authorization enables you to perform a particular activity in the SAP System, based on a set of authorization object field values.
    You program the authorization check using the ABAP statement AUTHORITY-CHECK.
    AUTHORITY-CHECK OBJECT 'S_TRVL_BKS'
    ID 'ACTVT' FIELD '02'
    ID 'CUSTTYPE' FIELD 'B'.
    IF SY-SUBRC <> 0.
    MESSAGE E...
    ENDIF.
    'S_TRVL_BKS' is a auth. object
    ID 'ACTVT' FIELD '02' in place 2 you can put 1,2, 3 for change create or display.
    The AUTHORITY-CHECK checks whether a user has the appropriate authorization to execute a particular activity.
    This Authorization concept is somewhat linked with BASIS people.
    As a developer you may not have access to access to SU21 Transaction where you have to define, authorizations, Objects and for nthat object you assign fields and values. Another Tcode is PFCG where you can assign these authrization objects and TCodes for a  profile and that profile in turn attached to a particular user.
    Take the help of the basis Guy and create and use.
    Regards
    ANJI

  • I'm getting a similar message: There was an error opening the database..." and the only option I get is a "quit" button. Help!

    I'm getting a similar message: First it offers me chance to repair - but if I it repair, it crashes.  Then if I select do not repair I get the following warning: There was an error opening the database..." and the only option I get is a "quit" button. Help!

    From the path in the error message you posted it appears that the library is not on your internal (root) drive.
    What type of disk is the library on and how is it formatted?
    The crash log Léonie is referring to is what is printed out when Aperture crashes. You wrote that Aperture crashes in your first post so if the app crashes you must have gotten a crash report.
    Message was edited by: Frank Caggiano

  • How to "un-grey" the "Updates" button under Help in PS CS6?

    I had uninstalled the CS5.5 and installed the CS6 Master collection. But the "Updates" button under Help in PS is greyed out, that means I cannot update the ACR to 7.1 or any subsequent updates. How can I overcome this problem? BTW, my computer is windows based.

    " Sure you can - simply download them from the support pages/ download section.”
    What should I download from that page?
    ATongT

  • I downloaded the new version of firefox, now my flash player wont work, the html text box is gone and so is the back and forward buttons. please help??

    I downloaded the new version of firefox, now I cant watch any movies, the html text box is totally gone, and so is the back and forward website buttons, please help? can i just have the old version back?

    Not sure whether for instance you initially had a Yahoo optimised version of Firefox, and have now overwritten it with an official Mozilla version. Although the Mozilla version should NOT add unwanted features, but the Yahoo version may well do.
    If you merely need to find the Yahoo emails page quickly just add it as a bookmark or as a bookmark on the Bookmarks toolbar and make sure that is visible.
    Clicking the star icon on the location bar whilst looking at your emails will bookmark the page.
    * [[How to use bookmarks to save and organize your favorite websites]]
    * [[Bookmarks Toolbar - Display your favorite websites at the top of the Firefox window]]
    I do not use Yahoo myself,and am not sure what add-ons are available. You could search yourself using
    * FirefoxButton -> add-ons
    ** see [[Find and install add-ons to add features to Firefox]]
    ** examples [https://addons.mozilla.org/en-us/firefox/addon/yahoo-toolbar/ yahoo toolbar] & [https://addons.mozilla.org/en-us/firefox/addon/yahoo-mail-notifier/ mail notifier]
    * also look at Yahoo's own information such as http://help.yahoo.com/tutorials/toolbar/cl3/c3_ff_toolbar1.html

  • How do I update my iPad 2 to iOS 5, I tried going to settings,general ,software update but I can't seem to find the software update button pls help :)

    How do I update my iPad 2 to iOS 5, I tried going to settings,general ,software update but I can't seem to find the software update button pls help :)

    Go to Settings > General > About and see what iOS version you are running.  If it is lower than 5, you won't find the software update button.  It was added when iOS 5 came out.  The current iOS is 5.1.1.  To update to the current OS, you'll need to connect to the computer you sync with (this is important - do not connect to a computer you do not sync with as you will lose you apps) and update the software in iTunes.  Once you have updated to the 5.1.1, the software update button will be in Settings going forward.  Make sure you have a lot of time.  Updating from below 5 to 5 or higher is a somewhat lengthy process.
    This link will provide the guidance you need:
    http://www.macworld.com/article/1162925/how_to_upgrade_your_ios_device_to_ios_5. html

  • When I start my mac book pro the screen flashes on and off and then a blue color before it open to the log in screen. Sometime a program will shot down buy it's self without me clicking the quit button. Help?!

    When I start my mac book pro the screen flashes on and off and then a blue color before it open to the log in screen. Sometime a program will shot down buy it's self without me clicking the quit button. Help?!

    If you keep getting a 'red' message it means that the HDD is faulty and will have to be replaced.  You will have to format the new HDD in Disk Utility>Erase and then install the OSX and your data from Time Machine.
    Ciao.

  • When button clicked help

    I have buttons for help, back, next, finish, cancel.
    initially I have the back and finish buttons setEnable(false)
    but when I click on Next button I want the Back button to be setEnable(true)
    I wrote the following
    //ActionListener for jButton_Next Of NavigationButtons Panel
    newNavigationButtonsClass.jButton_Next.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    newNavigationButtonsClass.jButton_Back.setEnabled(true);
    When I click on the jButton_Next the jButton_Back is not enabled. May I know what I can change in this to get this working. Thanks.

    Is the code where you initially disable the button
    getting called again somehow? I'd check to make
    sure this code isn't getting called again after you
    enable the button within actionPerformed.

  • A friend of mine was recently in an accident and we need to delete some photos from her iPhone's "Photo Stream From my Computer" album, but cannot figure out a way to do it (there's no delete button). Help?

    A friend of mine was recently in an accident and we need to delete some photos from her iPhone's "Photo Stream From my Computer" album, but cannot figure out a way to do it (there's no delete button). Help?

    Sounds like it was synced from her computer using iTunes.  Connect the phone to her computer, open iTunes, click on the name of her phone in iTunes, go to the Photos tab and see if this folder is checked.  If so, unchecking it and syncing will remove them all, or deleting/moving the photos from the folder on her computer and syncing will remove the deleted/moved photos.

  • When my computer and monitor go to sleep, the system locks up and I have to do an hard reset with the power button.  help?

    when my imac and display go to sleep, the computer locks up and will not restart without a hard restart with the power button.  help?

    Hello, what all especially USBwise do you have connected to it?
    One way to test is to Safe Boot from the HD, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, Test for problem in Safe Mode...
    PS. Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive
    Reboot, test again.
    If it only does it in Regular Boot, then it could be some hardware problem like Video card, (Quartz is turned off in Safe Mode), or Airport, or some USB or Firewire device, or 3rd party add-on, Check System Preferences>Accounts (Users & Groups in later OSX versions)>Login Items window to see if it or something relevant is listed. Or an errant process eating up RAM.
    Check the System Preferences>Other Row, for 3rd party Pref Panes.
    Also look in these if they exist, some are invisible...
    /private/var/run/StartupItems
    /Library/StartupItems
    /System/Library/StartupItems
    /System/Library/LaunchDaemons
    /Library/LaunchDaemons
    Open console in Applications>Utilities, check the system log for the date/time of the last problem  & the Startup right after that for clues.

  • Simple Button Action Help

    Hi
    I am new to flash and having a bit of trouble. All I would
    like to do is be able to create a button and have that button
    navigate to a frame.
    What I am doing now is:
    Insert - New Symbol - Button and name the button (ex: about)
    Go through the up/over/down/hit steps and return to scene 1
    I then drag the about button onto the stage
    I give the about button the instance name of about_btn
    In the action layer, I enter the following code:
    stop();
    _root.about_btn.onRelease = function(){
    gotoAndStop("about");
    "about" being the keyframe I would like to go to
    When I test the button, I get error 1120: "Access of
    undefined property onrelease".
    I am working on adobe flash cs3 on a pc. I know this is a
    very simple issue and any help would be greatly appreciated.
    Thank you.

    quote:
    Originally posted by:
    db11
    When I test the button, I get error 1120: "Access of
    undefined property onrelease".
    AS3 is case sensitive. You must have mistyped onrelease
    instead of onRelease

  • Simple button applet help

    ok, i'm working on a project involving buttons, and i finished it and it compiles fine, but when i run the applet (using textpad), nothign shows up.
    i decided to make a new applet of only the frame and buttons, and i got the same problem. here is the simple one.
    import java.util.*;
    import java.applet.Applet;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    public class framek extends JApplet
         public static final int WIDTH = 600;
         public static final int HEIGHT = 300;
         public void framek()
              JFrame myWindow = new JFrame();
              myWindow.setSize(WIDTH, HEIGHT);
         Container contentPane = myWindow.getContentPane();
              contentPane.setBackground(Color.blue);
              contentPane.setLayout(new BorderLayout());
              JPanel button = new JPanel();
              button.setLayout(new FlowLayout());
              JButton convert = new JButton("Translate");
              button.add(convert);
              JButton delete = new JButton("Delete");
              button.add(delete);
              contentPane.add(button, BorderLayout.SOUTH);
    i might have made some mistakes in the shortening of my project (such as variables that arent used) but i just need help with getting the buttons and background things to show. I used very similar programs in a textbook and on the web to check and they worked fine on textpad, and this doesnt. its probably a very simple thing that i forgot but i cant find it yet, as i am fairly new to swing.
    any help is appreciated thanks

    /*  <applet code="HelloApplet" width="600" height="300"></applet>
    *  use: >appletviewer HelloApplet.java
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class HelloApplet extends JApplet
        public static final int WIDTH = 600;
        public static final int HEIGHT = 300;
        public void init()
            Container contentPane = getContentPane();
            contentPane.setBackground(Color.blue);
            contentPane.setLayout(new BorderLayout());
            JPanel button = new JPanel();
            button.setLayout(new FlowLayout());
            JButton convert = new JButton("Translate");
            button.add(convert);
            JButton delete = new JButton("Delete");
            button.add(delete);
            contentPane.add(button, BorderLayout.SOUTH);
        /** this is a convenience method */
        public static void main(String[] args)
            JApplet applet = new HelloApplet();
            JFrame myWindow = new JFrame();
            myWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            myWindow.add(applet);
            myWindow.setSize(WIDTH, HEIGHT);
            myWindow.setLocation(200,200);
            applet.init();
            myWindow.setVisible(true);
    }

  • How to Disable Check for updates button in Help/About in firefox 5.0

    Hi the user should not manually check for updates so we want to disable the Check for updates button also in Help/About.
    Thanks in advanced

    You can hide that button with code in userChrome.css below the @namespace line.
    * http://kb.mozillazine.org/userChrome.css
    * http://kb.mozillazine.org/Editing_configuration
    You can use the ChromEdit Plus or Stylish extension to have easier access to the customization files.
    * ChromEdit Plus: http://webdesigns.ms11.net/chromeditp.html
    <pre><nowiki>@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); /* only needed once */
    #aboutDialog #updateBox { display:none!important; }</nowiki></pre>
    You can also choose to lock the related update pref(s) to false if you want to make sure.
    See:
    * http://kb.mozillazine.org/Locking_preferences
    * http://kb.mozillazine.org/about:config

  • I have the iPad 2 and it keeps dying, when it dies it wont turn back on, it shows the apple sign but that is it. THen it shuts off and does the same thing over again, I have tried holding the sleep/awake button along with the home button! HELP!!!

    Please help!

    I'm sorry, you are correct I am trying to restore my ipad because it stopped working.   We thought the battery was dead so we plugged it into the wall charger.  All it does when plugged in is flash the apple logo like it is going to start up and then shut off.  It repeats this every few seconds while it is plugged into the wall.  I let it charge overnight and still nothing.
    When I hold the power button and the home button down together while the ipad is plugged into the wall, it does flash then after I release the power button the connect to itunes screen comes on.   But when I connect it to my computer it goes blank.   itunes does not recongnize my ipad when I plug it into the computer.  I have used the same cord to plug in my other devices and itunes recongnizes them so it isn't the usb cord.
    It seems as if my system has crashed and I think this may just be an apple service trip for me.  But thanks so much for the advice.   =D

  • Email submit button(s) help

    I have a 5 page form and I need each page to go to a different email adress.  I have put a different email submit button on each page, but is there a way to script the button to only send the current page and not any of the others?  Or have one main email submit button that sends each page to a different email address?  I am new to Adobe LiveCycle Designer ES, but I have a (VB) programming background, so it seems like it should be possible with code  Thanks
    Adobe LiveCycle Designer ES ver 8.2

    Hi,
    The submit by email function will attach the complete form to the email. It cannot (afaik) split a form into five different PDFs.
    However there are workarounds.
    If you save the form as a Dynamic XML form in the save as dialog, then you can show and hide pages.
    Here is an example of a form that changes the presence property of pages, depending on the choice selected from the dropdown.
    http://www.assuredynamics.com/index.php/category/portfolio/showing-and-hiding-pages/
    When it comes to something like this it is helpful to split the script. The mouseUp event fires before the click event.
    For example for the email button on page 1, you can modify the script in the example to hide each of the pages 2-5 in the mouseUp event and then in the click event have the email script. In the postSubmit event you could have script to show all the pages again.
    A word of caution - if the user has Reader then the form needs to be Reader Enabled, otherwise the submit as PDF will fail silently.
    Hope that helps,
    Niall
    Assure Dynamics

Maybe you are looking for

  • How do I stop an e-mail address from going into junk

    I have an e-mail address that is in a filter and that filter is supposed to run BEFORE the junk filter. However, every single e-mail from that e-mail address is going into the spam folder. How do I get Thunderbird to: 1. Respect the filter that is su

  • Windows server 2008 r2 KB2871997 unexpected restarts

    Hi there, after I have installed KB2871997 on several Windows Servers we have a lot of unexpected restarts: Log Name:      System Source:        LsaSrv Date:          19.05.2014 11:19:24 Event ID:      5000 Task Category: None Level:         Error Ke

  • IChat quitting

    For the most part, I have no problems with iChat, but sometimes, I will try starting an audio or video chat and then iChat will just quit. Nothing is written to the error log and nothing shows up saying iChat quit. Then I will try oepning iChat and i

  • Thumbnail generation in windows service

    I try to create thumbnails for pdf files using the microsoft windowns 7 api codepack. If I use this code from a normal desktop application everything works fine. But if I use it from a windows service, to create thumbnails for our document manager, I

  • Weird smudges in file coming from CC Libraries object?

    Hi all, I was excited to start using the Creative Cloud libraries to organize reusable objects for a web design project. However, when I add an icon from the library to my photoshop file (the icon was drawn in illustrator and added to the library the