Results 1 to 4 of 4

Thread: JLabel-

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Animal Rocks! Palikarov's Avatar
    Join Date: Jun:2009
    Location:
    Posts: 318

    JLabel-

    , . Java, , , - newbie .

    JLabel-, LayeredPane. 4 , - 4 . MouseEvent-, ( .getX .getY ).

    , , ( , ) , - .setText() NullPointerException. label[12].setText("myLabel"); , .

    GUI-, . - - , .

    Code:
    import javax.swing.*;
    import java.awt.*;
    import java.sql.*;
    import java.security.*;
    import java.util.*;
    import java.lang.*;
    
    
    public class SpecRework implements MouseListener //implements MouseMotionListener
    {
        
        JFrame frame;
        JLayeredPane layeredPane;
        JLabel bgrLabel, testLabel;
        JLabel[] tp, tn, tk, tz;
        
        
        public SpecRework() //throws SQLException, ClassNotFoundException
        {
            
            
            frame = new JFrame("Spec");
            frame.setPreferredSize(new Dimension(436, 650));
            frame.setResizable(false);
            frame.setLayout(null);
            
            layeredPane = new JLayeredPane();
            layeredPane.setBounds(0, 0, 430, 590);
            
            frame.getContentPane().add(layeredPane);
            frame.pack();
            frame.setVisible(true);
            
            
            JLabel[] tp = new JLabel [21];
            JLabel[] tn = new JLabel [21];
            JLabel[] tk = new JLabel [21];
            JLabel[] tz = new JLabel [21];
            
            
            ...
            
            int nXP = 51;
            int nYP = 64;
            int nXS = 290; // next on 342
            int nYS = 25;
            
            for (int i=0; i<21; i++)
            {
                tn[i] = new JLabel("");
                tn[i].setBounds(nXP, nYP, nXS, nYS);
                //tn[i].addMouseListener(this);
                layeredPane.add(tn[i], new Integer(20));
                nYP = nYP + 25;
            }
            
            ...
            
            tp[12].setText("12"); //   
            
            testLabel = new JLabel();
            testLabel.setBounds(60, 150, nXS, nYS);
            layeredPane.add(testLabel, new Integer(30));
            testLabel.addMouseListener(this);
            
        }
        
    
            ....
            
            public void mousePressed(MouseEvent e)
            {
                //eventOutput(e);
                testLabel.setText("Work!"); //   ,  testLabel    
                tn[13].setText("Work!"); //   NullPointerException
                
            }
            
            ....
        
        public static void main(String args[]) throws SQLException, ClassNotFoundException
        {
            SpecRework window1 = new SpecRework();
        }
        
    }
    P67 Extreme4 | i5-2500K /45x100/ + HDT S1283 | 2x4GB KHX21C11T3K2 /2133 11-12-11-30-1T/ | GTX570 TFIII PE/OC | WD3000HLHX, WD6402AAEX | Silent Pro M600 | Cosmos RC-1000 | SM2053BW
    UT X48-T3RS | E5200 /333x9/ | 2x1GB Trident /1333 6-6-6-18-2T tRD7/ | HD5770 | ... | FSP 400PNF
    6730s

  2. #2
    Registered User
    Join Date: Dec:2007
    Location: Sofia
    Posts: 366
    , NullPointerException.
    , .

  3. #3
    System.gc()'s Avatar
    Join Date: Apr:2007
    Location: back in time
    Posts: 1,075
    Quote Originally Posted by Pheoman View Post
    , NullPointerException.
    , .
    , - ( ) shadow- . , this., this.tp = new JLabel [21];

    - scope . "" IDE , , .

    .. , , IDE Eclipse , , .
    Last edited by System.gc(); 2nd September 2009 at 00:47.
    UD3R|Q9550+1283|4x2 G.Skill@1066|MX500+1002FAEX+640AAKS+ST31 60|RX580-8GB|1841BLT|SS-760XP|Define7|z24i|Edifier S350DB
    geniusloci: ) ; ) ; ) ? nope|r.i.p.

  4. #4
    Animal Rocks! Palikarov's Avatar
    Join Date: Jun:2009
    Location:
    Posts: 318
    , , , this . this super .


    .. , , . , , ( )
    !
    Last edited by Palikarov; 2nd September 2009 at 00:55.
    P67 Extreme4 | i5-2500K /45x100/ + HDT S1283 | 2x4GB KHX21C11T3K2 /2133 11-12-11-30-1T/ | GTX570 TFIII PE/OC | WD3000HLHX, WD6402AAEX | Silent Pro M600 | Cosmos RC-1000 | SM2053BW
    UT X48-T3RS | E5200 /333x9/ | 2x1GB Trident /1333 6-6-6-18-2T tRD7/ | HD5770 | ... | FSP 400PNF
    6730s

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |