Custom Dialog box in blackberry - blackberry-jde

How to create custom Dialogue box and add listeners to the buttons in the dialogue box in blackberry

public class CustomDialog extends Screen implements FieldChangeListener
{
private ButtonField okButton;
public void fieldChanged(Field field, int context)
{
if (field == okButton)
{
close();
}
}
public CustomDialog(String message)
{
super(new VerticalFieldManager(), Screen.DEFAULT_CLOSE);
add(new LabelField("Search Error",LabelField.FIELD_HCENTER));
add(new LabelField(""));
add(new LabelField(message,LabelField.FIELD_HCENTER));
add(new LabelField(""));
okButton = new ButtonField("OK",ButtonField.FIELD_HCENTER);
okButton.setChangeListener(this);
add(okButton);
}
protected void paintBackground(Graphics graphics)
{
graphics.setColor(Color.GRAY);
graphics.fillRoundRect(0, 0, getWidth(), getHeight(), 12, 12);
graphics.setColor(Color.BLACK);
graphics.drawRoundRect(0, 0, getWidth(), getHeight(), 12, 12);
}
protected void sublayout(int width, int height)
{
layoutDelegate(width - 80, height - 80);
setPositionDelegate(10, 10);
setExtent(width - 60, Math.min(height - 60, getDelegate().getHeight() + 20));
setPosition(30, (height - getHeight())/2);
}
}

Related

Draw a circle on canvas using Animation

I need to create a circle using animation.
I need to set duration 2000 till my circle will be end at 360 degrees.
Class content
private int animValue;
private int strokeWidth = 15;
private int i = 0;
public MyCustomView(Context context) :
base(context)
{
}
public MyCustomView(Context context, IAttributeSet attrs) :
base(context, attrs)
{
animValue = 0;
}
public MyCustomView(Context context, IAttributeSet attrs, int defStyle) :
base(context, attrs, defStyle)
{
}
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
Paint paint = new Paint();
paint.SetStyle(Paint.Style.Stroke);
paint.StrokeWidth=(strokeWidth);
RectF rectF = new RectF();
rectF.Set(strokeWidth, strokeWidth, Width - strokeWidth, Width - strokeWidth);
paint.Color = (Color.Gray);
canvas.DrawArc(rectF, 0, 360, false, paint);
paint.Color=(Color.Blue);
canvas.DrawArc(rectF, animValue, i++, false, paint);
}
public void setValue(int animatedValue)
{
animValue = animatedValue;
Invalidate();
}
}
Activity Content
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
var circleView = FindViewById<MyCustomView>(Resource.Id.circleView);
ValueAnimator valueAnimator = ValueAnimator.OfInt(0, 0);
valueAnimator.SetDuration(2000);
valueAnimator.AddUpdateListener(new AnimatorUpdateListener(this, circleView));
valueAnimator.Start();
}
private class AnimatorUpdateListener : Java.Lang.Object, ValueAnimator.IAnimatorUpdateListener
{
private MainActivity mainActivity;
private MyCustomView circleView;
public AnimatorUpdateListener(MainActivity mainActivity, MyCustomView circleView)
{
this.mainActivity = mainActivity;
this.circleView = circleView;
}
void ValueAnimator.IAnimatorUpdateListener.OnAnimationUpdate(ValueAnimator animation)
{
circleView.setValue((int)animation.AnimatedValue);
}
}
The problem is that my circle doesnt finish at the end of circle it stops somewhere in middle.The line doesnt finish in the end of my circle...
[![Img][1]][1]
[1]: https://i.stack.imgur.com/oAz1Q.png
You can try the following code, and the effect is like this
Class content
class MyCustomView:View
{
private int animValue;
private int strokeWidth = 15;
//private int i = 0;
public MyCustomView(Context context) :
base(context)
{
}
public MyCustomView(Context context, IAttributeSet attrs) :
base(context, attrs)
{
animValue = 0;
}
public MyCustomView(Context context, IAttributeSet attrs, int defStyle) :
base(context, attrs, defStyle)
{
}
protected override void OnDraw(Canvas canvas)
{
base.OnDraw(canvas);
Paint paint = new Paint();
paint.SetStyle(Paint.Style.Stroke);
paint.StrokeWidth = (strokeWidth);
RectF rectF = new RectF();
rectF.Set(strokeWidth, strokeWidth, Width - strokeWidth, Width - strokeWidth);
paint.Color = (Color.Gray);
canvas.DrawArc(rectF, 0, 360, false, paint);
paint.Color = (Color.Blue);
canvas.DrawArc(rectF, 0, animValue, false, paint);
}
public void setValue(int animatedValue)
{
animValue = animatedValue;
Invalidate();
}
}
Activity Content
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.activity_main);
var circleView = FindViewById<MyCustomView>(Resource.Id.circleView);
ValueAnimator valueAnimator = ValueAnimator.OfInt(0, 360);
valueAnimator.SetDuration(2000);
valueAnimator.AddUpdateListener(new AnimatorUpdateListener(this, circleView));
valueAnimator.Start();
}
private class AnimatorUpdateListener : Java.Lang.Object, ValueAnimator.IAnimatorUpdateListener
{
private MainActivity mainActivity;
private MyCustomView circleView;
public AnimatorUpdateListener(MainActivity mainActivity, MyCustomView circleView)
{
this.mainActivity = mainActivity;
this.circleView = circleView;
}
void ValueAnimator.IAnimatorUpdateListener.OnAnimationUpdate(ValueAnimator animation)
{
circleView.setValue((int)animation.AnimatedValue);
}
}

JPanel animation

Hy there.
I am trying to make a JPanel which reacts to certain events and plays a little animation. For example if I click on a button, it should flash red.(I need this to indicate when a file was successfully saved(green flash), or a error occurred(red flash).
I found some tutorials on animations, but I'm having a hard time changing it to fit my needs. For example most of the tutorials instantiate a Timer at the beginning. But I only need the timer to be active for that short amount of time where the flash is played and than stop. Also I need different animation types.(red flash, green flash...)
This is what I have got so far, which is basically nothing:
package MainPackage;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.Timer;
public class StatusBar extends JPanel implements ActionListener{
Timer t = new Timer(10, this);
boolean stop = false;
Color color;
public void paintComponent (Graphics g) {
super.paintComponent(g);
setBackground(color);
}
public void confirm(){
color = new Color(46, 204, 113);
t.start();
}
public void warning(){
color = Color.red;
t.start();
}
#Override
public void actionPerformed(ActionEvent e) {
repaint();
}
}
Thanks in advance!
public class flashclass extends JFrame{
Thread th;
Color defaultColor, flashColor;
int i;
boolean success;
JPanel p;
public flashclass(){
setSize(200, 200);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
success = false;
defaultColor = new Color(214,217,223);
p = new JPanel();
JButton rbtn = new JButton("Red flash");
JButton gbtn = new JButton("Green flash");
rbtn.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
success = false;
flash(success);
}
});
gbtn.addActionListener(new ActionListener() {
#Override
public void actionPerformed(ActionEvent e) {
success = true;
flash(success);
}
});
p.add(rbtn);
p.add(gbtn);
getContentPane().add(p);
}
public void flash(boolean success){
i=0;
if(!success){
flashColor = Color.red;
}
else{
flashColor = Color.green;
}
th = new Thread(new Runnable() {
#Override
public void run() {
while(i<10){
p.setBackground(flashColor);
i++;
try {
Thread.sleep(10);
} catch (InterruptedException ex) {
Logger.getLogger(NewJFrame.class.getName()).log(Level.SEVERE, null, ex);
}
p.setBackground(defaultColor);
}
}
});
th.start();
}
}
public static void main(String args[]){
new flashclass();
}
}
So here is the finished class:
New animations can be added easily. And they also do not interfere with each other. So multiple states can be triggered simultaneously.
The StatusBar.java
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import javax.swing.JComponent;
import javax.swing.Timer;
public class StatusBar extends JComponent implements ActionListener{
int width;
int height;
boolean bLoad, bWarn, bConfirm, bError;
Timer timer;
Color bgColor;
int xPosLoad, alphaWarn, alphaConfirm, alphaError;
float cntWarn, cntConfirm, cntError;
int cntLoad;
final int barLength = 200;
public StatusBar(Color bg){
width = getWidth();
height = getHeight();
xPosLoad = -barLength;
alphaWarn = 0;
alphaConfirm = 0;
alphaError = 0;
bgColor = bg;
timer = new Timer(10, this);
this.addComponentListener(new ComponentAdapter() {
#Override
public void componentResized(ComponentEvent event) {
width = getWidth();
height = getHeight();
}
});
}
#Override
protected void paintComponent(Graphics g) {
// Background
g.setColor(bgColor);
g.fillRect(0, 0, width, height);
// loading
Graphics2D g2d = (Graphics2D)g;
GradientPaint gp = new GradientPaint(xPosLoad,0, new Color(0,0,0,0), xPosLoad+barLength, 0, new Color(200, 200, 255));
g2d.setPaint(gp);
g2d.fillRect(xPosLoad, 0, barLength, height);
// Green
g.setColor(new Color(20, 210, 60, alphaConfirm));
g.fillRect(0, 0, width, height);
// Yellow
g.setColor(new Color(255, 223, 0, alphaWarn));
g.fillRect(0, 0, width, height);
// Red
g.setColor(new Color(255, 0, 0, alphaError));
g.fillRect(0, 0, width, height);
}
#Override
public void actionPerformed(ActionEvent e) {
// step increase for all active components
boolean toggle = false;
if (bConfirm){
if(cntConfirm < 1){
cntConfirm += 0.01f;
alphaConfirm = lerp(cntConfirm, 255, true);
}else{
bConfirm = false;
cntConfirm = 0;
alphaConfirm = 0;
}
toggle = true;
}
if (bWarn){
if(cntWarn < 1){
cntWarn += 0.01f;
alphaWarn = lerp(cntWarn, 255, true);
}else{
bWarn = false;
cntWarn = 0;
alphaWarn = 0;
}
toggle = true;
}
if (bError){
if(cntError < 1){
cntError += 0.01f;
alphaError = lerp(cntError, 255, true);
}else{
bError = false;
cntError = 0;
alphaError = 0;
}
toggle = true;
}
if (bLoad){
if(cntLoad < 100){
cntLoad += 1;
xPosLoad = (cntLoad * (width + barLength)) / 100 - barLength;
}else{
cntLoad = 0;
xPosLoad = -barLength;
}
toggle = true;
}
repaint();
if (!toggle){
timer.stop();
}
}
private void startTimer(){
if (!timer.isRunning())
timer.start();
}
public void setBG(Color bg){
bgColor = bg;
System.out.println("Color: " + bgColor);
repaint();
}
// Green flash
public void confirm(){
// set values
bConfirm = true;
alphaConfirm = 255;
cntConfirm = 0;
startTimer();
}
//Yellow flash
public void warning(){
// restart values
bWarn = true;
alphaWarn = 255;
cntWarn = 0;
startTimer();
}
//Red Flash
public void error(){
// restart values
bError = true;
alphaError = 255;
cntError = 0;
startTimer();
}
//Blue load
public void loadStart(){
// restart values
bLoad = true;
xPosLoad = -barLength;
cntLoad = 0;
startTimer();
}
public void loadEnd(){
bLoad = false;
xPosLoad = -barLength;
}
private int lerp(float progress, int max, boolean inverse){
float x = progress;
float x2 = (float) Math.pow(x, 4);
float g = x + (1 - x);
float y = (float) ((float) x2 / (float)(Math.pow(g, 4)));
y = Math.min(y, 1);
y = Math.max(y, 0);
int res = (int) (y * max);
if (inverse){
res = max - res;
}
return res;
}
}
And the Example.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Example extends JFrame{
public static void main(String[] args){
new Example("Stat Example");
}
public Example(String title){
super(title);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
StatusBar stat = new StatusBar(Color.black);
stat.setPreferredSize(new Dimension(0, 10));
JPanel panel = new JPanel();
JButton bConfirm = new JButton("Confirm");
JButton bWarn = new JButton("Warning");
JButton bErr = new JButton("Error");
JButton bLoadS = new JButton("Start Loading");
JButton bLoadE = new JButton("End Loading");
panel.add(bConfirm);
panel.add(bWarn);
panel.add(bErr);
panel.add(bLoadS);
panel.add(bLoadE);
this.getContentPane().add(stat, BorderLayout.CENTER);
this.getContentPane().add(panel, BorderLayout.SOUTH);
this.pack();
this.setVisible(true);
// Listener
bConfirm.addActionListener(new java.awt.event.ActionListener() {
#Override
public void actionPerformed(ActionEvent event) {
stat.confirm();
}
});
bWarn.addActionListener(new java.awt.event.ActionListener() {
#Override
public void actionPerformed(ActionEvent event) {
stat.warning();
}
});
bErr.addActionListener(new java.awt.event.ActionListener() {
#Override
public void actionPerformed(ActionEvent event) {
stat.error();
}
});
bLoadS.addActionListener(new java.awt.event.ActionListener() {
#Override
public void actionPerformed(ActionEvent event) {
stat.loadStart();
}
});
bLoadE.addActionListener(new java.awt.event.ActionListener() {
#Override
public void actionPerformed(ActionEvent event) {
stat.loadEnd();
}
});
}
}

