具体情况是这样的aacaacaa可以排列为aac
aac
aa现在我的判断程序已经弄好
要求是将上面的矩阵可视化的显示到一个applet里面请各位高手给指点一下,怎么搞啊
本人对于applet不熟悉啊
高分求,能不能给个简单的源代码,包括坐标定位和如何可视化在panel上写字母的高分求了,谢谢
aac
aa现在我的判断程序已经弄好
要求是将上面的矩阵可视化的显示到一个applet里面请各位高手给指点一下,怎么搞啊
本人对于applet不熟悉啊
高分求,能不能给个简单的源代码,包括坐标定位和如何可视化在panel上写字母的高分求了,谢谢
import java.awt.Graphics;import javax.swing.JFrame;
import javax.swing.JPanel;public class TestPanel extends JPanel {
private String data;
public final static int cols = 4;
public final static int x0 = 10; //x偏移量
public final static int y0 = 10; //y偏移量
public final static int rowH = 20;//行距
public final static int colH = 20;//列间距
public static void main(String args[]) {
JFrame f = new JFrame();
f.getContentPane().add(new TestPanel("abcdadsdfs"));
f.setSize(400, 400);
f.setVisible(true);
}
public TestPanel(String str) {
this.data = str;
}
@Override
public void paint(Graphics g) {
super.paint(g);
paintData(g);
}
private void paintData(Graphics g) {
int x = 0;
int y = 0;
int col = 0;
int row = 0;
for(int i =0; i < data.length(); i++) {
col = i % cols;
row = i / cols;
x = x0 + col * rowH;
y = y0 + row * colH;
g.drawString(data.substring(i, i + 1), x, y);
}
}
}
}
paint 个点不就o了
自己控制好坐标