10-25-2012 06:18 AM
Hi,
I developed a application where i use this type of popupScreen.
Here I set the image, widht height to the Rich text Field
I want to set the vertical scroll for this Following is the code for this:-
txtNote_value = new RichTextField()
{
protected void paint(Graphics graphics)
{
graphics.setColor(Color.BLACK);
graphics.setFont(graphics.getFont().derive(Font.PL
super.paint(graphics);
invalidate();
}
protected void layout(int width, int height){
super.layout(width, height);
setExtent(255, 55);
}
public int getPreferredWidth(){
return width;
}
public int getPreferredHeight(){
return height;
}
};
txtNote_value.setBackground(imgTextBg);
txtNote_value.setEditable(true);
txtNote_value.setMinimalWidth(imgText_bg.getWidth(
txtNote_value.setMargin(5,2, 0, 2);
Can any one give me solution for scrolling the text.
I add this richtext field on separate vertical field manage and set the :- VerticalFieldManager.VERTICAL_SCROLL
but it can scroll the hole Text filed I don't want to do this I only want to scroll the inner text of Rich text Fiedl
Thanks In Advance
Solved! Go to Solution.
10-27-2012 06:59 PM
In brief, if you want to limit the size of a Field, you override its layout (or in the case of a Manager, its sublayout), and restrict the size it uses. If you do this with the Vertical size of a scrollable VerticalFieldManager, then the contents of the VFM will scroll inside the space that been allocated to it. I think this is what you want, so give this a go.
01-15-2013 05:06 AM
I take the Richtect filled in side the vertical filed manage the code is as bellow,
vfm =new VerticalFieldManager(Manager.STATUS_MOVE_FOCUS_VER
{
public void paint(Graphics g)
{
g.setBackgroundColor(Color.WHITESMOKE);
g.fillRoundRect(4, 1,getWidth(), getHeight(),12,12);
// g.drawRoundRect(0, 0,getWidth(), getHeight(),12,12);
// g.setBackgroundColor(Color.WHITE);
super.paint(g);
}
public void sublayout(int width, int height)
{
super.sublayout(265, 73);
setExtent(265,73);
}
};
editField = new RichTextField(Field.STATUS_MOVE_FOCUS_VERTICALLY )
{
public void paint(Graphics g)
{
getManager().invalidate();
g.setColor(Color.BLACK);
super.paint(g);
}
};
editField .setMargin(5,2, 0, 5);
editField.setEditable(true);
Border bdr = BorderFactory.createRoundedBorder(new XYEdges(4, 4, 4, 4),Border.STYLE_SOLID);
editField.setBorder(bdr);
vfm.add(editField);
Plz give me the solution. I not get scrollable......
01-15-2013 05:35 AM
Not tested but try this:
1) remove all the Manager.STATUS_MOVE_FOCUS_VERTICALLY style settings you have.
2) Change the sublayout to the following:
public void sublayout(int width, int height)
{
super.sublayout(265, height);
setExtent(this.getWidth(),73);
}
Note that coding pixels like this is going to cause you problems when you try to move the application to a different device. I would try to make these sorts of things relative, say for margins you could set them to be 1/20 of the device's screen width. Just a thought.
01-15-2013 08:46 AM
There are two gadgets in the knowledge base which provide you all the functionality you need:
TextBoxField revisited gives you an example of creating a vertically scrollable text box of a predefined vertical size - if you replace EditField with RichTextField you will get what you want.
Implementing a standard style scrollbar has a substitution for VerticalFieldManager which shows a Windows-like scrollbar. Replace VerticalFieldManager with VerticalScrollManager in your modification of TextBoxField and you'll get something very similar to what you want.
Make sure to read comments in both articles - they contain ideas on further development.
01-17-2013 11:53 PM
1) remove all the Manager.STATUS_MOVE_FOCUS_VERTICALLY style settings you have.
2) Change the sublayout to the following:
public void sublayout(int width, int height)
{
super.sublayout(265, height);
setExtent(this.getWidth(),73);
}
it is not work
I want to scroll the text which input on the richtextfield
01-18-2013 01:39 AM
Hi,
My text is scrolling but the problem is that the white patch behind the text is also scrolling.
code:-
vfm =new VerticalFieldManager(VerticalFieldManager.VERTICAL
{
public void paint(Graphics g)
{
g.setBackgroundColor(Color.WHITESMOKE);
g.fillRoundRect(4, 1,getWidth(), getHeight(),0,0);
// g.drawRoundRect(0, 0,getWidth(), getHeight(),12,12);
// g.setBackgroundColor(Color.WHITE);
super.paint(g);
}
public void sublayout(int width, int height)
{
super.sublayout(265,height ); //73
setExtent(this.getWidth(),73); //265
}
};
editField = new RichTextField( )
{
public void paint(Graphics g)
{
// getManager().invalidate();
g.setColor(Color.BLACK);
// g.setBackgroundColor(Color.WHITE);
super.paint(g);
}
// public void sublayout(int width, int height)
// {
// super.layout(265,height ); //73
// setExtent(this.getWidth(),73);
//
// }
};
the problem is given by
g.fillRoundRect(4, 1,getWidth(), getHeight(),0,0);
line if i remove this then the white patch not drawn
I attached the output
Plz help me
01-18-2013 10:23 AM
Adjust your fillRoundRect parameters with the scrolling position:
g.fillRoundRect(getHorizontalScroll() + 4, getVerticalScroll() + 1, getWidth() - 8, getHeight() - 2, 0, 0);
By the way, I suspect you misplaced your parameters - the first two are the coordinates of the upper left corner of the rectangle, the last two are arcWidth and arcHeight. If I'm right and you inadvertently switched places, the call will look like:
g.fillRoundRect(getHorizontalScroll(), getVerticalScroll(), getWidth(), getHeight(), 4, 1);
Good luck!
01-18-2013 11:47 PM
thanks for ur solution it work........Thank you so much