Detect if object is over pane during transition

I'm trying to detect if an elements that I move using PathTransition are entering the space of Pane.
This is my code:
public class Demo extends Application {
private void init(Stage primaryStage) {
Group root = new Group();
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 800, 600));
Rectangle rect = new Rectangle(5, 5, Color.BLACK);
root.getChildren().add(rect);
Path path = new Path();
path.getElements().add (new MoveTo (0, 350));
path.getElements().add (new LineTo(400, 350));
PathTransition pathTransition = new PathTransition();
pathTransition.setDuration(Duration.millis(5000));
pathTransition.setPath(path);
pathTransition.setNode(rect);
pathTransition.setAutoReverse(false);
AnchorPane pane = new AnchorPane();
pane.setPrefSize(250, 200);
pane.relocate(300, 300);
pane.setStyle("-fx-border-color: #000000;");
root.getChildren().add(pane);
pathTransition.play();
}
#Override
public void start(Stage primaryStage) throws Exception {
init(primaryStage);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Is there a way to bind an event to the pane object and when the rect goes over, it will detect it?
Try
BooleanBinding intersects = new BooleanBinding() {
{
this.bind(pane.boundsInParentProperty(), rect.boundsInParentProperty());
}
#Override
protected boolean computeValue() {
return pane.getBoundsInParent().intersects(rect.getBoundsInParent());
}
};
intersects.addListener(new ChangeListener<Boolean>() {
#Override
public void changed(ObservableValue<? extends Boolean> observable,
Boolean oldValue, Boolean newValue) {
if (newValue) {
System.out.println("Intersecting");
} else {
System.out.println("Not intersecting");
}
}
});
If you are still using old (pre-Java 8) versions of Java, you will need to declare pane and rect as final.

isSelected method for jRadioButton doesnt work

my isSelected method for the radio buttons are not working, even if i select them when i run the program, i am new to java gui coding so plz explain according to that, i am posting the whole gui's class code.And i am using eclipse swing designer
public class gui {
private JFrame frame;
private final ButtonGroup buttonGroup = new ButtonGroup();
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
gui window = new gui();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
* #throws FileNotFoundException
*/
public gui() throws FileNotFoundException {
initialize();
}
/**
* Initialize the contents of the frame.
* #throws FileNotFoundException
*/
private void initialize() throws FileNotFoundException {
FileReader reader=new FileReader("C:\\Users\\kkj\\workspace\\javaproject\\src\\Database.txt");
Scanner in=new Scanner(reader);
BList Restaurant=new BList();
BList ATM=new BList();
BList Hospital=new BList();
BList Hotels=new BList();
BList Petrol=new BList();
final Llist locations=new Llist();
System.out.println("Loading");
while(in.hasNextLine())
{
BNode bnode=new BNode();
bnode.name=in.nextLine();
//System.out.println(bnode.name);
String type=in.nextLine();
bnode.loc=in.nextLine();
if(type.equals("Restaurant"))
{
Restaurant.insert(bnode);
}
if(type.equals("ATM"))
{
ATM.insert(bnode);
}
if(type.equals("Hospital"))
{
Hospital.insert(bnode);
}
if(type.equals("Hotels"))
{
Hotels.insert(bnode);
}
if(type.equals("Petrol"))
{
Petrol.insert(bnode);
}
}
FileReader reader2=new FileReader("C:\\Users\\kkj\\workspace\\javaproject\\src\\locations.txt");
Scanner inL=new Scanner(reader2);
int s=0;
while(inL.hasNextLine())
{
LNode loc=new LNode();
loc.Name=inL.nextLine();
loc.dist=s++;
BNode temp;
temp=Restaurant.head;
while(temp.next!=null)
{ if(temp.loc.equals(loc.Name))
{loc.rest=temp;break;}
temp=temp.next;
}
temp=Hospital.head;
while(temp.next!=null)
{ if(temp.loc.equals(loc.Name))
{loc.Hospital=temp;break;}
temp=temp.next;
}
temp=Hotels.head;
while(temp.next!=null)
{ if(temp.loc.equals(loc.Name))
{loc.Hotels=temp;break;}
temp=temp.next;
}
//loc.hotels=temp;
temp=ATM.head;
while(temp.next!=null)
{ if(temp.loc.equals(loc.Name))
{loc.ATM=temp;break;}
temp=temp.next;
}
locations.insert(loc);
}
System.out.println("Loaded");
System.out.println(">>>>>>>>>>>Restaurants<<<<<<<<<<<<");
Restaurant.disp();
System.out.println(">>>>>>>>>>>Hotels<<<<<<<<<<<<");
Hotels.disp();
System.out.println(">>>>>>>>>>>Hospital<<<<<<<<<<<<");
Hospital.disp();
System.out.println(">>>>>>>>>>>ATM's<<<<<<<<<<<<");
ATM.disp();
System.out.println(">>>>>>>>>>>Locations<<<<<<<<<<<<");
locations.disp();
final String curr="Bsk";
String locin;
final String typein="Hospital";
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
JRadioButton rdbtnBsk = new JRadioButton("Bsk");
buttonGroup.add(rdbtnBsk);
rdbtnBsk.setBounds(26, 35, 109, 23);
frame.getContentPane().add(rdbtnBsk);
JRadioButton rdbtnKoramangala = new JRadioButton("Koramangala");
buttonGroup.add(rdbtnKoramangala);
rdbtnKoramangala.setBounds(26, 72, 109, 23);
frame.getContentPane().add(rdbtnKoramangala);
JRadioButton rdbtnMgRoad = new JRadioButton("MG Road");
buttonGroup.add(rdbtnMgRoad);
rdbtnMgRoad.setBounds(26, 125, 109, 23);
frame.getContentPane().add(rdbtnMgRoad);
if(rdbtnBsk.isSelected())
{
locin="Bsk";
}
if(rdbtnKoramangala.isSelected())
{
locin="Koramangala";
}
if(rdbtnMgRoad.isSelected())
{
locin="MG Road";
}
else System.exit(2);
final String locinn=locin;
JButton btnOutput = new JButton("output");
btnOutput.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)
{
Output out1=new Output();
System.out.println(">>>>>>>>>>>"+typein+" in "+locinn+"<<<<<<<<<<<<");
out1.display(locations, locinn, typein,curr);
}
});
btnOutput.setBounds(182, 193, 89, 23);
frame.getContentPane().add(btnOutput);
}
private class SwingAction extends AbstractAction {
public SwingAction() {
putValue(NAME, "SwingAction");
putValue(SHORT_DESCRIPTION, "Some short description");
}
public void actionPerformed(ActionEvent e) {
}
}
}
Am also new to Java Programming, but this might work, it worked for me.
Put the whole if/else block inside the actionPerformed() method of the "output" Button, like this :
JButton btnOutput = new JButton("output");
btnOutput.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0)
{ if(rdbtnBsk.isSelected())
{
locin="Bsk";
}
else if(rdbtnKoramangala.isSelected())
{
locin="Koramangala";
}
else if(rdbtnMgRoad.isSelected())
{
locin="MG Road";
}
final String locinn=locin;
Output out1=new Output();
System.out.println(">>>>>>>>>>>"+typein+" in "+locinn+"<<<<<<<<<<<<");
out1.display(locations, locinn, typein,curr);
}
});
btnOutput.setBounds(182, 193, 89, 23);
frame.getContentPane().add(btnOutput);
}

