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.

inside custom component

Java Development

Reply
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

How the browser Content are Horizontal Scroll in Os 4.6??

Hello i develop one application for HTML page show in the page.

This application are run perfectlly but there are some problem .

 

They Content are not scroll Horizontal so how to do slove this application????

 

Here i attach my code show given me some solution.

import java.io.ByteArrayOutputStream;

import javax.microedition.io.HttpConnection;

import net.rim.device.api.browser.field.BrowserContent;
import net.rim.device.api.browser.field.Event;
import net.rim.device.api.browser.field.RenderingOptions;
import net.rim.device.api.browser.field.RenderingSession;
import net.rim.device.api.io.Base64OutputStream;
import net.rim.device.api.io.http.HttpHeaders;
import net.rim.device.api.ui.Field;
import net.rim.device.api.ui.Font;
import net.rim.device.api.ui.Manager;
import net.rim.device.api.ui.MenuItem;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.Menu;
import net.rim.device.api.ui.component.NullField;
import net.rim.device.api.ui.component.RadioButtonField;
import net.rim.device.api.ui.component.RadioButtonGroup;
import net.rim.device.api.ui.component.RichTextField;
import net.rim.device.api.ui.container.DialogFieldManager;
import net.rim.device.api.ui.container.FullScreen;
import net.rim.device.api.ui.container.HorizontalFieldManager;
import net.rim.device.api.ui.container.MainScreen;
import net.rim.device.api.ui.container.VerticalFieldManager;


public class BrowserFi extends MainScreen{
	HorizontalFieldManager ve=new HorizontalFieldManager(HORIZONTAL_SCROLL);
	private String fontType = "Times New Roman";
	String htmlString;
	Field field;
	public BrowserFi() {
		super(DEFAULT_CLOSE |DEFAULT_MENU |Field.USE_ALL_HEIGHT |Field.USE_ALL_WIDTH );
	try{	
		//NOMINAL PIPE DIAM. IN INCHE
		//ACUTAL INSIDE DIAM. IN INCHES
		//ACTUAL OUTSIDE DIAM.IN INCHES
		//WEIGHT PER FOOT POUNDS
		//style='table-layout:fixed'
		 htmlString = "<html>"+
		"<head>"+"<meta name='HandheldFriendly' content='true' >"+"<meta name='viewport' content='width=device-width,user=scalable=yes' >"+"<meta http-equiv='Content-Type' content='text/html; charset=iso-8859-1'>"+
		"</head>"+
		"<body bgcolor='#99FFFF' width='100%' font-style='italic'>"+
		"<h1>STANDARD PIPE DATA</h1>"+
		"<table border='1' width='480px' >"+
		"<tr>"+
		"<th width='80px'>Hi</th>"+
		"<th width='80px'>Hello</th>"+
		"<th width='80px'>How</th>"+
		"<th width='80px'>Are </th>"+
		"<th width='130px'>you?</th>"+
		"</tr>"+
		"<tr>"+
		"<td width='80px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td width='80px'>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td width='80px'>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td width='80px'>.244<br/>.424<br/>.567<br/>.850<br/>1.130<br/></td>"+
		"<td width='130px'>2526.000<br/>13836.800<br/>754.360<br/>473.910<br/>270.030<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='96px'>1<br/>1 ¼<br/>1 ½<br/>2<br/>2 ½</td>"+
		"<td width='96px'>1.049<br/>1.380<br/>1.610<br/>2.067<br/>2.469</td>"+
		"<td width='96px'>1.315<br/>1.660<br/>1.900<br/>2.375<br/>2.875</td>"+
		"<td width='96px'>1.678<br/>2.272<br/>2.717<br/>3.652<br/>5.793<br/></td>"+
		"<td width='96px'>166.620<br/>.275<br/>70.733<br/>49.913<br/>30.077<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='96px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>7.575<br/>9.109<br/>10.790<br/>12.538<br/>14.617<br/></td>"+
		"<td>19.479<br/>14.565<br/>11.312<br/>9.030<br/>7.198<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"<tr>"+
		"<td width='200px'>1/8<br/>1/4<br/>3/8<br/>1/2<br/>3/4</td>"+
		"<td>.269<br/>.364<br/>.493<br/>.622<br/>.824</td>"+
		"<td>.405<br/>.540<br/>.675<br/>.840<br/>1.050</td>"+
		"<td>18.974<br/>28.554<br/>40.483<br/></td>"+
		"<td>4.984<br/>2.878<br/>1.826<br/></td>"+
		"</tr>"+
		"</table>"+
		"<h1><center>BARLOW'S FORMULA</center></h1>"+
		"<p>Barlow &apos s Formula is a safe, easy method for finding the relationship between internal fluid pressure and stress in the pipe wall.  The formula predicts bursting pressures that have been found to be safely within the actual test bursting pressures.</p>"+
		"<p>It is interesting to note that the formula uses the &quot outside diameter &quot of pipe and is sometimes referred to as the &quot outside diameter formula.&quot</p>"+
		"<p> where:<br>P = internal units pressure, psi<br>S = unit stress, psi<br>D = outside diameter of pipe, in.<br>t = wall thickness, in.</p>"+
		"</body>"+
		"</html>";
		
		/*ByteArrayOutputStream output = new ByteArrayOutputStream();
        Base64OutputStream boutput = new Base64OutputStream( output );
        output.write( "data:text/html;base64,".getBytes() );
        boutput.write( htmlString.getBytes() );
        boutput.flush();
        boutput.close();
        output.flush();
        output.close();*/
		
		HttpConnection connection = new HttpConnectionImpl(htmlString);
		
		 BrowserContent content = RenderingSession.getNewInstance().getBrowserContent(connection,null,null);
		 
		 field = content.getDisplayableContent();
		 field.setFont(Font.getDefault().derive(Font.PLAIN, 1));
		RichTextField vi=new RichTextField("Hello Barlow’s Formula is a safe, easy method for finding the relationship between internal fluid pressure and stress in the pipe wall.  The formula predicts bursting pressures that have been found to be safely within the actual test bursting pressures.");
		HeaderField head=new HeaderField("Pipe Fitter");
		
		add(head);
		//ve.setFont(Font.getDefault().derive(Font.DOTTED_UNDERLINED, 1));
		ve.add(field);
		
		ve.add(vi);
		add(ve);
		content.finishLoading();
	}
	catch(Exception e){
		System.out.println("---"+e);
	}
	}
	private MenuItem miFontType = new MenuItem("Fonts", 110, 10){
	String choices[] = { "  OK    ", "Cancel" };
	int values[] = { Dialog.OK, Dialog.CANCEL };
	RadioButtonField[] buttons = new RadioButtonField[4];
	int selectedIndex = 0;

	public void run() {

		if (fontType.equalsIgnoreCase(Const.FONT_NAME_1)) {
			selectedIndex = 0;
		} else if (fontType.equalsIgnoreCase(Const.FONT_NAME_2)) {
			selectedIndex = 1;
		} else if (fontType.equalsIgnoreCase(Const.FONT_NAME_3)) {
			selectedIndex = 2;
		} else if (fontType.equalsIgnoreCase(Const.FONT_NAME_4)) {
			selectedIndex = 3;
		}

		buttons[0] = new RadioButtonField(Const.FONT_NAME_1, null, false,
				Field.USE_ALL_WIDTH | Field.FIELD_HCENTER);
		buttons[1] = new RadioButtonField(Const.FONT_NAME_2, null, false,
				Field.USE_ALL_WIDTH | Field.FIELD_HCENTER);
		buttons[2] = new RadioButtonField(Const.FONT_NAME_3, null, false,
				Field.USE_ALL_WIDTH | Field.FIELD_HCENTER);
		buttons[3] = new RadioButtonField(Const.FONT_NAME_4, null, false,
				Field.USE_ALL_WIDTH | Field.FIELD_HCENTER);

		RadioButtonDialog d = new RadioButtonDialog("Font Type:", choices,
				values, buttons, selectedIndex);
		int status = d.doModal();
		if (status == Dialog.OK) {
			fontType = d.getRadioButtonValue();
			if (fontType != null) {
				fontType = fontType.toLowerCase().trim();
			} else
				fontType = "serif";
		} else if (status == Dialog.CANCEL) {
			d.close();
		}
	}
	};
	
