?? class-schedule3.java
字號(hào):
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.text.*;
import java.util.*;
public class class-schedule3 extends Frame {
private int position = 0;
private static Object location[][] = {
{"San Mateo, CA", Locale.US},
{"Milano, Italia", Locale.ITALY},
{"Espoo, Suomi", new Locale("fi", "FI")}
};
public class-schedule3() {
this(null);
}
public class-schedule3(Locale loc) {
super("Java Training");
if (loc != null) {
for (int i=0;i<location.length;i++) {
if (loc.equals((Locale)location[i][1])) {
position = i;
break;
}
}
}
ResourceBundle labels = ResourceBundle.getBundle(
"training-settings-bundle", (Locale)location[position][1]);
ResourceBundle settings = ResourceBundle.getBundle(
"training-settings-bundle", (Locale)location[position][1]);
Image im = getToolkit().getImage(
getClass().getResource(settings.getString("Map")));
image-canvas ic = new ImageCanvas(im);
Panel p = new Panel(new GridLayout(3, 2));
p.add(new Label(labels.getString("Date")));
String dateString = settings.getString("Date");
DateFormat dfInput = DateFormat.getDateInstance(
DateFormat.LONG, Locale.US);
DateFormat dfOutput = DateFormat.getDateInstance(
DateFormat.SHORT, (Locale)location[position][1]);
String dateLabelString;
try {
dateLabelString = dfOutput.format(dfInput.parse(dateString));
}
catch (ParseException e) {
dateLabelString = dateString;
}
p.add(new Label(dateLabelString));
p.add(new Label(labels.getString("Cost")));
String costString = settings.getString("Cost");
NumberFormat nfInput =
NumberFormat.getNumberInstance(Locale.US);
NumberFormat nfOutput = NumberFormat.getCurrencyInstance(
(Locale)location[position][1]);
String costLabelString;
try {
Number n = nfInput.parse(costString);
costLabelString = nfOutput.format(n.longValue());
}
catch (ParseException e) {
costLabelString = costString;
}
p.add(new Label(costLabelString));
p.add(new Label(labels.getString("Location")));
p.add(new Label((String)location[position][0]));
add(new Label(labels.getString("Title"), Label.CENTER),
BorderLayout.NORTH);
add(p, BorderLayout.SOUTH);
ScrollPane sp = new ScrollPane();
sp.add(ic);
add(sp, BorderLayout.CENTER);
setSize(300, 250);
}
public static void main(String[] args) {
for (int i=0;i<location.length;i++) {
Frame f = new class-schedule3((Locale)location[i][1]);
f.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
f.setVisible(true);
}
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -