Return an array of JButtons - Is this possible?

Is it possible to return an array of JButtons? I have madean array of JButtons and assigned them anonymous listeners as they each do the same thing so i only had to do one in the for loop creation
the idea is that i want to ship this code out to a method called createButtons and call it in the make frame method, but i cant seem to find a solution that actually works
thanks

JustSomeGuy wrote:
If you went to your teacher and asked them how they felt about [the java forums], and under what circumstances it may be considered cheating, I think you will be suprised by the answer. Most teachers actually want you to learn, big shocker I know.
JSGJSG.kudos++;
compSciUndergrad wrote:
if you want to tell me your opinions i am all ears, i hope they are not to harsh :SI'm of the opinion that at least 90% of students who are concerned about being seen as cheating are only concerned because they feel that they are cheating. Furthermore atleast 90% of students who "feel" that they are cheating have perfectly valid concerns, because they are in fact cheating.
In my humble opinion it would be better for all concerned if cheaters did get caught, and sooner rather than later... because when they hit the real-world, where there really is no-one to cheat off, cheaters allways seem to come-a-cropper, big-time... because they also lie about there total lack of progress, in a shortsighted attempt to cover up there total imcompetence... too often taking those who entrusted them to actually do the friggin job down with them.
Lots of good people getting skinned-alive by a pack of feral know-nothing friggin lawers, all because some moron kid tells a pack of lies, and thinks he's gonna get away with it come crunch time. Ummm... No thanks. Ta.
So, much better to delineate between the competent and the not-competent programmer at the paedogogical stage. Eh what?
I wouldn't class posting a bit of code on a forum as lay-down-mazaire proof positive that "He's a cheat". My concern is that you are actively concerned (paranoid even), which is indicative that you have actually cheated in the past; and plan to do so in the future. That's all.
Cheers. Keith.

Similar Messages

  • Gui - making an array of JButtons to make a grid

    how do i declare an array of JButtons to make a 16x16 grid? here is an example:
    JPanel grid = new JPanel();
    grid.setLayout (new GridLayout(16,16));
    Container content = frame.getContentPane();
    ImageIcon icon = new ImageIcon("picture.gif");
    JButton[][] element = new JButton[16][16];
    for ( i = 0; i < 16; i++ )
    for ( j = 0; j < 16; j++)
    grid.add(element[i][j].setIcon(icon));
    content.add(grid);
    is that correct at all? it returns this error:
    'void' type not allowed here
    grid.add(elem[i][j].setIcon(icon));
    the caret points to the open parenthesis in setIcon(icon).
    if an array of JButtons doesnt work at all, is there an alternative? my program allows the user to arrange various bricks, etc. to create a maze.

    A 2-dimensional array of JButtons is perfectly possible, provided you write valid Java code. That's all the compiler is complaining about. And also, you forgot to create any button objects to go in the array. Try something like this:for ( i = 0; i < 16; i++ ) {
      for ( j = 0; j < 16; j++) {
        element[i][j] = new JButton();
        element[i][j].setIcon(icon);
        grid.add(element[i][j]);
    content.add(grid);That will get you started. Of course those buttons won't do anything until you add listeners to them, but that's your next challenge, I suppose.
    (By the way, there's a bug in the code that runs this forum. Wherever you see "<i>" in the code, alter it to use the correct rectangular brackets.)

  • Is it possible to make an array of JButtons?

    is it possible to make an array of JButtons?

    Note that this doesn't create any JButtons, just the array!

  • My iphone 6 turned off while i was using face time and it returns with the screen saying Hello mean its reset automatically how is this possible ? Now it requires an id and password to activate which i do not remember need help ?

    My iphone 6 turned off while i was using face time and it returns with the screen saying Hello mean its reset automatically how is this possible ? Now it requires an id and password to activate which i do not remember need help ? but i do remember the id and password which i was using on itunes and Apple store. please i almoost buy it in 890$ so it will be a big lost please help me.

    shahzadfromlahore wrote:
    Now it requires an id and password to activate which i do not remember need help ? but i do remember the id and password which i was using on itunes and Apple store. please i almoost buy it in 890$ so it will be a big lost please help me
    Who set up the phone? Who's Apple ID was used to activate it?

  • I would like to change the current song from the pull down tab so that I don't have to exit whatever app I'm in, return to music and change it. Is this possible?

    I would like to change the current song from the pull down tab so that I don't have to exit whatever app I'm in, return to music and change it. Is this possible?

    Try double clicking the Home button and then swipe the bottom row fully to to the right to get to the music control

  • I Need to Return Two values or more from Function, Is this possible?

    Below is the offending query, I am trying to pass v_bu and v_po to this function, and after validations then return v_count and v_action is this possible in a function? I am having problem returning two values.
    see below code
    function po_edi_func(v_bu purchase_order.business_unit_id%type,
         v_po purchase_order.purchase_order_number%type)
         return number as pragma autonomous_transaction;
         v_count               number;
         v_ctdel               number;
         v_action          varchar2(1);
    begin
    select count(*)
    into v_count
    from sewn.purchase_order
    where business_unit_id=v_bu
    and purchase_order_number =v_po;
    if v_count > 0 then
         select count(*)
         into v_ctdel
         from sewn.purchase_order
         where business_unit_id=v_bu
    and purchase_order_number =v_po
         and purc_orde_status = 1;
         if v_count <> v_ctdel then -- ALl PO's Cancelled--
         v_action := 'U'; -- - NOT ALL PO DELETED --
         else
         v_action := 'D'; -- DELETED ALL PO--
         end if;
    else
         v_action := 'I';-- New PO INSERT--
    end if;
    commit;
    return v_count;
    end;

    Paul,
    This is becoming a nightmare to me, can you look at the below and tell me where I am having a problem
    This is the Function below
    CREATE OR REPLACE function po_edi_func(v_bu sewn.purchase_order.business_unit_id%type,
         v_po sewn.purchase_order.purchase_order_number%type,v_action_out OUT VARCHAR2)
         return number as pragma autonomous_transaction;
         v_count               number;
         v_ctdel               number;
         v_action          varchar2(1);
    begin
    select count(*)
    into v_count
    from sewn.purchase_order
    where business_unit_id=v_bu
    and purchase_order_number =v_po;
    if v_count > 0 then
         select count(*)
         into v_ctdel
         from sewn.purchase_order
         where business_unit_id=v_bu
    and purchase_order_number =v_po
         and purc_orde_status = 1;
         if v_count <> v_ctdel then -- ALl PO's Cancelled--
         v_action := 'U'; -- - NOT ALL PO DELETED --
         else
         v_action := 'D'; -- DELETED ALL PO--
         end if;
    else
         v_action := 'I';-- New PO INSERT--
    end if;
    commit;
    v_action_out := (lpad(v_count,8,'0')||lpad(v_action,1,' '));
    return v_action_out;
    end;
    and this is how I am calling it from my trigger which has to pass the v_bu and v_po values to be used in extracting data and returning the records
    see below
    if po_edi_func(v_bu,v_po) <> '' then;
    v_count:= (substr(v_action,1,8));
    v_action := substr(v_actione,9,1);
    else
    v_count:=0;
    v_action := 'I';
    end if;
    I need the extracted values of v_count and v_action for my app to reset some values

  • How to define method  witch returning an array in View, using method wizard

    Dear experts.
    I would  like to define method  which returning an array in View.
    When View is opened, in "Methods" tab push "new" button, then select "Method" in Method Type window,
    push "Next" but in Method Properties window Array Type checkbox is disabled. So, it is not possible to
    define method with returning array type.
    Please anybody, help me to resolve this problem.

    Hi
    While creating method, you can see a check box over there as array type just check it that array type check box,
    or
    You can selet java native type as array by selecting "java native type"
    thanks
    anup
    Edited by: Anup Bharti on Oct 15, 2008 8:50 AM
    Edited by: Anup Bharti on Oct 15, 2008 8:51 AM

  • Using NetBeans Matisse to build a form with an array of JButtons

    With Matisse I can build a form with a lot of buttons on it, but i want to use a 2-dim array of JButtons so that I can easily access the buttons. How should I do this?

    Code it by hand. It's not that hard.
    JButton [][]buttons = new JButton[NUM_ROWS][NUM_COLUMNS];
    for (int row = 0; row < NUM_ROWS; row++) {
       for (int row = 0; row < NUM_ROWS; row++) {
          buttons[row][col] = new JButton();
          // set other properties of buttons[row][col]
    }If there is a lot of stuff, you could even make a separate method for creating a single button:
    private JButton createButton()
       JButton button = new JButton();
       // whatever else
       return button;
    }Then, in the "for" loops:
    buttons[row][col] = createButton();

  • Is this possible with Boxes?

    Hi,
    I am currently using a Horizontal Box to group a JLabel, 3 JTextFields and a JButton in a row. (it is a date entry field, with a pop-up calendar that is activated by the button.)
    It looks exactly how I want it, EXCEPT that I need to make an exact replica of those objects, so the top fields will be used as a date search function FROM X date and the bottom fields will be the TO X date.
    However, I cannot find a way to move the "search TO date" fields one line down or below the "search FROM date" fields.
    Is this possible? Because right now my GUI looks rather silly with 10 objects horizontally spanning my screen.
    Thanks in advance.

    You will need to use multiple components.
    You probably want something like:
    Search from:
    Search to:
    [          ] [          ] [           ]It may be a good idea to use combo boxes with fixed
    values instead of textfields. If you use textfields,
    then you'll have to verify the input.I'm quite happy using textfields as I have already written two classes that verify the type of input and limit the amount of characters entered.
    So you'll have 4 components (1 for each horizontal
    row).
    Then you can create another box, but this time
    vertical:
    Box box = new Box(BoxLayout.Y_AXIS)
    and then add the 4 components to the box.I dont really understand this part.
    So, you are saying I should make 2 horizontal boxes and then put them in a vertical box?
    And what is that syntax? As far as I know, you create a box using:
    Box box  = Box.createVerticalBox();Thanks for the prompt reply.

  • Information from formula that returns an array is not shown on chart

    Hello experts,
    I have a chart (combination) which should show information from a group of cells that have a formula in it and returns an array ().
    {=SUM((Plan1!L2:L43=L2)(Plan1!I2:I43=D3)Plan1!M2:M43)}
    In the spreadsheet and on the chart, while developing the dashboard, it shows perfectly.
    What happens is that while previewing.....no data is shown at all on the chart.
    Please advise on how to solve it.
    Carlos Henrique Matos da Silva - SAP BusinessObjects BI - Brazil.

    Hi Carlos,
    Excel Array entered formulae are not supported in Xcelsius.
    When you are designing the dashboard Xcelsius is using native Excel functrionality and calculation engine to display the results.  When you preview the dashboard Xcelsius convertys all of the spreadsheet formulae to Flash/ActionScript which does not have the equivalent array functionality, adn so when previewed the results do not show.
    Hope this helps
    Charles

  • Returning an array type from a local method in Web Dynpro Java application

    Hi,
    In my project, we have a requirement to display 18 rolling months along with the year, starting from current month.
    How I am going to approach is that I will get the system date and get the current month and send the month and year value to a local method which will return 18 rolling months along with the year.
    But, when I tried to create a new method there is no option to return an array type. It was greyed out.
    So, we can not return an array type from a method from Web Dynpro for Java application?
    If so, what is the alternative and how am I going to achieve it?
    I will appreciate your help!
    Regards
    Ram

    HI
    You can create new methods in
      //@@begin others
      private ArrayList MyMethod(){
           // ** Put your code here
           return new ArrayList();
      //@@end
    Other option are create a context node with cardinality 0...n with one or more attributes, and in your method create the needed registers into this node. To read this values, you only need to read your context node.
    Best regards
    Edited by: Xavier Aranda on Dec 2, 2010 9:41 AM

  • BPEL build error when invoke an extrenal Web Service that returns an Array

    Hello,
    I built with JDeveloper a web service that returns an Array of Java Bean classes and I try to invoke this web service from a BPEL process. The wsdl file is automatically generated by the JDev. When I built the BPEl project I obtained the following error:
    [bpelc] [Error] :-1:-1: src-resolve.4.2: Error resolving component 'SOAP-ENC:Array'. It was detected that 'SOAP-ENC:Array' is in namespace 'http://schemas.xmlsoap.org/soap/encoding/', but components from this namespace are not referenceable from schema document 'http://malangiu-ro:8988/cde-Project-context-root/CdeFactoryWS?WSDL'. If this is the incorrect namespace, perhaps the prefix of 'SOAP-ENC:Array' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'http://malangiu-ro:8988/cde-Project-context-root/CdeFactoryWS?WSDL'.
    [bpelc] [Error] :-1:-1: src-resolve.4.2: Error resolving component 'SOAPENC:Array'. It was detected that 'SOAPENC:Array' is in namespace 'http://schemas.xmlsoap.org/soap/encoding/', but components from this namespace are not referenceable from schema document 'http://malangiu-ro:8988/cde-Project-context-root/Top300FactoryWS?WSDL'. If this is the incorrect namespace, perhaps the prefix of 'SOAPENC:Array' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'http://malangiu-ro:8988/cde-Project-context-root/Top300FactoryWS?WSDL'.
    [bpelc] [Error] :-1:-1: src-resolve.4.2: Error resolving component 'SOAP-ENC:Array'. It was detected that 'SOAP-ENC:Array' is in namespace 'http://schemas.xmlsoap.org/soap/encoding/', but components from this namespace are not referenceable from schema document 'http://malangiu-ro:8988/cde-Project-context-root/CdeFactoryWS?WSDL'. If this is the incorrect namespace, perhaps the prefix of 'SOAP-ENC:Array' needs to be changed. If this is the correct namespace, then an appropriate 'import' tag should be added to 'http://malangiu-ro:8988/cde-Project-context-root/CdeFactoryWS?WSDL'.
    Any hint? Thanks in advance!
    Regards,
    Marinel

    Hi,
    BPEL and BPEL PM do not have a good support for SOAPENC-Array: it would be very difficult to create such an array in BPEL or to receive it and manipulate it.
    The (unfortunately very intrusive) work around is to change the WSDL of the service to use a XML type defined using XML schema. This is all the more painful that JDev 9.0.4 does not have strong support for complex types.
    In general though, I would highly recommend this best practice:
    1) Start by define the WSDL contract first
    2) Then generate the server side skeleton to implement it
    3) Use BPEL as the client to this contract.
    By starting with the contract first, you make sure that 1) your interfaces are clean and coarse grained.
    2) things like java objects, sessions, etc to not leak through the interface (which would be the worst thing that could happen because it would closely link the client and the server.
    Sorry for not being more helpful. This will get radically cleaner in Oracle AS 10.1.3.
    Edwin

  • Lost Mode and Play Sound are "Pending."  However, iCloud indicates that it connected and backed up to iCloud at a date that is 1 week after it went missing.  How is this possible without locking (Lost Mode Pending an internet connection)

    Hi,
    My wife lost her iPhone two weeks ago while on vacation in London (cell service inoperative in foreign country).  Using Find My iPhone app on my device, I activated Lost Mode and Play Sound.  However, both are listed as "Pending," since it those actions require the phone to connect to the internet (wifi only due to no cellular data coverage.).
    We recently returned home and purchased a new iPhone.
    However, when looking to restore the apps/settings from her old phone using a previous iCloud backup, iCloud indicates that the old phone connected to iCloud and backed up the original phone at a date that is 1 week after it went missing.  How is this possible without locking (Lost Mode Pending an internet connection)?
    If the phone was activated and connected to the internet via a wifi signal, shouldn't it immedately lock, show up on the map, Play Sound, and send me an email that the phone has been found?
    I also read somewhere that if running iOS 7, the iCloud website interface enables you to track previous locations, for instance if the phone moves from wifi hotspot to hotspot.  Is that true?  If so, how do I do that?
    Thank you for your time, and have a great day!
    Sincerely,
    - Matt

    just giving this a wee bump as time is of the essence here and i need advice/ answers quick!
    apologies if i've broke any rules!
    alex

  • I need to rotate a string indicator 90 degrees. Is this possible

    To make my front panel less cluttered, I would like to have my string indicator rotated 90 degrees counter clockwise. Is this possible and if so will I be able to place it in an array of strings? Any and all help is greatly appreciated.

    pcardinale wrote:
    So just color the indicator transparent, and feed the text to the caption (i.e. use the caption as an indicator).
    Paul Cardinale
    While fundamentally, this would provide a potential work-around.  I find it morally objectionable Whats next? tategaki?
    Jeff

  • HT1386 I am trying to sync my iPod Touches calendar to my MacBook Pro calendar. I have been successful at syncing the events from my MacBook Pro's iCal to the iPod but haven't been able to sync the events from my iPod to my MacBook Pro. Is this possible?

    I have an iPod touch that I often use to manage different events for work. I have been able to sync the events on my calendar from my MacBook Pro to the iPod touch successfully using wifi. What I really need to do though is sync my iPod calendar events to my MacBook Pro calendar. Is this possible? How do I set this up? It would be a huge help if I could transfer the events on my iPod calendar to my computers calendar. I currently have the wifi sync option on and have turned on the sync calendars option in iTunes. Thank you for your help!

    For resetting the sync history on a Mac running Lion - 10.7.x if needed.
    http://support.apple.com/kb/TS1627
    If you see the Sync menu in the menu bar, skip to step 3: 
    If you do not see the Sync menu in your menu bar, skip to step 7.
    Hold the Option key on your keyboard, then click the Sync menu in the menu bar:   
    if you see the Sync menu but you are unable to open it, skip to step 8.
    Choose Reset Sync Services.
    Click Reset Sync History.
    Test for the original issue. If the issue persists, or if you are unable to open the Sync menu, follow these steps:
    In the Finder, choose Utilities from the Go menu.
    Open Terminal.
    In the Terminal window, type or paste the following command on a single line:
    /System/Library/Frameworks/SyncServices.framework/Versions/A/Resources/resetsync .pl full
    Press Return.
    Quit Terminal after the operation has completed (when Terminal returns to the command prompt with a $).

Maybe you are looking for

  • How to connect my ipad to a beamer?

    How to connect my ipad to a beamer?

  • Photos are cropped after being shared from Photos App

    So, I wanted to share Photos from my Photos App using iCloud shared albums. I have iCloud Photo Library enabled. All the photos I want to share are perfectly uploaded to iCloud, as I checked them on my iPhone. But when I created the shared album, som

  • Compiling JSP within a WAR cannot find classes

              I have developed a WAR file containing a trivial JSP that simply invokes functionality contained within           a Java class. The WAR file is registered without a problem, and unpacks my libraries and classes to           C:\weblogic\myse

  • Still Getting Buffering Issues and Slow Web Page L...

    Since I suspect this issue hasn't gone away - and I/we have been asked to post issues individually rather than clumping into a single tread. I just got back from Spain and after quizzing family it seems we are still getting Stream Buffering Issues (a

  • Threads with servlets

    Best groupmember, I have a jsp and a servlet. The jsp includes the servlet. The servlet looks like this: class TheServlet extends HttpServlet { private String myFirstname = ""; private String myLastname = ""; public void doPost(......) { //Loads of t