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!

Similar Messages

  • Is it possible to make a 2D array (or whatever-dimension) array like..

    Is it possible to make a 2D array (or whatever-dimension) array like this...
            collumn 1                   collumn 2
    Emulated Address   Real Memory address*
               (int)                            (int *)
    +----------------------+----------------------------+
    |            0                |              0xA0               | <-- row 1
    |            1                |              0xA1               | <-- row 2
    |            2                |              0xA2               | <-- row 3
    +----------------------+----------------------------+
    * A = Address.
    is it possible to make an array like that?
    if it is, please tell me how to do it...
    thanks.
    ... I'm trying to make an emulator to emulate the simplest memory.

    Given your other posts, I'm assuming you mean in C, right?
    If so, the answer is yes, but specifically how will depend on a needed clarification of your question.  What you present doesn't really need to be a 2 dimensional array, just one: that looks like a simple list of memory addresses, right?
    At the simplest you can declare an array with two dimensions `iny myarray[2][3];` but to make the table you put up there you'd only need `int *myarray[3];`
    If you also wanted space allocated somewhere that each element of that list pointed to, you could allocate them separately:
    int *myarray[3];
    myarray[0] = (int *) malloc(sizeof(int));
    myarray[1] = (int *) malloc(sizeof(int));
    myarray[2] = (int *) malloc(sizeof(int));
    Obviously with many entries this should be in a loop.  Perhaps not as obviously, why would you not just malloc a larger block of memory to start with?
    What is the end goal?
    EDIT: actually, upon rereading your question, the mallocs are probably irrelevant.  `int *myarray[3]` will get you the array you are looking for.  Just realize that until you point those pointers to memory you 'own' you shouldn't assign to or read from them.
    Last edited by Trilby (2013-04-19 10:06:31)

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

  • Possible to make arrays of JLabels?

    I would like to make arrays of JLabels, Iconimages, and Jpanels, but I can't find how to do it.
    Is it eaven possible?
    How can I proceed instead...?

    Why not????
    Infact you can make an array of any premitive type or of any object... Just you need to use this syntax...
    dataType[] arrVarName = new dataType[size];
    for example,
    JLabel[] lblArr = new JLabel[10];
    This will create the new array of JLabel type of 10 elements size... You can initialize each element like this:
    for(int i = 0; i < lblArr.length; i++){
    lblArr[i] = new JLabel("Hello " + i);
    and you can print each element like this:
    for(int i = 0; i < lblArr.length; i++){
    System.out.println(lblArr.getText());
    Okay... Still if you are having any doubt you are always welcome

  • Is it possible to make an ImageIcon array?

    Hi, I have been having some strange problems with ImageIcon...
    Here is my code...
    ImageIcon tiles[][] = new ImageIcon[5][5];
    tiles[0][0] = "1.png";
    I know this is not right, but basically, I want to make a 2dimensional array of imageIcon's, and then use a loop to set the link to the image. This is tough because I have not had any luck with this code. It works on strings, int's, float's, etc. but not on ImageIcon's grrrrrrr
    thanks

    All I want to do, Is make an array of ImageIcon's and then use a 2dimensional loop to draw all the tiles.
    problem one: I want to use a loop to create each individual ImageIcon, and since there is no "setfile" kind of function i tried making my own in the post above. But im simply trying to make a loop which sets all of the tiles to appropriate file names. (all the file names are numbers and then .png)
    Thats all I want to do, and I want to pass a parameter to a function which tells it the filename to set, and the specific ImageIcon in the array to modify. Hence why I had 2 paramater strings in the previous post

  • Is it possible to make a code editor in Java?

    I'm new to java and so i'd like to know if it would be possible to make a simple code editor for Mobile Phones with Java.
    The code editor will be for GML.
    I'd like to make it so that the code can be easily edited on a wide range Mobile phones (not necissarily smart phones).
    If this is possible, I would greatly appreaciate any help or advice. Thanks.
    skinnyeddy

    TuringPest wrote:
    Hippolyte wrote:
    skinnyeddy wrote:
    "first list the areas in which you are proficient" - I'm not. I thought it would be easy to make a simple text/code editor in java without any experience. That was a bit of a mistake. Looks like I'll have to learn the hard way :SIMHO, one should woodshed it, work on programming basics and object-oriented programming fundamentals, in Java for at least one year before attempting to write any GUI code. Even day in this forum we see what code looks like when this advice is not followed.my first java code 5 years ago was an applet with a changing 2d function being animated.
    it worked after 2 grueling days and i was so happy because visual feedback was my only motivation.
    so its hard to say. granted, my code was awful for a long time.I'm thinking of the guy last week who had Swing+JDBC code and kept pestering for help on an obvious syntax error (he was invoking a method with no arguments when it was defined to take a String array) and for the life of him, he couldn't see the error or understand the error message. Posters kept telling him to learn the fundamentals first, but he was stubborn and kept demanding someone fix his syntax error...

  • Is it possible to make a move in contouring mode with onboard program

    I use Labview 7.1.
    I have a motion board 7344.
    Is it possible to make a move in contouring mode (as in the attached vi) with onboard program and how do that?
    Attachments:
    Onboard_program.vi ‏79 KB

    It's not possible to use the contouring mode in an onboard program like you did it in your example. The reason is that while the program is downloaded the write buffer.flx is NOT executed. Thus it can't download the buffer data stored in your front panel arrays. When you start the onboard program later it doesn't have access to your buffer data on the front panel.
    In fact I don't see a real advantage why you would like to run the write buffer.flx in an onboard program. You could configure and download the buffer on the host and then use it in an onboard program.
    Best regards,
    Jochen Klier
    NI-Germany

  • Is it possible to make the automatic scroll go left to right instead of top to bottom?

    Hi all,
    I find it hard to follow text when adobe is scrolling from top to bottom. Is there any way to make it scroll left to right instead?

    user13392320 wrote:
    Is it possible to make ODI process a source row by row instead of as a dataset?Yes it is, the Agent acts like a SQL cursor if you use a select on the source tab (in the IKM) and an insert on the target tab (same step in the IKM) it will read it row by row. You can tweak the batch fetch array sizes in the Agent configuration.
    user13392320 wrote:
    To make changes to the target table I need to join the source table to the target table. I want to process source records in a particular order. What will be loaded from the current source record will depend on the previously loaded, related source record, during this some run of my ODI job. And ideas? Thanks!Cant see why you cant drag the target table onto the source datastores and join them - carefully choose where you want the join to take place (probably in the target). If you want to order the records there are some Knowledge Module tweaks to specify an order by clause using the UD1 -> UD5 flags on a datastore. Search the forum or google for the code.
    Hope this helps.
    Alastair

  • Is possible to make Serializable a Connection object?

    Hi I would like to know if is possible to make Serializable a Connection Object, I would like to save the Connection object into a text file so other class can read it and execute a proper query. If is possible how can I do it?.
    Thanks.

    Actually, if a class isn't already Serializable, you can't make it become Serializable reliably. Consider the following case:
    class A
        int x = 0;
        public void setX(int new_x) { x = new_x; }
        public int getX() { return x; }
    class B extends A implements Serializable
        int y = 0;
        public void setY(int new_y) { y = new_y; }
        public int getY() { return y; }
    public static void main(String arg[]) throws Exception
        B b = new B();
        b.setX(10);
        b.setY(12);
        someObjectOutputStream.writeObject(b);
    }The problem with this is that the implementation of Serializable by class B does not affect class A. In the above example, the ObjectInputStream that obtains the instance of B will have a y value of 12, but an x value of 0 (not 10).
    Thus, unless the Connection object implemented Serializable to begin with, it can't become Serializable. And, as the above post has described, the implementers of the Connection object would not make it Serializable as the local Connection object uses underlying O/S resources which cannot simply be transformed into a byte array.

  • 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 alert message.

    Hi,
    Anyone knows if it Is possible to make an alert-message that pops up ( f.e as a little window) on a specific day to remember me of something I have to do that day?
    Would be handy.
    Is this possible with Tiger or is there a third party application that does the trick?
    Thanks in advance.

    Try a free widget called quikAlert
    http://www.apple.com/downloads/dashboard/business/qwikalert.html
    Regards
    TD

  • Is it possible to make a copy of the Leopard install DVD?

    Is it possible to make a copy of the Leopard install DVD? If so, is there a special way this has to be done? I just found out that we needed to use the Leopard install DVD to recover a complete backup from Time Machine after a recent hard drive failure. We have the family pack of Leopard, so I would like to keep the original at home and send a copy when my daughter goes off to college in case she needs to recover again. Her machine was originally a Tiger MacBook, so those install disks will not work. If it is not possible to copy the DVD, is there a way to create a bootable utility to do a time machine recovery?

    This half-solved my problem. I have had no problems creating a backup copy for my intel based computers, but non-intel based computers are problematic; a G5 powermac tower and a G4 Powerbook. Both with super drives for single density burning. Both have Leopard running, installed from an install disc purchased from Apple. However, neither will mount the copy, but intel based computers will. have burnt/burned with both toast 9 and Disc Utility. Discs won't mount and are "spit out" by the drive.
    Power Mac G5 OS X: 10.5.4
    Model Identifier: PowerMac7,3
    Processor Name: PowerPC G5 (3.0)
    Processor Speed: 2 GHz
    Number Of CPUs: 2
    L2 Cache (per CPU): 512 KB
    Memory: 1.5 GB
    Bus Speed: 1 GHz
    Boot ROM Version: 5.1.8f7
    Any thoughts?
    -Jim

  • I am trying to find out if I can change a setting of the calendar in my iPhone.   When I view calendar, in month, I would like to view it with the starting day of the week being Monday, not Sunday.  Is it possible to make this change? SS

    I am trying to find out if I can change a setting of the calendar in my iPhone. 
    When I view calendar, in month, I would like to view it with the starting day of the week being Monday, not Sunday.  Is it possible to make this change?

    Hello SMEvans32
    You can use iCloud to share the Calendar, that way she will always be up to date on that particular section of your work calendar. If you want to use iCloud, I would recommend backing up so you have a safe copy of your data.
    iCloud: Calendar sharing overview
    http://support.apple.com/kb/PH2689
    iCloud Setup
    http://www.apple.com/icloud/setup/
    Thanks for using Apple Support Communities.
    Regards,
    -Norm G.

  • Is It Possible to Clone RAID Array in a Safe and Easy Way?

    Why do computer users need to clone RAID array, especially Windows Server users need to do RAID cloning? Generally speaking, they need to clone RAID array regularly in order to upgrade disk or migrate data from small disk to a larger one. A typical
    example is that when the partitions on the hardware RAID runs out of space, you may prefer to rebuild the hardware RAID with larger hard disks. Then, you need to backup the data to another place, rebuild the hardware RAID and restore data again.
    What a time-consuming task!
    Is it possible to clone RAID array in a safe and easy way? The answer is yes and this article will introduce a RAID cloning software.

    Hi jiangchunli,
    Were you looking to post this question in some other forum? This looks like related to RAID and Disk upgrades.
    This forum is meant for
    http://www.windowsazure.com/en-us/services/recovery-manager/
    Please let us know if this is indeed Hyper-V Recovery Manager related so we can help better.
    Thanks
    Praveen
    Praveen/ www.PraveenKumar.in

  • Top-Level Navigation Bar - Is it possible to make it 3 levels?

    Dear Portal Experts,
    Could someone please advise if it is possible to make the Top-Level Navigation Bar show more than 2 menu levels?  I looked at the document and it said we can only have 1 or 2 levels.  But I'm just wondering if there is any way around it.  Thanks.

    yes you are right .we can set only 1 0r 2 levels but good news is there is a workaround
    follow this blog
    Tag  Libraries: Creating a Hover Menu in SAP NetWeaver Portal
    reward points if helpful

Maybe you are looking for