	protected void makeMenu(Menu menu, int instance) {
	menu.add(miFontType);

	}
	

}

final class RadioButtonDialog extends Dialog {

RadioButtonGroup rbGroup = new RadioButtonGroup();
RadioButtonField[] buttons;

public RadioButtonDialog(String title, String choices[], int values[],
	RadioButtonField[] rButtons, int selectedIndex) {
super(title, choices, values, Dialog.OK, null, Dialog.GLOBAL_STATUS);
this.buttons = rButtons;
rButtons = null;
for (int i = 0; i < this.buttons.length; i++) {
	rbGroup.add(this.buttons[i]);
}
rbGroup.setSelectedIndex(selectedIndex);

Manager delegate = getDelegate();
if (delegate instanceof DialogFieldManager) {
	DialogFieldManager dfm = (DialogFieldManager) delegate;
	Manager manager = dfm.getCustomManager();

	if (manager != null) {
		for (int i = 0; i < this.buttons.length; i++) {
			this.buttons[i].setMargin(0, 0, 0, 30);
			manager.add(this.buttons[i]);
		}
	}
}

}

public String getRadioButtonValue() {
if (rbGroup.getSelectedIndex() != -1)
	return buttons[rbGroup.getSelectedIndex()].getLabel();
else
	return null;
}

public int getSelectedIndex() {
return rbGroup.getSelectedIndex();
}
}

 

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import javax.microedition.io.HttpConnection;

import net.rim.device.api.io.Base64OutputStream;

public class HttpConnectionImpl implements HttpConnection {
    private long streamLength = 7000;
    private DataInputStream dataInput;
    private InputStream in;
    private String encoding = "text/html";

    public HttpConnectionImpl(String data) {
        try {
        	//UTF-8ISO-8859-1
            in = new ByteArrayInputStream(data.getBytes("ISO-8859-1"));
            dataInput = new DataInputStream(in);
        } catch (Exception e) {
            System.out.println("HttpConnectionImpl : Exception : " + e);
        }

    }

    public String getURL() {
        return "";
    }

    public String getProtocol() {
        return "";
    }

    public String getHost() {
        return "";
    }

    public String getFile() {
        return "";
    }

    public String getRef() {
        return "";
    }

    public String getQuery() {
        return "";
    }

    public int getPort() {
        return 0;
    }

    public String getRequestMethod() {
        return "";
    }

    public void setRequestMethod(String s) throws IOException {

    }

    public String getRequestProperty(String s) {
        return "";
    }

    public void setRequestProperty(String s, String s1) throws IOException {

    }

    public int getResponseCode() throws IOException {
        return 200;
    }

    public String getResponseMessage() throws IOException {
        return "";
    }

    public long getExpiration() throws IOException {
        return 0;
    }

    public long getDate() throws IOException {
        return 0;
    }

    public long getLastModified() throws IOException {
        return 0;
    }

    public String getHeaderField(String s) throws IOException {
        return "";
    }

    public int getHeaderFieldInt(String s, int i) throws IOException {
        return 0;
    }

    public long getHeaderFieldDate(String s, long l) throws IOException {
        return 0;
    }

    public String getHeaderField(int i) throws IOException {
        return "";
    }

    public String getHeaderFieldKey(int i) throws IOException {
        return "";
    }

    public String getType() {
        return "text/html";
    }

    public String getEncoding() {
        return encoding;
    }

    public long getLength() {
        return streamLength;
    }

    public InputStream openInputStream() throws IOException {
        return in;
    }

    public DataInputStream openDataInputStream() throws IOException {
        return dataInput;
    }

    public void close() throws IOException {

    }

    public OutputStream openOutputStream() throws IOException {
        return new ByteArrayOutputStream();
    }

    public DataOutputStream openDataOutputStream() throws IOException {
        return new DataOutputStream(new ByteArrayOutputStream());
    }
}

 

 

here i attach my code.

so show that and reply me as soon as possibel .