Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012
Accepted Solution

Cursor not showing up in the editfield

I have added a Name field which is an editfield.

This is what it looks-

 

Name: [Editfield box to contain input]

 

But the cursor is just not visible/showing up in this edit box which is making it difficult to understand where exactly the user wants to type.

 

How to get the cursor blinking in the box.Please help.Though this may seem a minute problem,its one that cant be ignored from a developer perspective.

 

Hope to receive a help.

Thanks.

 

//Add box next to field for containing input 
       HorizontalFieldManager hfm = new HorizontalFieldManager();
       LabelField lbl = new LabelField(" Customer Name: ");
       
       final EditField TextField1 = new EditField()
       {
           
            protected void layout(int maxWidth, int maxHeight) 
            {
                super.layout(Math.min(maxWidth, 300), Math.min(maxHeight, 20));
            }
           protected boolean keyChar(char ch, int status, int time) 
                {
                if (CharacterUtilities.isLetter(ch) || (ch == Characters.BACKSPACE || (ch == Characters.SPACE))) 
                {
                return super.keyChar(ch, status, time);
                }
               return true;
                }
            protected void paint(Graphics g)
                {       
                         g.clear();
                        g.drawRect(0,0, 50, 50);
                        int oldColor = g.getColor();
                        g.setColor(Color.WHITE);
                        g.fillRect(0, 0, this.getPreferredWidth(), this.getPreferredHeight());
                        g.setColor(oldColor);
                        g.drawRect(100, 100, 50, 50);
                        super.paint(g);
                 }    
                
        };
       TextField1.setBorder(BorderFactory.createRoundedBorder(new XYEdges(6,6,6,6)));
       hfm.add(lbl);
       hfm.add(TextField1);
       add(hfm);

 

Please use plain text.
Developer
simon_hain
Posts: 14,035
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Cursor not showing up in the editfield

don't overwrite paint.
what do you want to achieve by doing this?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012

Re: Cursor not showing up in the editfield

The paint is used to add white background color to the editfield box.Please guide how to resolve.

 

Regards,

Techie

Please use plain text.
Developer
simon_hain
Posts: 14,035
Registered: ‎07-29-2008
My Carrier: O2 Germany

Re: Cursor not showing up in the editfield

use paintBackground. Or the background class.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012

Re: Cursor not showing up in the editfield

Hi

 

I tried out using paintBackground this way.

 

protected void paintBackground(Graphics g)
                {       
                       
                        g.setBackgroundColor(Color.WHITE);
                   
                       g.clear();
                 }    

 But no change :smileysad:

How else to implement.

Please use plain text.
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012

Re: Cursor not showing up in the editfield

Please guide guys.
Please use plain text.
Developer
lakshman9687
Posts: 226
Registered: ‎07-22-2011
My Carrier: AirTel

Re: Cursor not showing up in the editfield

HI,

 

You can use setBackground for edit field, use any rectangle image it will come..

 

Regards,

Lakshman K

----------------------------------------------------------
Feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.

Please use plain text.
Developer
rabiray
Posts: 141
Registered: ‎07-13-2011
My Carrier: Vodafone

Re: Cursor not showing up in the editfield

Please use plain text.
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012

Re: Cursor not showing up in the editfield

Hi Lakshman,

 

I want to avoid using an image.Want to get it done through the field borders itself.Any idea.Please suggest with a coding construct.

 

Appreciate your help.

 

Thanks

Please use plain text.
Regular Contributor
techie
Posts: 77
Registered: ‎05-21-2012

Re: Cursor not showing up in the editfield

Hi Rabiray

 

Yes i checked that link which is based on creating a white background for editfield.

(Though that post has gone way too long with discussions)

 

I still couldn't see a resolve to my problem of cursor display there.

 

Please guide if you have any idea.

 

Also request you to kindly  see this link to aid a small problem that i am facing in our previous discussion.

http://supportforums.blackberry.com/t5/Java-Development/Autocomplete-textfield/m-p/1731421#M199829

 

Thanks so much.

 

 

 

Please use plain text.