2013-10-25 23 views
0

我正在使用诺基亚阿莎sdk1.0。我在我的应用程序中使用TextArea,但我的textarea不是scrollable.i使用下面的代码,所以如何使它滚动。如何使textArea在诺基亚可以滚动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库更多JScrollPanes?然后你应该添加LWUIT标签。 – Meier

+0

我认为这个链接可以帮助你。 http://stackoverflow.com/questions/17144349/lwuit-textarea-scroll-issue –

回答

1

要使TextArea文本可滚动,您必须使用滚动窗格。

您需要做的是这样

JScrollPane scrollPane = new JScrollPane(textarea); 

看到http://docs.oracle.com/javase/7/docs/api/javax/swing/JScrollPane.html

+0

我的平台是JAVAME。我们不能用摇摆的任何组件在我的平台我think.so给我任何其他方式使滚动textArea –

+0

您可以使用kAWT的J2ME - http://www.trantor.de/kawt/ – josh

+0

任何人请给我具体的答案我的问题。我卡住了 –