📄 pieapplet2.java
字号:
import java.awt.*;
import javax.swing.*;
public class PieApplet2 extends JApplet {
public void init() {
Container pane = getContentPane();
int topSlice = 1;
while (getParameter("color" + topSlice) != null) {
topSlice++;
}
PiePanel pie = new PiePanel(topSlice);
boolean noMoreSlices = false;
int currentSlice = 0;
while ((!noMoreSlices) & (currentSlice < topSlice)) {
// get color
String paramValue = getParameter("color" + currentSlice);
if (paramValue == null) {
noMoreSlices = true;
continue;
}
String redValue = paramValue.substring(0, 2);
int red = Integer.parseInt(redValue, 16);
String greenValue = paramValue.substring(2, 4);
int green = Integer.parseInt(greenValue, 16);
String blueValue = paramValue.substring(4, 6);
int blue = Integer.parseInt(blueValue, 16);
Color sliceColor = new Color(red, green, blue);
// get value
String sliceValue = getParameter("slice" + currentSlice);
int slice = Integer.parseInt(sliceValue);
// add slice
pie.addSlice(sliceColor, slice);
currentSlice++;
}
pane.add(pie);
setContentPane(pane);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -