BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 06-21-2010, 07:10 AM   #1
Naga Mallika
New Member
 
Join Date: Jun 2010
Model: 8300
PIN: N/A
Carrier: airtel
Posts: 6
Post button field

Please Login to Remove!

i have to create a title for the screen, a label field,an edit field and a button field now i need logic that when my button field is clicked the text in the edit field should be displayed like a pop up screen. my code is


package com.Editfield;

import net.rim.device.api.ui.*;
import net.rim.device.api.ui.Field.*;
import net.rim.device.api.ui.component.TextField.*;
import net.rim.device.api.ui.component.EditField.*;
import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.container.*;
import net.rim.device.api.system.*;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.decor.*;
import net.rim.device.api.ui.XYEdges.*;

/**
*
*/
public class Editfield extends UiApplication {
public static void main(String[] args){

Editfield theApp = new Editfield();
theApp.enterEventDispatcher();
}
public Editfield() {
pushScreen(new EditfieldScreen());


}
}

class EditfieldScreen extends MainScreen
{



FieldChangeListener listener = new FieldChangeListener(){
public void fieldChanged(Field field, int context){
LabelField lbl1 = (LabelField) field;
add(lbl1);
System.out.println("Button pressed:");
}
};

ButtonField buttonField = new ButtonField("Test Button");

public EditfieldScreen()
{
super();
setTitle("EditField Demo");
Border bdr = BorderFactory.createRoundedBorder(new XYEdges(4,4,4,4),Border.STYLE_SOLID);


LabelField lbl = new LabelField("Enter the name:");

EditField edit = new EditField("Sample Test:","");

edit.setBorder(bdr);

ButtonField buttonField = new ButtonField("Show");

add(lbl);
add(edit);
add(buttonField);
buttonField.setChangeListener(listener);



}




public boolean onClose(){
Dialog.alert("Goodbye!");
System.exit(0);
return true;
}

}


till here my code is running perfectly but when the show button is clicked it is showing the jvm error
Offline  
Old 06-24-2010, 01:11 AM   #2
Naga Mallika
New Member
 
Join Date: Jun 2010
Model: 8300
PIN: N/A
Carrier: airtel
Posts: 6
Default need help

need help to get a pop up screen when a buttonfield is clicked
Offline  
Old 08-02-2010, 06:42 AM   #3
f_ortega86
New Member
 
Join Date: Aug 2010
Model: 8900
PIN: N/A
Carrier: nothing
Posts: 1
Default

Your problem is here:

Quote:
FieldChangeListener listener = new FieldChangeListener(){
public void fieldChanged(Field field, int context){
LabelField lbl1 = (LabelField) field;
add(lbl1);
System.out.println("Button pressed:");
}
};
The parameter field isn´t a LabelField because you use this listener in a ButtonField. In addiction, you can´t add any Field to the current Screen like that code "add(lbl1)". Try this:

Quote:
FieldChangeListener listener = new FieldChangeListener(){
public void fieldChanged(Field field, int context){
//With this you obtain the control of the current screen
EditFieldScreen screen = (EditFieldScreen) UiApplication.getUiApplication().getActiveScreen() ;

Dialog.inform(screen.edit.getText()); /*You need to put the EditField like an attribute in the EditfieldScreen class*/

}
};
Offline  
Old 08-23-2010, 01:33 AM   #4
Naga Mallika
New Member
 
Join Date: Jun 2010
Model: 8300
PIN: N/A
Carrier: airtel
Posts: 6
Default

thank you
Offline  
Old 08-23-2010, 01:37 AM   #5
Naga Mallika
New Member
 
Join Date: Jun 2010
Model: 8300
PIN: N/A
Carrier: airtel
Posts: 6
Default CustomLayoutManagers

This is my code

/*
* CustomLayoutManagersApplication.java
*
* © <your company here>, 2003-2008
* Confidential and proprietary.
*/

package BlackBerry.CustomLayoutManagers.CustomLayoutManage rsApplication;



