2013-10-25 1 views
0

Я работаю над nokia asha sdk1.0. Я использую TextArea в своем приложении, но мой текстовый файл не прокручивается. Я использовал следующий код, чтобы сделать его прокручиваемым.Как сделать textArea прокручиваемым в nokia asha sdk1.0

Display.init(this); 
     Display.getInstance().setForceFullScreen(true); 
     Form form=new Form(); 
     form.setScrollable(false); 
     form.getUnselectedStyle().setBgColor(10175989); 
     form.setLayout(new BorderLayout()); 
     Container northcon=new Container(); 
     int northcomponentHT=form.getPreferredH()*20/100; 
     northcon.setPreferredH(northcomponentHT); 
     Label northlab=new Label("NORTH"); 
     northcon.addComponent(northlab); 
     form.addComponent(BorderLayout.NORTH,northcon); 
     Container centercon=new Container(); 
     TextArea textarea=new TextArea(); 
     int centercomponentHT=form.getPreferredH()*60/100; 
     textarea.setPreferredH(centercomponentHT); 
     textarea.setPreferredW(form.getPreferredW()); 
     String string=new String("dfjjkfjknfsdfhkfjfjcannot be surpassed by that of watching electric lights. Everyone in Gods creation is special and so are wcannot be surpassed by that of watching electric lights. Everyone in Gods creation is special and so are wcannot be surpassed by that of watching electric lights. Everyone in Gods creation is special and so are wcannot be surpassed by that of watching electric lights. Everyone in Gods creation is special and so are wcannot be surpassed by that of watching electric lights. Everyone in Gods creation is special and so are wcannot be surpassed by that of watching electric lights. Everyone in Gods creation is special and so are wcannot be surpassed by that of watching electric lights. Everyone in Gods creation is special and so are wkfiufjkfjkfjfjkfjierojfkjjiojkldf;jasf;ljsf;jl;dfjas;dflk;lfj;asdfljsdl;fkjierojeiorjoiejkfjoeirjjeoirjoejo;efdfkljoijerjorj"); 
     textarea.setScrollVisible(true); 

     textarea.setText(string); 
     textarea.setEditable(false); 
     textarea.setGrowByContent(true); 
     textarea.setRows(50); 

     //centercon.setScrollable(true); 
     centercon.addComponent(textarea); 

     form.addComponent(BorderLayout.CENTER,centercon); 
     Container southcon=new Container(); 
     int southcomponentHT=form.getPreferredH()*20/100; 
     southcon.setPreferredH(southcomponentHT); 
     Label southlab=new Label("SOUTH"); 
     southcon.addComponent(southlab); 
     form.addComponent(BorderLayout.SOUTH,southcon); 
     form.show(); 
+0

Вы используете библиотеку LWUIT? Затем вы должны добавить тег LWUIT. – Meier

+0

Я думаю, эта ссылка может вам помочь. http://stackoverflow.com/questions/17144349/lwuit-textarea-scroll-issue –

ответ

1

Чтобы текст TextArea прокручивался, вы должны использовать панель прокрутки.

Вы должны были бы сделать что-то вроде

JScrollPane scrollPane = new JScrollPane(textarea); 

Смотрите больше на JScrollPanes в http://docs.oracle.com/javase/7/docs/api/javax/swing/JScrollPane.html

+0

Моя платформа JavaME Мы не можем использовать любой компонент качания в моей платформе, как я think.so дать мне какой-либо другой способ сделать прокручиваемый текстArea –

+0

Вы можете использовать kAWT для J2ME - http://www.trantor.de/kawt/ – josh

+0

любой, пожалуйста, дайте мне конкретный ответ на мой вопрос.i застрял –

 Смежные вопросы

  • Нет связанных вопросов^_^