BlackBerry Storm - focus does not comes on focussable fields added after scrollable list field

searchlist = new FileList(list_vector,ind,j);//a custom list field
searchlist.setRowHeight(40);
searchListManager = new VerticalFieldManager(
Manager.VERTICAL_SCROLL |Manager.VERTICAL_SCROLLBAR)
searchListManager.add(searchlist);
objManager.add(searchListManager);
HomeScreen1.this.add(header_manager);
HomeScreen1.this.add(objManager);
//after few lines of code
button_manager.add(Previous);
button_manager.add(Next);
objManager.add(button_manager);
now my problem is when i scroll over the list field then next n previous are not visible
but when i press key up n down then they get only visible
what to do???????????
Try to implement searchListManager as a scrollable VerticalManager with fixed size (Display height - header manager height - button manager height)
UPDATE Code to try:
class Scr extends MainScreen implements ListFieldCallback {
int DISPLAY_WIDTH = Display.getWidth();
int DISPLAY_HEIGHT = Display.getHeight();
Vector mItems = new Vector();
ListField mListField = new ListField();
SizedVFM mListManager = new SizedVFM(DISPLAY_WIDTH, DISPLAY_HEIGHT - 50);
ButtonField mPrevButtonField = new ButtonField("Previous",
ButtonField.CONSUME_CLICK);
ButtonField mNextButtonField = new ButtonField("Next",
ButtonField.CONSUME_CLICK);
HorizontalFieldManager mButtonsManager = new HorizontalFieldManager(
FIELD_HCENTER);
public Scr() {
for (int i = 1; i < 31; i++) {
mItems.addElement("item " + String.valueOf(i));
}
mListField.setCallback(this);
mListField.setSize(30);
add(mListManager);
mListManager.add(mListField);
mPrevButtonField.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
Dialog.inform("Previouse pressed");
}
});
mNextButtonField.setChangeListener(new FieldChangeListener() {
public void fieldChanged(Field field, int context) {
Dialog.inform("Next pressed");
}
});
mButtonsManager.add(mPrevButtonField);
mButtonsManager.add(mNextButtonField);
add(mButtonsManager);
}
public void drawListRow(ListField field, Graphics g, int i, int y, int w) {
// Draw the text.
String text = (String) get(field, i);
g.drawText(text, 0, y, 0, w);
}
public Object get(ListField listField, int index) {
return mItems.elementAt(index);
}
public int getPreferredWidth(ListField listField) {
return DISPLAY_WIDTH;
}
public int indexOfList(ListField listField, String prefix, int start) {
return 0;
}
}
class SizedVFM extends VerticalFieldManager {
int mWidth;
int mHeight;
public SizedVFM(int width, int height) {
super(VERTICAL_SCROLL | VERTICAL_SCROLLBAR);
mWidth = width;
mHeight = height;
}
public int getPreferredHeight() {
return mHeight;
}
public int getPreferredWidth() {
return mWidth;
}
public void setHeight(int height) {
mHeight = height;
}
protected void sublayout(int maxWidth, int maxHeight) {
super.sublayout(maxWidth, maxHeight);
setExtent(getPreferredWidth(), getPreferredHeight());
}
}
And the result should be like that:
alt text http://img215.imageshack.us/img215/1402/9530list.jpg

Resources