JLabel on JButton does always show ...

Hi guys, i tried the following stuff
myButton.setPreferredSize(new Dimension(100,60));
          myLabel = new JLabel("");
          myLabel.setPreferredSize(myButton.getPreferredSize());
          myButton.add(myLabel);the problem is whenever i access the
myButton.myLabel.setText("sometext"); via my actionlistener it sets its text to ... instead of showing me its content
and i am sure the content would fit as its a THREE CHAR code...
thanks in advance
PS: i generate a grid of buttons with " " caption, when someone clicks the button the text on the button changes! (i use JLabels cause i want to exchange the changing text to images later!)

i moved one step further and put the images in already
works like charm and does what i expect it to do
i saw that JButton can hold an icon without jlabel (dunno why i overlooked this the day before...)
you are right, i can add the actionlistener to the class and assign the class itself.
further i replaced Applet by JApplet and the refrehs works with any more line of code... only had to change the import and add the J infront of Applet nice
thanks for your help!!
here is my 'final' code
package wii.tanks.leveleditor.view;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
//import java.awt.Component;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Color;
import java.awt.event.*;
import javax.swing.ImageIcon;
import java.net.URL;
import java.awt.Dimension;
// information from normal wii.tanks.model.Entity
class lvlEntity extends JButton implements ActionListener {
     final static long serialVersionUID = 1;
     public int currentEntity = 1;
     private JLabel myLabel;
     public int height = 0;
     public int destroyable = 0;
     public static final int NORMAL = 0; // floor
     public static final int BOX_NORMAL = 1;
     public static final int BOX_REFLECTS = 2;
     public static final int BOX_EXPLODES = 3;
     public static final int BOX_CRUSHER = 4;
     public static final int HOLE = 10;     // can't pass you will die instantly
     public static final int MUD = 11;       // pass-able but will slow you down
     public static final int[]       i_entities = {lvlEntity.NORMAL,     lvlEntity.BOX_NORMAL,     lvlEntity.BOX_REFLECTS,     lvlEntity.BOX_EXPLODES, lvlEntity.BOX_CRUSHER, lvlEntity.HOLE, lvlEntity.MUD};
     //public static final String[] s_entities = {"  ",                    "",                         "<B>",                         ">B<",                          "}B{",                          "(O)",                "MUD"};
     public static final String[] s_entities = {"1","2","3","4","5","6","7"};
     public static final String[] src_entities = {"FLOOR_1.png", "BOX_NORMAL_1.png","BOX_REFLECT_1.png","BOX_EXPLODES_1.png","BOX_CRUSHER_1.png","HOLE.png","MUD.png"};
     public static ImageIcon icon_entities[] = null;     
     public lvlEntity() {
          JPanel pane = (JPanel)this.getParent();
          this.setIcon(createImageIcon("file:///"+System.getProperty("user.dir")+"\\wii\\tanks\\leveleditor\\res\\"+src_entities[0], src_entities[0]));
          this.addActionListener(this);
     /** Returns an ImageIcon, or null if the path was invalid. */
     protected ImageIcon createImageIcon(String path, String description) {
          try {
          URL imgURL = new URL(path);
          if (imgURL != null) {
          return new ImageIcon(imgURL, description);
          } else {
          System.err.println("Couldn't find file: " + path);
          return null;
          } catch (Exception e) {System.out.print(e.getLocalizedMessage());}
          return null; // you never reach this
     public void actionPerformed(ActionEvent e) {
          lvlEntity src = (lvlEntity)e.getSource();
          src.setIcon(createImageIcon("file:///"+System.getProperty("user.dir")+"\\wii\\tanks\\leveleditor\\res\\"+src_entities[currentEntity], src_entities[currentEntity]));
          System.out.println("file:///"+System.getProperty("user.dir")+"\\wii\\tanks\\leveleditor\\res\\"+src_entities[currentEntity]);
          currentEntity = (currentEntity+1)%(s_entities.length);
/*public*/
class BattlefieldGui extends JPanel{
     final static long serialVersionUID = 0;
     Font font;
     public BattlefieldGui(int aSizeHeight, int aSizeWidth) {
     setLayout(new GridLayout(aSizeHeight, aSizeWidth));
     font = new Font("Helvetca", Font.PLAIN, 12);
     for (int i =1; i<=aSizeHeight;i++) {
          for (int j =1; j<=aSizeWidth;j++) {
               addEntity(i+"|"+j);
     void addEntity(String name) {
          lvlEntity entity = new lvlEntity();
     entity.setBackground(new Color(120,120,120));
     entity.setName(name);
     setFont(font);
     add(entity);
     public class Battlefield extends JApplet {
     public void init() {
     add(new BattlefieldGui(17,17));
     this.setSize(440, 600);
Edited by: [email protected] on Dec 31, 2007 3:47 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • When I try to sync my music on my iPhone 4 I have a tab at the top that says 'on this iPhone' The music in that tab is always on my phone but does not show in my itunes library.  How can I get it into my library?

    When I try to sync my music on my iPhone 4 I have a tab at the top that says 'on this iPhone'.  This is at the end of all the other tabs like info, ringtones, music etc. The music in that tab is always on my phone but does not show in my itunes library.  How can I get it into my library?  It doesn't sync either.

    The new iTunes has a somewhat different look from the previous version.  You can get the old look back if you prefer it by doing View > Show Sidebar in iTunes.  Or you can adapt to the new look.

  • My iphone 5 does not show callid when there is a call, i used to get it but after my trip to China, the cller id is always unknown, how can I get it back? thanks

    Hi
    My iphone 5 does not show callid when there is a call, i used to get it earlier but after my recent trip to China, the cller id is always shows unknown, how can I get it back? thanks

    Thanks Malcom,  I was able to restablish the caller id feature through the carrier as you suggested

  • [svn] 3459: Fix FB-14050: Watchpoints: Debugger stack does not always show correct 'Suspended' message when at a Watchpoint.

    Revision: 3459
    Author: [email protected]
    Date: 2008-10-02 14:09:16 -0700 (Thu, 02 Oct 2008)
    Log Message:
    Fix FB-14050: Watchpoints: Debugger stack does not always show correct 'Suspended' message when at a Watchpoint.
    Ticket Links:
    http://bugs.adobe.com/jira/browse/FB-14050
    Modified Paths:
    flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/DManager.java
    flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/DProtocol.java
    flex/sdk/trunk/modules/debugger/src/java/flash/tools/debugger/concrete/PlayerSession.java

    Hi Experts,
    After i tried a few times, i can successfully start prepare with upgrade asistant monitor - Administrator >> Start Prepare,
    Thanks

  • It downloads version 4.1 - but does not install it and always shows this as Firefox 4.0 - Yahoo edition. Moreover the tabs open when I close firefox do not open when I start next.

    Question
    It downloads version 4.1 - but does not install it and always shows this as Firefox 4.0 - Yahoo edition. Moreover the tabs open when I close firefox do not open when I start next. edit
    Details

    Download the official version of Firefox 4.0.1 here: <br />
    http://www.mozilla.com/en-US/firefox/
    Then un-install that Yahoo branded version and install the official version.

  • I use an iPod nano 5th generation. I have had it for 2 years now and then after about a year when I plugged in my iPod to my computer, the iPod is read but the tab where I would always go that showed my list of artists to sync to my iPod does not show up

         I use an iPod nano 5th generation. I have had it for about two years now and after about one year, I plugged in my iPod into my computer to sync more music. Here is the problem: The tab where you go to sync music to your iPod and shows the list of artists and songs you want to sync to the iPod, the tab I can get to but the list of songs and artists does not show up and the only way I can sync music to my iPod is to basically wipe my iPod and start from scratch. Obviously, I do not want to do that because I do not have all the songs in my library that I have on my iPod. I have uninstalled iTunes and then re-installed it, but it did not work and I do not know what else to do. I would really appreciate helpful guidance to get it fixed if it can be fixed. Thanks in advance

    http://support.apple.com/kb/TS1591
    There have been some problems accessing pages on the Apple web site.  If the hyperlink gives you a "We're sorry" message, try again.

  • Why does itunes always show my iphone as connected when it is not

    When I plug in one of our Apple devices to sync to our home computer, etc., iTunes shows the device I want to sync, but it also always shows my iphone as plugged in too. (At the top where it says Devices). Not a big deal, but is there a way to remove this instead of always hitting the eject button?

    Do you have wifi sync enabled for those devices?
    Select the device, click the Summary tab.
    If it is enabled, there's no need to eject the device, even with the cable plugged in.

  • JLabel and JButton both disappear under Mac OS X

    Hello all,
    In my application I have two JButtons and a JLabel. When I compile and run the application the resulting window always shows the first button to begin with but doesn't show the second button until the window loses focus then gains it, or until I click where the second button was suppose to be. Regardless, the JLabel never appears. I've run this on both Windows and Linux now and everything appears as they should. Any thoughts?

    Sorry, I'm still new to these forums.
    import java.util.Locale;
    import java.util.ResourceBundle;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.KeyEvent;
    import java.io.*;
    import javax.swing.*;
    import com.apple.eawt.*;
    public class railsservermanager extends JFrame
         private Font font = new Font("calibri", Font.BOLD, 36);
         protected ResourceBundle resbundle;
         protected AboutBox aboutBox;
         protected PrefPane prefs;
         private Application fApplication = Application.getApplication();
         protected Action newAction, openAction, closeAction, saveAction, saveAsAction, undoAction, cutAction, copyAction, pasteAction, clearAction, selectAllAction;
         static final JMenuBar mainMenuBar = new JMenuBar();     
         protected JMenu fileMenu, editMenu;
         public railsservermanager()
              super("");
              resbundle = ResourceBundle.getBundle ("strings", Locale.getDefault());
              setTitle(resbundle.getString("frameConstructor"));
              Container primaryContainer = this.getContentPane();
              FlowLayout primaryLayout = new FlowLayout();
              primaryContainer.setLayout(primaryLayout);
              createActions();
              addMenus();
              //Collect User's Project Directory
              final String usersproject = JOptionPane.showInputDialog("Please enter your project directory");
              //Initialize My Objects
              final ScriptManager scriptM = new ScriptManager(usersproject);
              final RunCommand runC = new RunCommand();          
              Action startAction = new AbstractAction("Start Server")
                   public void actionPerformed(ActionEvent evt)
                        String startPath = scriptM.createStartScript();
                        int exitstatus = runC.command(startPath);
                        //scriptM.deleteFile(startPath);
                        String result;
                        if(exitstatus == 0)
                             result = "Server Started Successfully.";
                             JOptionPane.showMessageDialog(null, result, result, JOptionPane.INFORMATION_MESSAGE);
              Action stopAction = new AbstractAction("Stop Server")
                   public void actionPerformed(ActionEvent evt)
                        String stopPath = scriptM.createStopScript();
                        int exitstatus = runC.command(stopPath);
                        //scriptM.deleteFile(stopPath);
                        String result;
                        if(exitstatus == 0)
                             result = "Server Stopped Successfully.";
                             JOptionPane.showMessageDialog(null, result, result, JOptionPane.INFORMATION_MESSAGE);
              JButton startserver = new JButton(startAction);
              JButton stopserver = new JButton(stopAction);
              JLabel apptitle = new JLabel(resbundle.getString("frameConstructor"));
              primaryContainer.add(apptitle);
              primaryContainer.add(startserver);
              primaryContainer.add(stopserver);
              setSize(310, 150);
              setVisible(true);
         }I hope this helps a little more.

  • How to always show rulers in Photoshop CS5 and other problems

    Does anyone know how to make Photoshop CS5 always show rulers in mac? I have not have this issue with any other PS. I need the rulers to drag guides contantly, but photoshop cs5 would not show the rulers automatically. Everytime I have to go to View --> Show rulers or the shortcut command + R. Is there a way to instruct Photoshop to always show rules with any file I open or create?
    I have many other issues with Photoshop CS5 that CS2, 3, and 4 had out of the box... It is very frustrating that I spent all this money and instead of working, I have been on the phone with Adobe for hours... I am very disappointed so far.
    I have had CS5 Master's Collection for 2 months now on Mac 10.6.7. I have reinstalled Photoshop 3 times as some shortcuts were not working like shift plus scroll to inscrease to 100%, 200%, etc.
    The other thing that still does not work and Adobe has not offered a solution is that my Photoshop would not append extensions. Regardless of the Preferences settings, all my files get saved as JPG instead of jpg... I wonder if any of you out there have this issue as well?
    Thank you.

    I believe my computer and its account are healthy. I just bought the mac pro with solid state and the only programs I have installed are the Master Collection CS5.
    I have good news though - After two months of waiting, I was finally able to speak with Adobe specialists yesterday and they changed the shortcut for Save As that Photoshop ships with from Command + Alt + S to Command + Shift + S - and miraculously now Photoshop appends extensions!!!
    However, my question about always displaying rulers remains. We got disconnected and I didn't have a chance to ask them (I was on hold for an hour and a half!)

  • When i download a new app on ipad it does not show up on iphone

    I have icloud turned on on my ipad and iphone but when i download a new app on my ipad or iphone it does not always show up on the other.  Its getting very aggravating and I have no idea how to fix this!!!!!!!!!

    Make sure the app is supported on both devices. Some apps are iPad only. Also make sure they are supported by the iOS version on each device if they are running different versions of iOS.
    Turn on automatic downloads on both devices:
    Settings > iTunes & App Stores > Select items you want to download automatically fom the Automatic Downloads section

  • New Content on my Tunes does no show up on Apple TV

    Apple TV 2.0 is great. I have it set so that everything on my macpro shows up on the Apple TV menus (streaming via 80211n).
    However, when I make a new purchase on itunes on my computer or rip a new CD, the new stuff does not show up in the Apple TV menus. It always used to show immediately on Apple TV under the old interface. The only way to make it show up is to physically restart my Apple TV every time..... tedious!
    Can anyone help.... cus it is frustrating!

    I was going to post a new thread about this, but came across this one. I think updating is completely non existent. I put a new video in my movies section in iTunes and have been watching and waiting for it to show up. It's past 36 hours at this point and still not there. This is really getting on my nerves. If it had always worked this way in version 1, I would have adjusted and not really thought about it further. But I don't get why they took the near instantaneous updating out. I'm really annoyed with having to load a 2 GB file for a few minutes, then walk back, restart iTunes, (or apparently I just need to sync it again manually) to see it show up.

  • Cisco Jabber for Windows always shows "Away"

    Cisco Jabber for Windows (9.0.1, CUPS 8.6.4, UCM 8.6.2, Exchange 2010) always shows status as "Away" for one user. Others seem to be working correctly showing "one the phone", "in a meeting", etc. Tried reinstalling client with no change. If you manually change to "Available", it changes right back to "Away". Anyone have an idea where to look (registry, logs, etc.)?

    I am seeing the same problem.  I haven't tried a different user to login on the same machine, but I did try closing my client on my primary machine (exited) and then logged in on a different computer with a fresh Jabber for Windows install. 
    I am running Jabber for Windows Version 9.0.2 Build 9453 on windows 7 64bit primarily, and Windows XP as the second test.  Running CUPS 8.6.4 in HA over WAN cluster mode with CUCM 7.1.5 and Unity Connection 8.5.1 ES 16.
    Phone presence information does still flow through when I pick up my phone hand set my status changes from Away to On a Call.
    When I check the presence diagnostic test for my user, it also reports that I am away.

  • Getting values from JLabel[] with JButton[] help!

    Hello everyone!
    My problem is:
    I have created JPanel, i have an array of JButtons and array of JLabels, they are all placed on JPanel depending from record count in *.mdb table - JLabels have its own value selected from Access table.mdb! I need- each time i press some button,say 3rd button i get value showing from 3rd JLabel in some elsewere created textfield, if i have some 60 records and 60 buttons and 60 labels its very annoying to add for each button actionlistener and for each button ask for example jButton[1].addActionListener() ...{ jLabel[1].getText()......} and so on!
    Any suggestion will be appreciated! Thank you!

    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class Testing
      public void buildGUI()
        final int ROWS = 10;
        JPanel[] rows = new JPanel[ROWS];
        final JLabel[] labels = new JLabel[ROWS];
        JButton[] buttons = new JButton[ROWS];
        JPanel p = new JPanel(new GridLayout(ROWS,1));
        final JTextField tf = new JTextField(10);
        ActionListener listener = new ActionListener(){
          public void actionPerformed(ActionEvent ae){
            tf.setText(labels[Integer.parseInt(((JButton)ae.getSource()).getName())].getText());
        for(int x = 0; x < ROWS; x++)
          labels[x] = new JLabel(""+(int)(Math.random()*10000));
          buttons[x] = new JButton("Button "+x);
          buttons[x].setName(""+x);
          buttons[x].addActionListener(listener);
          rows[x] = new JPanel(new GridLayout(1,2));
          rows[x].add(labels[x]);
          rows[x].add(buttons[x]);
          p.add(rows[x]);
        JFrame f = new JFrame();
        f.getContentPane().add(p,BorderLayout.CENTER);
        f.getContentPane().add(tf,BorderLayout.SOUTH);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }

  • WT reporter does not show split for tax authorities!

    Dear all:
        I need to report for all employees some WTs of taxes, but wt reporter does not show the splits for them (to distinguish federal from statal authorities payments), it is like summarises all the same WTs... I tried payroll recon. report but this one does not output the data in ALV format (im in 4.6 version) so it is not useful to run in bulk
    Do you have any work around for this?
    I would appreciate any tip or workaround on this,
    Thank you!

    Hi
    1. Allocated costs are always treated as Fixed costs, unless you have booked the expenses in FI using Activity Type as Aux Account assignment object
    2. Check whether these costs are included in Inventory valuation in your Cost Comp Str in OKTZ... If not relevant for inv valuation, these costs wont show up for Variance calculations
    br, Ajay M

  • Ipad 2 does not show in itunes

    My ipad 2 was completely dead last night so I plugged it in to charge using the 10W wall charger that came with it and noticed that it did not vibrate when I plugged it in nor did it show the lightning bolt showing it was charging. I left it alone from a few hours and when I checked, it was up to 12%. Normally a few hours will almost fully charge it. I swapped out a few different cables, chargers, and even plugged it into my mac USB, and none of them vibrated and showed the lightning bolt. When I plug it into my Mac, it does not show in iTunes at all under devices. I plugged in my iPhone and iPod and both showed instantly. I decided to leave the paid charge overnight on the wall charger to see what would happen.
    This morning it was up to 53%. I updated the iPad 2 software to iOS 5.1.1, updated iTunes to 10.6.1, updated all software on my Mac (I have OS X 10.6.8) and still doesnt show in iTunes and none of the chargers or cables make it vibrate when plugged in and none show the charging bolt. I deleted iTunes and the Apple Mobile Device driver and then reinstalled thinking perhaps the mobile device driver was messed up - didnt help.
    On the iPad 2, I went to settings/general/reset/reset network settings - no help.
    Of course, throughout this I have reset my Mac several times, reset the iPad both by sliding the bar to shut down and by holding down the reset button & home button at the same time until the Apple logo appears, and as stated above tried several wall chargers and USB cables that works on my other i products. So I do not think its something obvious like that.
    Any help is greatly appreciated.
    iPad 2, iOS 5.1.1
    Mac OS X 10.6.8
    ITunes 10.6.1

    Let me know when you figure this out. I am experiencing the exact same situation. Just started this morning after I switched my mobileme account to icloud. I can see my iphone in itunes, but when I plug my ipad in, nothing. Not on any computer. I have always been able to sync and charge with no trouble. Now my ipad is slowly turning in to a door stop.
    Help!
    Thank you!

Maybe you are looking for

  • I couldn't log on my windows 8.1 so I tried to edit utilman and cmd to clear the password but it didn't help

    hi, I could not log on my Windows 8.1 because it was telling me the password is not correct while the passwoord was correct. so I serached IN Google and found how to work some security files like Ultiman en CMD to clear the password and log again. bu

  • Videos on Hulu and other video sites are not playing.

    Videos on sites like Hulu and NBC do not play. The sites load fine, and in fact the ads load fine. But when it gets to the video, nothing comes up at all, just black. Eventually some error comes up like "could not get video at this time." Youtube DOE

  • Location of aspnet_client/System_Web/2_0_50727/CrystalReportWebFormViewer4

    I am using CR2008 Basic (10.5 I believe) .  The report viewer works fine on our secure web server under a virtual directory i.e. wwwroot\abc\....  When our engineers run "CRRedist2008_x86.msi " it installs the "aspnet_client/System_Web/2_0_50727/Crys

  • The Case of the Disappearing Clones

    Ok, here's a new one for me. I was cloning a cloud edge, and examining my work. The History palette was blocking my view, so I moved it. Instead, it jumped to the palette bar. Brought it back and tried to move it again. Same thing. Huh? I opened it f

  • Low and High sliders in Audi

    Hellow! I use Audigy2 Value for a long time but never had this question in my mind. Now i have to make music arrangement of several songs and mix a lot of tracks in Sonar, so i extremly need to hear "true" frequencies of my tracks in monitors while m