【Java】NTTドコモ FOMA iアプリ版 日蒙簡易辞書

NTTドコモ FOMA iアプリ版 日蒙簡易辞書

NTTドコモ FOMA iアプリ版 日蒙簡易辞書

  • タグ:
  • タグはありません
package net.hinekure.ijmdic;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.microedition.io.Connector;
import com.nttdocomo.ui.Button;
import com.nttdocomo.ui.Component;
import com.nttdocomo.ui.ComponentListener;
import com.nttdocomo.ui.Display;
import com.nttdocomo.ui.IApplication;
import com.nttdocomo.ui.Label;
import com.nttdocomo.ui.Panel;
import com.nttdocomo.ui.TextBox;
public class Launcher extends IApplication {
public void start() {
TxtPanel myPanel;
myPanel = new TxtPanel();
Display.setCurrent(myPanel);
}
}
class TxtPanel extends Panel {
Label lblLabel;
TextBox txtBox;
Button btn;
Label lblLabel2;
TextBox txtBox2;
//
TxtPanel() {
lblLabel = new Label(" Ver 1.00");
lblLabel.setSize(240, 14);
//
txtBox = new TextBox("", 100, 1, TextBox.DISPLAY_ANY);
txtBox2 = new TextBox("", 100, 10, TextBox.DISPLAY_ANY);
// txtBox2.setEditable(false);
btn = new Button("");
btn.setSize(240, 20);
lblLabel2 = new Label("");
lblLabel2.setSize(240, 12);
//
this.add(lblLabel);
this.add(txtBox);
this.add(btn);
this.add(lblLabel2);
this.add(txtBox2);
//
this.setComponentListener(new ListenerObj(lblLabel2, txtBox, txtBox2,
btn));
}
}
class ListenerObj implements ComponentListener {
private Label myLbl;
private TextBox myTxt;
private TextBox myTxt2;
private Button myBtn;
public ListenerObj(Label receLbl, TextBox recetxt, TextBox recetxt2,
Button receBtl) {
myLbl = receLbl;
myTxt = recetxt;
myTxt2 = recetxt2;
myBtn = receBtl;
}
public void componentAction(Component c, int type, int param) {
if ((c == myBtn) && (type == BUTTON_PRESSED)) {
Search();
}
}
private void Search() {
InputStream is = null;
com.nttdocomo.io.BufferedReader br = null;
String out = null;
out = "";
String str;
int result_num = 0;
String keywords;
keywords = myTxt.getText();
myLbl.setText("");
try {
try {
is = Connector.openInputStream("resource:///jmdic_sjis.txt");
br = new com.nttdocomo.io.BufferedReader(new InputStreamReader(
is));
str = br.readLine();
while ((str = br.readLine()) != null) {
//
if ((str.indexOf(keywords) != -1) || (keywords == "")) {
out += str + "\n";
result_num++;
myLbl.setText("" + result_num + "!");
}
}
} finally {
if (br != null)
br.close();
}
if (result_num == 0) {
out = "\n\n";
}
} catch (IOException e) {
out = "...";
}
myTxt2.setText(out);
}
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX