超长的java代码 java代码过长

一段比较长java的代码 , 高手帮我解决几个问题1.GroupLayout layout=new GroupLayout(c);
创建一个GroupLayout的对象,同时创建时需要以一个Container的对象作为参数
2 layout.setAutoCreateContainerGaps(true);
setAutoCreateContainerGaps(boolean)是用来设置是否应该自动创建容器与触到容器边框的组件之间的间隙,参数是一个boolean值,true代表是,false代表否 。
3. GroupLayout.ParallelGroup hpg2a=layout.createParallelGroup(GroupLayout.Alignment.LEADING);
ParallelGroup 是GroupLayout的一个内部类,所以要创建他的实例必须是这样的:GroupLayout.ParallelGroup
createParallelGroup(GroupLayout.Alignment alignment)方法使用 Alignment.LEADING 的对齐方式创建并返回一个 ParallelGroup,Alignment.LEADING是GroupLayout的一个field,在这里以这个作为参数 。这句话就是一个简单的语句,不能再简单里,你看里面虽然有很多点,但其实只有一个层次就相当于 A a = b.c(o);
4. hpg2a.addComponent(cb2);
将 Component 对象作为参数添加到此 Group 。就是给GroupLayout.ParallelGroup添加一个cb2组件
总结:你对api很不了解,这些东西都是在api里面可以查到的,所以你应该把api下载下来,放在自己的桌面上随时查阅,学java 的时候api文档是必不可少的工具哦,加油!
求一个简单的JAVA游戏代码,100行左右 , 谢谢!import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Painter extends JFrame{
/**
*
*/
private static final long serialVersionUID = 8160427604782702376L;
CanvasPanel canvas = new CanvasPanel();;
public Painter() {
super("Star");
this.add(canvas);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.setResizable(false);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public static void main(String[] args) {
new Painter();
}
}
class CanvasPanel extends JPanel implements ActionListener{
/**
*
*/
private static final long serialVersionUID = -4642528854538741028L;
private JButton[] btn = new JButton[4];
private String[] btn_name = {"+", "-", "R", "L"};
private int center_x = 200, center_y = 200, radius = 100, degree = 0;
public CanvasPanel() {
this.setPreferredSize(new Dimension(400, 500));
this.setLayout(null);
for(int i = 0; i4; i++) {
btn[i] = new JButton(btn_name[i]);
btn[i].setBounds(160 + i * 60, 425, 50, 50);
btn[i].addActionListener(this);
this.add(btn[i]);
}
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
for(int i = 0; i5; i++) {
g.drawLine( (int) (center_x + radius * Math.sin(Math.toRadians(degree + 72 * i))),
(int) (center_y - radius * Math.cos(Math.toRadians(degree + 72 * i))),
(int) (center_x + radius * Math.sin(Math.toRadians(degree + 72 * i + 144))),
(int) (center_y - radius * Math.cos(Math.toRadians(degree + 72 * i + 144))));
}
}
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
if(e.getActionCommand() == "+") {
if(radius200)
radius += 2;
repaint();
} else if(e.getActionCommand() == "-") {
if(radius0)
radius -= 2;
repaint();
} else if(e.getActionCommand() == "R") {
degree = (degree + 2) % 360;
repaint();
} else if(e.getActionCommand() == "L") {
degree = (degree - 2) % 360;
repaint();
}
}
}
谁能给一个Java程序代码我,要50行到100行就可以啦 。最好有几行解释给你一个前几天才帮人写的

推荐阅读