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


COMPUTER PROCESS 811-3110 / 8113110 (USED ) picture

COMPUTER PROCESS 811-3110 / 8113110 (USED )

$80.00



NEW SEALED AB 1747-L541 /C SLC 500 SLC 5/04 CPU PROCESSOR UNIT MODULE US picture

NEW SEALED AB 1747-L541 /C SLC 500 SLC 5/04 CPU PROCESSOR UNIT MODULE US

$310.93



Robot Coupe Cutting blades, 6 pcs fits CFP-4, CFP5, CFP-9 Food Processor picture

Robot Coupe Cutting blades, 6 pcs fits CFP-4, CFP5, CFP-9 Food Processor

$20.00



Alphasmart 3000 Word Processor Portable Full Keyboard Classroom Typewriter picture

Alphasmart 3000 Word Processor Portable Full Keyboard Classroom Typewriter

$49.99



The Writer by Keyboard Instructor Word Processor Typing Trainer w/ Case picture

The Writer by Keyboard Instructor Word Processor Typing Trainer w/ Case

$30.00



Allen Bradley 1747-L542 SER C SLC 500 5/04 CPU PROCESSOR UNIT AB 1747L542 picture

Allen Bradley 1747-L542 SER C SLC 500 5/04 CPU PROCESSOR UNIT AB 1747L542

$306.80







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