import net.rim.device.api.ui.*;
class CustomLayoutManagersApplication extends UiApplication
{

public CustomLayoutManagersApplication ()
{

CustomMainScreen CLMS = new CustomMainScreen(); pushScreen(CLMS);
}

public static void main(String args[])
{
CustomLayoutManagersApplication cts = new CustomLayoutManagersApplication();
cts.enterEventDispatcher();
}

}
--------
I am getting cannot find symbol near that line i am not able to find out what is the mistake i did in my code

-------------
package BlackBerry.CustomLayoutManagers.CustomLayoutManage rsScreen;
import net.rim.device.api.ui.*;
import net.rim.device.api.ui.Field.*;
import net.rim.device.api.ui.container.*;

import net.rim.device.api.ui.XYEdges.*;
import net.rim.device.api.ui.component.TextField.*;
import net.rim.device.api.ui.component.EditField.*;
import net.rim.device.api.ui.decor.*;
import net.rim.device.api.ui.Manager.*;

import net.rim.device.api.ui.container.HorizontalFieldMan ager.*;
import net.rim.device.api.ui.container.VerticalFieldManag er.*;

import net.rim.device.api.ui.component.*;
import net.rim.device.api.ui.component.LabelField.*;

import net.rim.device.api.ui.component.BitmapField.*;
import net.rim.device.api.system.*;

import net.rim.device.api.ui.container.MainScreen.*;


/**
*
*/
public class CustomMainScreen extends MainScreen
{
ObjectChoiceField obj;
String choicestrs[] = {"January","February","March","April","May","June" ,"July","August","September","October","November", "December"};

public CustomMainScreen()
{


setTitle("CustomLayoutManagers");
Bitmap bmp2 = Bitmap.getBitmapResource("bing.PNG");
BitmapField bmp = new BitmapField(bmp2,BitmapField.FIELD_LEFT);
LabelField lbl = new LabelField("Name:",LabelField.FIELD_RIGHT);
EditField edit = new EditField();
obj = new ObjectChoiceField("Month:",choicestrs,0);
ButtonField button = new ButtonField("Add");
CustomLayoutManagersDemo CLMD = new CustomLayoutManagersDemo(); CLMD.addbmp(bmp);
CLMD.addlbl(lbl);
CLMD.addedit(edit);
CLMD.addobj(obj);
CLMD.addbutton(button);
add(CLMD);
}
---------------------
i am getting cannot find symbol in my above code all the two code are linked
Offline  
Closed Thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Grandstream GXP2160 VoIP IP Phone Color Gigabit Enterprise HD 6 Line PoE Black picture

Grandstream GXP2160 VoIP IP Phone Color Gigabit Enterprise HD 6 Line PoE Black

$37.98



NEW Polycom VVX 501 VoIP IP Phone & Stand Warranty VVX411 2200-48500-019 Lync picture

NEW Polycom VVX 501 VoIP IP Phone & Stand Warranty VVX411 2200-48500-019 Lync

$49.98



Polycom VVX 410 VoIP IP Phone & Stand Warranty Reset VVX410 2201-46162-001 Lync picture

Polycom VVX 410 VoIP IP Phone & Stand Warranty Reset VVX410 2201-46162-001 Lync

$17.98



Polycom Vvx 601 VoIP 16 Line Business Phone 4.3

Polycom Vvx 601 VoIP 16 Line Business Phone 4.3" HD Touchscreen PoE With Stand

$28.95



Polycom VVX 400 VoIP IP Phone & Stand Warranty Reset 2201-46104-001 SIP or Skype picture

Polycom VVX 400 VoIP IP Phone & Stand Warranty Reset 2201-46104-001 SIP or Skype

$17.98



Allworx 9212 VoIP IP Phone with Stand Warranty Paetec 9212P Business Office picture

Allworx 9212 VoIP IP Phone with Stand Warranty Paetec 9212P Business Office

$17.98







Copyright © 2004-2016 BlackBerryForums.com.
The names RIM © and BlackBerry © are registered Trademarks of BlackBerry Inc.