Java by API/javax.microedition.lcdui/ImageItem — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 17:43, 31 мая 2010
Содержание
ImageItem.LAYOUT_CENTER
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
public class Main extends MIDlet {
Display d;
Form aForm = new Form("Demo Form");
ChoiceGroup aChoiceGroup = new ChoiceGroup("Choose", Choice.EXCLUSIVE, new String[] { "This",
"That" }, null);
DateField aDateField = new DateField(null, DateField.TIME);
Gauge aGauge = new Gauge("Score", true, 10, 1);
StringItem aStringItem = new StringItem(null, "Demo Items");
TextField aTextField = new TextField("Comments", "Your comments here", 20, 0);
ImageItem anImageItem;
Image anImage;
public Main() {
try {
anImage = Image.createImage("/star.png");
} catch (java.io.IOException ioE) {
System.out.println("Problem reading image");
}
anImageItem = new ImageItem("Demo Image", anImage, ImageItem.LAYOUT_CENTER, "No image");
aForm.append(aStringItem);
aForm.append(aChoiceGroup);
aForm.append(aDateField);
aForm.append(aGauge);
aForm.append(aTextField);
aForm.append(anImageItem);
}
protected void startApp() {
d = Display.getDisplay(this);
d.setCurrent(aForm);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
ImageItem.LAYOUT_DEFAULT
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;
public class ImageItemLAYOUT_DEFAULT extends MIDlet {
protected Display display;
protected void startApp() {
display = Display.getDisplay(this);
Form form = new Form("Demo");
form.append("line");
try {
Image red = Image.createImage("/red.png");
form.append(new ImageItem("Default", red, ImageItem.LAYOUT_DEFAULT, null));
} catch (IOException ex) {
form.append("Failed to load images");
}
display.setCurrent(form);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
ImageItem.LAYOUT_LEFT
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;
public class ImageItemLAYOUT_LEFT extends MIDlet {
protected Display display;
protected void startApp() {
display = Display.getDisplay(this);
Form form = new Form("Demo");
form.append("line");
try {
Image red = Image.createImage("/red.png");
form.append(new ImageItem("Left", red, ImageItem.LAYOUT_LEFT, null));
} catch (IOException ex) {
form.append("Failed to load images");
}
display.setCurrent(form);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
ImageItem.LAYOUT_NEWLINE_AFTER
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;
public class ImageItemLAYOUT_NEWLINE_BEFORELAYOUT_CENTER extends MIDlet {
protected Display display;
protected void startApp() {
display = Display.getDisplay(this);
Form form = new Form("Demo");
form.append("line");
try {
Image red = Image.createImage("/red.png");
form.append(new ImageItem(null, red,
ImageItem.LAYOUT_NEWLINE_BEFORE |
ImageItem.LAYOUT_CENTER |
ImageItem.LAYOUT_NEWLINE_AFTER, null));
} catch (IOException ex) {
form.append("Failed to load images");
}
display.setCurrent(form);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
ImageItem.LAYOUT_NEWLINE_BEFORE
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;
public class ImageItemLAYOUT_NEWLINE_BEFORELAYOUT_CENTER extends MIDlet {
protected Display display;
protected void startApp() {
display = Display.getDisplay(this);
Form form = new Form("Demo");
form.append("line");
try {
Image red = Image.createImage("/red.png");
form.append(new ImageItem(null, red,
ImageItem.LAYOUT_NEWLINE_BEFORE |
ImageItem.LAYOUT_CENTER |
ImageItem.LAYOUT_NEWLINE_AFTER, null));
} catch (IOException ex) {
form.append("Failed to load images");
}
display.setCurrent(form);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
ImageItem.LAYOUT_RIGHT
import java.io.IOException;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.midlet.MIDlet;
public class ImageItemLAYOUT_RIGHT extends MIDlet {
protected Display display;
protected void startApp() {
display = Display.getDisplay(this);
Form form = new Form("Demo");
form.append("line");
try {
Image red = Image.createImage("/red.png");
form.append(new ImageItem("Right", red, ImageItem.LAYOUT_RIGHT, null));
} catch (IOException ex) {
form.append("Failed to load images");
}
display.setCurrent(form);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}
new ImageItem(String label, Image img, int layout, String altText)
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.ChoiceGroup;
import javax.microedition.lcdui.DateField;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Gauge;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.ImageItem;
import javax.microedition.lcdui.StringItem;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.MIDlet;
public class Main extends MIDlet {
Display d;
Form aForm = new Form("Demo Form");
ChoiceGroup aChoiceGroup = new ChoiceGroup("Choose", Choice.EXCLUSIVE, new String[] { "This",
"That" }, null);
DateField aDateField = new DateField(null, DateField.TIME);
Gauge aGauge = new Gauge("Score", true, 10, 1);
StringItem aStringItem = new StringItem(null, "Demo Items");
TextField aTextField = new TextField("Comments", "Your comments here", 20, 0);
ImageItem anImageItem;
Image anImage;
public Main() {
try {
anImage = Image.createImage("/star.png");
} catch (java.io.IOException ioE) {
System.out.println("Problem reading image");
}
anImageItem = new ImageItem("Demo Image", anImage, ImageItem.LAYOUT_CENTER, "No image");
aForm.append(aStringItem);
aForm.append(aChoiceGroup);
aForm.append(aDateField);
aForm.append(aGauge);
aForm.append(aTextField);
aForm.append(anImageItem);
}
protected void startApp() {
d = Display.getDisplay(this);
d.setCurrent(aForm);
}
protected void pauseApp() {
}
protected void destroyApp(boolean unconditional) {
}
}