귀속
6062 단어 귀속
순서
분기
순환하다
:
system.out……
for(int i=0;i
}
귀속
종료 방법은 리턴을 쓰면 됩니다.
1. 알고리즘이 통용된다.
2. 종료 조건이 있습니다.
자신을 호출하는 것이 아니라 호출하는 방법의 내용은 자신과 같다.
창고
더미: 일반적으로 일종의 무질서한 구조로 일반적으로 창설된 대상을 유지한다.heap
스택 오버플로우
사귀환은 프로그램의 퇴출을 초래할 수 있다
데드 사이클
도구류
200ms 일시 중지
try{
Thread.sleep(200);
}catch(Exception ef){}
슬라이더
java.swing.JSlider js=new java.swing.JSlider();
this.add(js);
js.setValue(255);
값 js를 얻습니다.getValue();
SliderListener sl=new SliderListener();
최대값, 최소값, js를 설정합니다.setMaximum(10);
js.addChangeListener(sl);
삼각형 코드:
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
public class triangle extends JFrame{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
triangle tr=new triangle();
tr.InitGUI();
}
private void InitGUI() {
// TODO Auto-generated method stub
// this.setTitle(" ");
this.setSize(new Dimension(700,600));
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(3);
this.setVisible(true);
Graphics g=this.getGraphics();
MouseListener bl=new Listener(g);
this.addMouseListener(bl);
}
}
listener:
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class Listener implements MouseListener {
private Graphics g;
public Listener(Graphics g){
this.g=g;
}
public void draw(Graphics g,int a1,int a2,int b1,int b2,int c1,int c2, int count){
int d1,d2,e1,e2,f1,f2;
count++;
g.drawLine(a1, a2, b1, b2);
g.drawLine(c1, c2, b1, b2);
g.drawLine(a1, a2, c1, c2);
if (count>=6){return;}
d1=(a1+b1)/2;
d2=(a2+b2)/2;
e1=(a1+c1)/2;
e2=(a2+c2)/2;
f1=(c1+b1)/2;
f2=(c2+b2)/2;
draw(g,a1,a2,e1,e2,d1,d2,count);
draw(g,b1,b2,d1,d2,f1,f2,count);
draw(g,c1,c2,e1,e2,f1,f2,count);
}
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
draw(g,300,50,100,(int)(200*Math.sqrt(3))+50,500,(int)(200*Math.sqrt(3))+50,0);
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}
:
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
public class square extends JFrame{
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
square tr=new square();
tr.InitGUI();
}
private void InitGUI() {
// TODO Auto-generated method stub
this.setSize(new Dimension(700,700));
this.setLocationRelativeTo(null);
this.setDefaultCloseOperation(3);
this.setVisible(true);
Graphics g=this.getGraphics();
MouseListener bl=new Listener3(g);
this.addMouseListener(bl);
}
}
:
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class Listener3 implements MouseListener {
private Graphics g;
public Listener3(Graphics g){
this.g=g;
}
public void draw(Graphics g,int x1,int x2,int h,int w, int count){
if (count==0){g.draw3DRect(x1, x2, h, w, false);}
count++;
g.fill3DRect(x1+(int)(h/3), x2+(int)(h/3), (int)(h/3), (int)(h/3), false);
if (count>=6){return;}
draw(g,x1,x2,(int)(h/3),(int)(h/3),count);
draw(g,x1+(int)(h/3),x2,(int)(h/3),(int)(h/3),count);
draw(g,x1,x2+(int)(h/3),(int)(h/3),(int)(h/3),count);
draw(g,x1+(int)(h/3),x2+(int)(h/3),(int)(h/3),(int)(h/3),count);
draw(g,x1+(int)(h/3)*2,x2,(int)(h/3),(int)(h/3),count);
draw(g,x1+(int)(h/3),x2+(int)(h/3)*2,(int)(h/3),(int)(h/3),count);
draw(g,x1+(int)(h/3)*2,x2+(int)(h/3)*2,(int)(h/3),(int)(h/3),count);
draw(g,x1,x2+(int)(h/3)*2,(int)(h/3),(int)(h/3),count);
draw(g,x1+(int)(h/3)*2,x2+(int)(h/3),(int)(h/3),(int)(h/3),count);
}
@Override
public void mouseClicked(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseEntered(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mouseExited(MouseEvent arg0) {
// TODO Auto-generated method stub
}
@Override
public void mousePressed(MouseEvent arg0) {
// TODO Auto-generated method stub
draw(g,50,50,600,600,0);
}
@Override
public void mouseReleased(MouseEvent arg0) {
// TODO Auto-generated method stub
}
}