Ⅰ java畫圖形
1.定義抽象類AbstractImage
import java.awt.Graphics;
public abstract class AbstractImage {
 public abstract void draw(Graphics g);
}
2.(示例)定義正方形類
import java.awt.*;
public class Rec extends AbstractImage {
 /*
  * 1.定義正方形左上頂點的坐標(x,y)
  * 2.定義正方形的寬為width,高為height
  * 3.寫構造方法,setter getter方法
  * */
 private int x;
 private int y;
 private int width;
 private int height;
 
 public Rec(){
  
 }
 
 public Rec(int x, int y, int width, int height) {
  this.x = x;
  this.y = y;
  this.width = width;
  this.height = height;
 }
 
 //重寫draw方法:正方形的draw方法
 public void draw(Graphics g) {
  Color c=g.getColor();//獲得窗口的前景色
  g.setColor(Color.BLUE);//設置正方形的前景色
  g.fillRect(x, y, width, height);//畫出正方形
 }
 public int getX() {
  return x;
 }
 public void setX(int x) {
  this.x = x;
 }
 public int getY() {
  return y;
 }
 public void setY(int y) {
  this.y = y;
 }
 public int getWidth() {
  return width;
 }
 public void setWidth(int width) {
  this.width = width;
 }
 public int getHeight() {
  return height;
 }
 public void setHeight(int height) {
  this.height = height;
 }
}
3.定義一個測試類,有main方法
在這個測試類中定義一個窗口(lanchFrame方法  會自動調用paint方法  paint方法里調用正方形的draw方法),到時我們要在這個窗口裡畫出正方形
import java.awt.*;
import java.awt.event.*;
public class Test extends Frame{
 
 //定義窗口的大小為常量
 private static final int GAME_WIDTH = 800;
 private static final int GAME_HEIGHT = 600;
 public static void main(String [] args){
  Test t =new Test();
  t.lanchFrame();
 }
 private void lanchFrame() {
  this.setLocation(400,300);//設置窗口的位置(以屏幕的左上角為基準)
  this.setSize(GAME_WIDTH,GAME_HEIGHT);//設置窗口的大小
  this.setTitle("畫圖測試");
  //匿名類實現關閉窗口
  this.addWindowListener(new WindowAdapter(){
   public void windowClosing(WindowEvent e) {
    System.exit(0);
   }
  });
  this.setResizable(false);//設置窗口不可以改變大小
  this.setBackground(Color.GREEN);//設置窗口的背景色為綠色
  
  setVisible(true);//設置窗口可見
 }
 
 public void paint(Graphics g){
  //在這里實例化正方形類,並調用它的draw方法
  Rec rec=new Rec(150,150,200,200);//在實例化的時候就可以指定正方形的大小
  rec.draw(g);//這里把paint方法中的畫筆g傳遞給正方形的draw方法
 }
}
//其他兩個圖形也一樣,畫圓用的是畫筆g的fillOval()方法
4.運行測試
在硬碟上建個文件夾,如E:\test\    在這個文件夾下把這三個文件都放進去
在dos下編譯測試:
javac Test.java
java Test
如果實在IDE中測試,那我就不多說了。
5.總結:
【1】先畫出窗口lanchFrame,並設置窗口的屬性,如大小、可見、不可以隨意改動大小、位置、可以通過關閉按鈕關閉窗口
【2.】在窗口中畫出想要畫的圖形,lanchFrame自動調用paint方法,在paint方法中調用具體圖形的draw方法。
Ⅱ 用Java實現畫圖板功能的程序,請問如何編寫一個繪制三角形的程序段
class Triangle extends drawings//空心三角形類 
{ 
void draw(Graphics2D g2d) 
{g2d.setPaint(new Color(R,G,B)); 
g2d.setStroke(new BasicStroke(stroke, 
BasicStroke.CAP_ROUND,BasicStroke.JOIN_BEVEL)); 
g2d.drawLine((int)((x1+x2)/2),Math.min(y1,y2),Math.max(x1,x2),Math.max(y1,y2)); 
g2d.drawLine(Math.max(x1,x2),Math.max(y1,y2),Math.min(x1,x2),Math.max(y1,y2));
g2d.drawLine(Math.min(x1,x2),Math.max(y1,y2),(int)((x1+x2)/2),Math.min(y1,y2));
} 
} 
以上是通過繪制三條直線作為三角形的三條邊來繪制三角形.
class fillTriangle extends drawings//實心三角形 
{ 
void draw(Graphics2D g2d) 
{g2d.setPaint(new Color(R,G,B)); 
g2d.setStroke(new BasicStroke(stroke)); 
int mx=(int)((x1+x2)/2);
int[] x={mx,Math.max(x1,x2),Math.min(x1,x2)};
int[] y={Math.min(y1,y2),Math.max(y1,y2),Math.max(y1,y2)};
g2d.fillPolygon(x,y,3);
} 
}
以上是用填充多邊形的方式填充一個三角形,如果把最後的:g2d.fillPolygon(x,y,3)改為g2d.drawPolygon(x,y,3); 則是以繪制多邊形的方式繪制空心三角形.
這里說明一下:因為(x1,y1,x2,y2)只能確定一個矩形區域,即滑鼠拉動的起點和終點確定的矩形區域所以可以有多種方式確定三角形的三個頂點,我這個用的三個頂點是:
點1( (x1+x2)/2, min(y) ) 點2( max(x),max(y) ) 點3( min(x),max(y) )
你的補充內容太多了,沒心情看啊,太累了
Ⅲ Java畫圖
看來你從未動過手解決未知問題,只會做練習?
這里已經提示了怎麼做,你只需要先了解基本的Swing中的JLabel/JFrame怎麼用,然後自己自己做一個EllipseComponent覆蓋它的paintComponent(Graphicsg)方法,使用一個像Eclipse這樣的開發工具IDE,在g後面打個點就有提示這個Graphics有什麼方法可用,裡面就有2D繪圖的方法。
importjava.awt.Color;
importjava.awt.Dimension;
importjava.awt.EventQueue;
importjava.awt.Graphics;
importjava.awt.Rectangle;
importjava.awt.event.ComponentAdapter;
importjava.awt.event.ComponentEvent;
importjavax.swing.JFrame;
importjavax.swing.JPanel;
importjavax.swing.UIManager;
{
	=5929654695935454925L;
	publicstaticvoidmain(String[]args){
		try{
			UIManager.setLookAndFeel(UIManager
					.());
		}catch(Exceptione){
			e.printStackTrace();
		}
		EventQueue.invokeLater(newRunnable(){
			publicvoidrun(){
				EllipseViewerapp=newEllipseViewer();
			}
		});
	}
	privateJPanelpanel;
	publicEllipseViewer(){
		add(getPanel());
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		pack();
		setVisible(true);
		addComponentListener(newComponentAdapter(){
			@Override
			publicvoidcomponentResized(ComponentEvente){
				System.out.println("WindowResized:Frame");
			}
		});
	}
	publicJPanelgetPanel(){
		if(panel==null){
			panel=newEllipseComponent();
			panel.setPreferredSize(newDimension(300,200));
			panel.setBackground(Color.RED);
		}
		returnpanel;
	}
	{
		=-1744557274793554529L;
		protectedvoidpaintComponent(Graphicsg){
			System.out.println("Paintcomponent");
			RectangleclientArea=this.getBounds();
			intheight=clientArea.height-1;
			intwidth=clientArea.width-1;
			//setforegroundcolor
			g.setColor(Color.BLACK);
			//drawcycle/ellipse
			g.drawOval(0,0,width,height);
			//setforegroundcolor
			g.setColor(Color.ORANGE);
			//fillit,wegive1pixelaslinewidth.
			g.fillOval(1,1,width-2,height-2);
		}
	}
}
Ⅳ 求java繪圖程序源代碼
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class MyTestGeneric{
  public static void main(String args[]) {
    new MyFrame99("drawing...");
  }
}
class MyFrame99 extends Frame {
  ArrayList<Point> points = null;
  MyFrame99(String s) {
    super(s);
    points = new ArrayList<Point>(); 
    setLayout(null);
    setBounds(300,300,400,300); 
    this.setBackground(new Color(204,204,255));
    setVisible(true);
    this.addMouseListener(new Monitor());
 }
 
 public void paint(Graphics g) {
    Iterator<Point> i = points.iterator();
    while(i.hasNext()){
      Point p = i.next();
      g.setColor(Color.BLUE);
      g.fillOval(p.x,p.y,10,10);
    }
  }
  
  public void addPoint(Point p){
    points.add(p);
  }
}
class Monitor extends MouseAdapter {
  public void mousePressed(MouseEvent e) {
    MyFrame99 f = (MyFrame99)e.getSource();
    f.addPoint(new Point(e.getX(),e.getY()));
    f.repaint();
  }
}
這個應該是你要的了,
Ⅳ Java繪圖機制是什麼樣的
JAVA的繪圖功能非常豐富,繪圖包括字體、顏色、圖形,以下我們將分技術專題來講。
一、關於JAVA的繪圖機制。
JAVA中的任何一個圖形組件,小到文本框、標簽,大到一個FRAME,一個DIALOG,都有一個專門負責顯示其界面的函數,這個函數名稱是固定的:paint,它的原型為: public void paint(Graphics g) { …… } 每當組件大小、位置、組件內容發生變化時,該函數即負責生成新的圖形界面顯示。由於該函數可以被子類繼承,因此,繼承的子類有能力修改該函數。如果子類中沒有出現該函數,則表示其行為完全繼承自父類。則不管是組件中是否添加了新的內容,是否發生了大小的改變,是否發生了位移,父類都要有一個專門的線程,來負責描繪變化以後的組件界面。 paint函數由父類自動維護,並且如果子類一旦重載該函數,必須自己去維護所有的界面顯示。
二、設置畫筆顏色
1、顏色常識
任何顏色都是三原色組成(RGB),JAVA中支持224位彩色,即紅綠藍色分量可取值介於0..255之間。下面首先學習一個JAVA中的類Color Color中的常量:
public final static Color black=new Color(0,0,0);
public final static Color blue=new Color(0,0,255);
…..
Color的構造函數:
public Color(int r,int g,int b);
使用舉例:如果想構造一個灰色對象,則用下面的句子:
Color gray=new Color(205,205,205);
2、設置畫筆顏色語法
g.setColor(color); //color是一個Color對象
每修改一次顏色它影響的就是下面所有的繪圖語句,一直影響到再次碰到setColor函數才以新的顏色代替。
3、使用JColorChooser組件選擇顏色 JAVA中有一個已經定義好的選色器,通過簡單的語法我們就可以將該窗口調出來,從其中選擇自己喜歡的顏色。下面的這個例子就是通過顏色選取器選取顏色,並將選擇到的顏色做為窗體的背景色。
(1)JColorChooser簡介 JColorChooser組件的showDialog()方法讓用戶從彈出的窗口中選擇一個顏色,並傳給Color對象。其調用語法如下: color=JColorChooser.showDialog(this,」選色」,color); 第一個參數指定調用選色器的父窗體,第二個參數指定選色器窗口標題,最後一個為接收顏色的顏色對象。
4、如何將一個圖形(以文件存在,如JPG或者GIF)畫到窗體的畫布中其實放置圖形到畫板中實際就是調用了畫板的drawImage函數。其大致思路如下:首先獲取一個ImageIcon對象,這個對象將會從指定的文件中讀取相關圖象信息,它支持GIF和JPG、BMP等基本圖象格式。語法如下:
ImageIcon icon=new ImageIcon(GraExp5.class.getResource("1.gif"));
獲取到圖象的圖標以後,就可以從圖標中獲取到繪制到畫板上的實際需要的圖象:
Image img=icon.getImage();
有了這個圖象對象,我們就可以用畫板的drawImage函數畫圖了。
g.drawImage(img,0,0,null);
Ⅵ GUI畫圖板(繪圖板)設計,用Java編寫程序代碼!!謝謝!!
只有矩形有圓形能移動,其它實現起來麻煩點,辦法有的只是代碼太多。
畫圓弧改成了畫曲線,圓弧稍麻煩,當然方法是很簡單的,你可以自己思考一下。
雙擊13個顏色中的任意一個都會彈出顏色選擇器。
有保存與打開功能。擴展名請用 .jdr
基本滿足條件,細節可能不是很好,另,代碼比較亂,怕不好看懂咯,呼呼。
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.util.ArrayList;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
public class JDraw {
 public static void main(String[] args) {
  JFrame f=new JFrame();
  f.setDefaultCloseOperation(3);
  f.setSize(880,600);
  f.setLocationRelativeTo(null);
  f.getContentPane().add(M.c);
  f.getContentPane().add(M.m,"South");
  f.setVisible(true);
 }
}
class CVS extends Component implements ComponentListener,MouseListener,MouseMotionListener{
 public void componentHidden(ComponentEvent e) {}
 public void componentMoved(ComponentEvent e) {}
 public void componentResized(ComponentEvent e) {resized();}
 public void componentShown(ComponentEvent e) {}
 private void resized() {
  int w=this.getWidth();
  int h=this.getHeight();
  tbuff=new BufferedImage(w,h,3);
  makeBuff(w,h);
 }
 private void makeBuff(int w,int h) {
  Graphics g = tbuff.getGraphics();
  g.drawImage(buff,0,0,null);
  g.dispose();
  buff=new BufferedImage(w,h,3);
  g=buff.getGraphics();
  g.drawImage(tbuff,0,0,null);
  g.dispose();
 }
 
 BufferedImage buff,tbuff;
 CVS(){
  this.addComponentListener(this);
  this.addMouseListener(this);
  this.addMouseMotionListener(this);
  buff=new BufferedImage(1,1,3);
 }
 
 public void paint(Graphics gr){
  Graphics2D g = buff.createGraphics();
  g.setBackground(new Color(0xff000000,true));
  g.clearRect(0,0,getWidth(),getHeight());
  g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, 
    RenderingHints.VALUE_ANTIALIAS_ON);
  M.sa.drawAll(g);
  if(M.ts!=null)
   M.ts.draw(g);
  g.dispose();
  gr.drawImage(buff,0,0,this);
  gr.dispose();
 }
 public void mouseClicked(MouseEvent e) {}
 public void mouseEntered(MouseEvent e) {}
 public void mouseExited(MouseEvent e) {}
 public void mousePressed(MouseEvent e) {
  M.mp(e.getPoint());
 }
 public void mouseReleased(MouseEvent e) {
  M.mr(e.getPoint());
 }
 public void mouseDragged(MouseEvent e) {
  M.md(e.getPoint());
 }
 public void mouseMoved(MouseEvent e) {}
}
class Menu extends JComponent implements MouseListener,ActionListener{
 JComboBox sbox,method;
 CLabel[] cl;
 JCheckBox fillC,drawB;
 JRadioButton fc,bc;
 ButtonGroup bg;
 JButton clear,up,down,save,load;
 Menu(){
  this.setLayout(new FlowLayout());
  method=new JComboBox(new Object[]{"draw","move","erase",});
  add(method);
  sbox=new JComboBox(new Object[]{"Pt","Ln","Rect","Cir","Arc",});
  add(sbox);
  cl=new CLabel[13];
  for(int i=0; i<cl.length; i++){
   cl[i]=new CLabel();
   cl[i].addMouseListener(this);
   add(cl[i]);
  }
  fc=new JRadioButton("fc",true);
  bc=new JRadioButton("bc");
  bg=new ButtonGroup();
  bg.add(fc);bg.add(bc);
  add(fc);add(bc);
  fc.setOpaque(true);
  bc.setOpaque(true);
  fc.setBackground(Color.white);
  bc.setBackground(Color.blue);
  fillC=new JCheckBox("Fill",true);
  drawB=new JCheckBox("Draw",true);
  fillC.addActionListener(this);
  drawB.addActionListener(this);
  add(fillC);add(drawB);
  clear=new JButton("clear");
  clear.addActionListener(this);
  add(clear);
  up=new JButton("zUp");
  up.addActionListener(this);
  add(up);
  down=new JButton("zDown");
  down.addActionListener(this);
  add(down);
  save=new JButton("Save");
  save.addActionListener(this);
  add(save);
  load=new JButton("Load");
  load.addActionListener(this);
  add(load);
 }
 public void mouseClicked(MouseEvent e) {
  JLabel l=(JLabel)e.getSource();
  if(e.getClickCount()==2){
   Color sc=JColorChooser.showDialog(null, "Color chooser", l.getBackground());
   l.setBackground(sc);
   mousePressed(e);
  }
 }
 public void mouseEntered(MouseEvent e) {}
 public void mouseExited(MouseEvent e) {}
 public void mousePressed(MouseEvent e) {
  Color c=((JLabel)e.getSource()).getBackground();
  if(fc.isSelected())
   fc.setBackground(c);
  else if(bc.isSelected())
   bc.setBackground(c);
  M.cp();
 }
 public void mouseReleased(MouseEvent e) {}
 public void actionPerformed(ActionEvent e) {
  if(e.getSource()==clear)M.clear();
  else if(e.getSource()==up)M.up();
  else if(e.getSource()==down)M.down();
  else if(e.getSource()==save)M.save();
  else if(e.getSource()==load)M.load();
  else if(e.getSource()==fillC||e.getSource()==drawB)M.cp();
 }
}
class CLabel extends JLabel{
 static Color[] cs={Color.red,Color.orange,Color.yellow,Color.green,Color.cyan,
  Color.blue,Color.magenta,Color.magenta.brighter(),
  Color.white,Color.black,Color.gray,Color.LIGHT_GRAY,Color.DARK_GRAY,};
 static int i;
 CLabel(){
  this.setOpaque(true);
  this.setBackground(cs[i++]);
  this.setBorder(BorderFactory.createLineBorder(Color.black));
  this.setPreferredSize(new Dimension(10,20));
 }
}
class M{
 static JFileChooser jfc=new JFileChooser();
 static Menu m=new Menu();
 static CVS c=new CVS();
 static SA sa=new SA();
 static S ts=null,selected=null;
 static Color fc,bc;
 static void clear(){
  sa.ss.clear();
  c.repaint();
 }
 public static void cp() {
  System.out.println(selected);
  if(selected!=null){
   selected.fillColor=m.fc.getBackground();
   selected.borderColor=m.bc.getBackground();
   selected.fc=m.fillC.isSelected();
   selected.db=m.drawB.isSelected();
   c.repaint();
  }
 }
 public static void up() {
  if(selected!=null){
   sa.upZ(selected);
   c.repaint();
  }
 }
 public static void down(){
  if(selected!=null){
   sa.downZ(selected);
   c.repaint();
  }
 }
 static{
  jfc.setFileFilter(new FileNameExtensionFilter("JDraw file (*.jdraw,*.jdr)","jdr","jdraw"));
 }
 static void save(){
  int x=jfc.showSaveDialog(c);
  if(x==JFileChooser.APPROVE_OPTION){
   File f = jfc.getSelectedFile();
   try{
    ObjectOutputStream oos=new ObjectOutputStream(new FileOutputStream(f));
    oos.writeObject(sa);
    oos.flush();
    oos.close();
   }catch(Exception e){}
  }
 }
 static void load(){
  int x=jfc.showOpenDialog(c);
  if(x==JFileChooser.APPROVE_OPTION){
   File f = jfc.getSelectedFile();
   try{
    ObjectInputStream oos=new ObjectInputStream(new FileInputStream(f));
    Object r=oos.readObject();
    if(r!=null){
     sa=(SA)r;
     c.repaint();
    }
    oos.close();
   }catch(Exception e){e.printStackTrace();}
  }
 }
 static int mx,my,tx,ty,ox,oy;
 static int pc=0,pmax;
 static int sm;
 static boolean ne=true;
 static int mid;
 static void mp(Point p){
  mid=m.method.getSelectedIndex();
  if(mid==0){
   if(ne){
    mx=p.x;my=p.y;
    pc=0;
    sm=m.sbox.getSelectedIndex();
    pmax=sm==4?2:1;
    ne=false;
   }
   ++pc;
  }
  else if(mid==1){
   checkSel(p);
   mx=p.x;my=p.y;
  }
  else if(mid==2){
   checkSel(p);
   if(selected!=null){
    sa.ss.remove(selected);
    c.repaint();
   }
  }
 }
 private static void checkSel(Point p) {
  selected=null;
  for(int i=sa.ss.size();i>0; i--)
   if(sa.ss.get(i-1).shape.contains(p)){
    selected=sa.ss.get(i-1);break;
   }
  sa.select(selected);
  c.repaint();
 }
 static void mt(){
  Shape s=null;
  int cx,cy,cw,ch;
  switch(sm){
  case 0:
  case 2:
   cx=Math.min(mx,tx);
   cy=Math.min(my,ty);
   cw=Math.abs(mx-tx);
   ch=Math.abs(my-ty);
   if(sm==0)
    s=new Ellipse2D.Double(cx,cy,cw,ch);
   else
    s=new Rectangle(cx,cy,cw,ch);
   break;
  case 1:
   s=new Line2D.Float(mx,my,tx,ty);
   break;
  case 3:
   cw=Math.abs(mx-tx);
   ch=Math.abs(my-ty);
   int cd=(int)Math.sqrt(Math.pow(mx-tx,2)+Math.pow(my-ty,2))*2;
   cx=mx-cd/2;
   cy=my-cd/2;
   s=new Ellipse2D.Double(cx,cy,cd,cd);
   break;
  case 4:
   Path2D p=new Path2D.Double();
   p.moveTo(mx,my);
   if(pc==1){
    p.lineTo(tx, ty);
   }
   else{
    p.quadTo(ox,oy,tx,ty);
   }
   s=p;
   break;
  }
  ts=new S(s,m.fc.getBackground(),m.bc.getBackground(),m.fillC.isSelected(),m.drawB.isSelected(),null);
  c.repaint();
 }
 static void md(Point p){
  if(mid==0){
   if(!sa.ss.isEmpty()){
    sa.ss.get(sa.ss.size()-1).sel=false;
   }
   if(pc>1){
    ox=p.x;oy=p.y;
   }
   else{
    tx=p.x;ty=p.y;
   }
   mt();
  }
  else if(mid==1){
   if(selected!=null){
    moveTo(selected,p);
    c.repaint();
   }
  }
  else if(mid==2){
   checkSel(p);
   if(selected!=null){
    sa.ss.remove(selected);
    c.repaint();
   }
  }
 }
 static void moveTo(S s, Point p) {
  if(s.shape instanceof Rectangle){
   Rectangle r=(Rectangle)s.shape;
   r.setLocation(r.x+p.x-mx,r.y+p.y-my);
   mx=p.x;my=p.y;
  }
  else if(s.shape instanceof Ellipse2D){
   Ellipse2D e=(Ellipse2D)s.shape;
   e.setFrame(e.getX()+p.x-mx,e.getY()+p.y-my,e.getWidth(),e.getHeight());
   mx=p.x;my=p.y;
  }
 }
 static void mr(Point p) {
  if(pc==pmax){
   pc=0;
   ne=true;
   sa.add(ts);
   selected=ts;
   ts=null;
  }
 }
}
class S implements Serializable{
 boolean fc,db,sel=true;
 Shape shape;
 Color fillColor,borderColor;
 Stroke stroke;
 static Stroke bstroke=new MyBasicStroke();
 static Stroke selectStroke=new BasicStroke(1,BasicStroke.CAP_BUTT,BasicStroke.JOIN_MITER,1,new float[]{5,2},1);
 S(Shape s,Color c,Color b,boolean f,boolean d,Stroke k){
  this.shape=s;this.fillColor=c;this.borderColor=b;this.fc=f;this.db=d;this.stroke=k==null?bstroke:k;
 }
 void draw(Graphics2D g){
  if(fc){
   g.setColor(fillColor);
   g.fill(shape);
  }
  if(db){
   g.setColor(borderColor);
   g.setStroke(stroke);
   g.draw(shape);
  }
  if(sel){
   g.setColor(Color.green);
   g.setStroke(selectStroke);
   g.draw(shape.getBounds());
  }
 }
}
class MyBasicStroke extends BasicStroke implements Serializable{}
class SA implements Serializable{
 ArrayList<S> ss=new ArrayList<S>();
 void add(S s){
  if(s!=null){
   for(S sx:ss)
    sx.sel=false;
   ss.add(s);
  }
 }
 S remove(int i){
  return ss.remove(i);
 }
 void remove(S s){
  ss.remove(s);
 }
 void upZ(S s){
  indexZ(s,1);
 }
 void downZ(S s){
  indexZ(s,-1);
 }
 void indexZ(S s, int i) {
  int si=ss.indexOf(s);
  if(si+i<0||si+i>ss.size()-1)return;
  swap(s,ss.get(si+i));
 }
 void swap(S a,S b){
  int ai=ss.indexOf(a);
  int bi=ss.indexOf(b);
  ss.set(ai,b);
  ss.set(bi,a);
 }
 void select(S s){
  for(S x:ss)
   x.sel=false;
  if(s!=null)
   s.sel=true;
 }
 void drawAll(Graphics2D g){
  for(S s:ss)
   s.draw(g);
 }
}
Ⅶ java程序設計課程簡介
一 JAVA程序設計課程講什麼內容
 
  《Java程序設計》課程是使用Java語言進行應用程序設計的課程。課程的主要目標有三:一、掌握Java語言的語法,能夠較為深入理解Java語言機制,掌握Java語言面向對象的特點。 二、掌握JavaSE中基本的API,掌握在 *** 、線程、輸入輸出、文本處理、圖形用戶界面、網路等方面的應用。三、能夠編寫有一定規模的應用程序,養成良好的編程習慣。 本課程要對Java語言的一些機制會詳細講解,所以具有系統性。本課程還注重實踐性,要講Java語言在文本、文件、窗體界面、圖形、資料庫、多線程、並行編程方面的應用。還會講到編好代碼的經驗與技巧,包括面向對象的思想、軟體開發工具的使用等。 在教學中,採用教師講授、學生自測、學生討論、編程實踐相結合的方法。 
 
 二 千鋒JAVA課程介紹
 
  Java語言的發展及相關技術的介虛運紹,Java技術和平台在網路計算及電子商務中的應用介紹;Java語言的基礎知識:Java語言的主要特點,設計思想,Java虛擬機,垃圾回收機制,安全性的保證機制;Java語言的基本語法規范,包括標識符、關鍵字、數據類型、表達式和流控制,程序基本結構;?面向對象技術的基本特點,Java語言的面向對象特性,類和對象的概念,封裝性、繼承性、多態性,Java語言的特殊屬性;Java程序的例外處理機制和方法;
  Java語言的輸入/輸出處理機制和方法,常用的輸入/輸出方法,輸入/輸出處鍵茄理的應用;
  Java語言的圖形用戶界面設計:AWT界面設計的基本方法,常用的組件類庫,圖形用戶界面的事件處理模型和方法,JFC介紹,Swing圖形界面設計;Java Applet程序設計,Applet程序的特點,運行機制,與瀏覽器的集成,安全機制的使用;
  多線程程序設計,進程和線程的聯系和區別,多線程程序設計的一般方法,線程的生命周期,線程狀態的控制,多線程的互斥和同步;Java語言的網路編程技術和應用,Socket程序設計,Client/Server程序設計;Java的Servlet和jsP(Java?Server?Page)技術;
  JavaBeans和RMI。 
三 java程序設計的介紹
 
 《java程序設計》是2006年清華大學出版社 北京交通大學出版社出版的圖書,作者是吳萍、蒲鵬、朱麗娟。主要講述了本書通過對Java編程語言的全面介紹,引導讀者快速地掌握Java編程語言的核心內容並學會靈活運用所學的語言知識及面向對象的編程思想。全書共分9章,內容包括Java語言概述、面向對象編程初步、Java的基本語法、類庫與數組、面向對象編程深入、Applet程序、圖形用戶界面編程、異常處理和輸入輸出及多線程編程。
 
 四 java程序設計的內容簡介
 
 本書採用任務驅動教學模式,通過任務的實施,使讀者在讀程序、版學知識、寫程序的過程中,權逐漸掌握面向對象的Java程序設計思想和技能。本書共分12個單元,主要包括Java程序設計過程、基本語法規則、面向對象技術、數組與字元串、異常處理、GUI編程、輸入/輸出處理、多線程編程以及基礎網路編程等內容。
  本書適合作為高等職業院校計算機相關專業「Java程序設計」或者「面向對象程序設計」課程的教材,也可作為相關技術人員學習Java的參考用書。
 
 五 java程序設計的內容簡介
 
 本書是依據本科和高職高專院校的培養目標及基本要求,結合作者多專年來的教學經驗和工程實踐屬基礎,為實施教學改革,使計算機教學進一步面向軟體編程實踐而編寫的一本教材。包括的主要內容有:面向對象程序設計語言,Java程序設計入門,程序控制流程,JAVA的方法、類與對象、繼承與派生,JAVA的異常處理,JAVA包的組成和使用,設計APPLET程序、JAVA的多線程、I/O流、網路程序設計等。每章後都配有上機實戰和理論鞏固題,實現教與學的統一。
  本書語言通俗易懂,內容豐富翔實,突出了以實用為中心的特點。使用本書進行學習,可幫助讀者用最少的時間掌握最多的知識及工作經驗與技巧,是本科和高職高專院校理想的教學教材,同時也可作為軟體和信息技術工程人員的參考差亮梁用書。
 
 六 《JAVA程序設計》課程設計
 
  1 package study.part02;
   2 import java.util.Calendar;
   3 import java.awt.*;
   4 import javax.swing.*;
   5 import java.awt.event.*;
   6 import java.lang.Thread;
   7 public class Clock extends JFrame implements ComponentListener,
   8 ItemListener,Runnable{
   9 Thread timer;
   10 private JComboBox bobox_color;
   11 public void start(){
   12 if(timer==null)
   13 timer=new Thread(this,"ShowTime");
   14 timer.start();
   15 }
   16 public void run(){
   17 while(true){
   18 try{
   19 timer.sleep(1000);
   20 }catch(InterruptedException e){}
   21 repaint();
   22 }
   23 }
   24 public void stop(){
   25 timer.stop();
   26 }
   27 public Clock(){
   28 super("Clock");
   29 this.setSize(600,600);
   30 this.setDefaultCloseOperation(EXIT_ON_CLOSE);
   31 this.setLayout(new FlowLayout());
   32 
   33 this.setVisible(true);
   34 }
   35 public void paint(Graphics g){
   36 Calendar cal=Calendar.getInstance();
   37 int year=cal.get(Calendar.YEAR);
   38 int month=cal.get(Calendar.MONTH);
   39 int day=cal.get(Calendar.DATE);
   40 int hour=cal.get(Calendar.HOUR);
   41 int minute=cal.get(Calendar.MINUTE);
   42 int second=cal.get(Calendar.SECOND);
   43 int a,b;
   44 a=this.getWidth()/2;
   45 for(int i=1;i<=360;i++){
   46 double angle=i*Math.PI/180;
   47 double radius=a-50;
   48 int x=(int)Math.round(radius*Math.sin(angle));
   49 int y=(int)Math.round(radius*Math.cos(angle));
   50 if(i%30==0){
   51 int j=i/30;
   52 String str=String.valueOf(j);
   53 g.setColor(Color.black);
   54 // g.fillOval(a+x,a+y,1,1);
   55 g.drawString(str,a+x,a-y);
   56 }
   57 double radh=a-200;
   58 angle=hour*Math.PI/30;
   59 int xh=(int)Math.round(radh*Math.sin(angle));
   60 int yh=(int)Math.round(radh*Math.cos(angle));
   61 g.setColor(Color.red);
   62 g.drawLine(a,a,a+xh,a-yh);
   63 double radm=a-150;
   64 angle=minute*Math.PI/30;
   65 int xm=(int)Math.round(radm*Math.sin(angle));
   66 int ym=(int)Math.round(radm*Math.cos(angle));
   67 g.setColor(Color.blue);
   68 g.drawLine(a,a,a+xm,a-ym);
   69 double rads=a-100;
   70 angle=second*Math.PI/30;
   71 int xs=(int)Math.round(rads*Math.sin(angle));
   72 int ys=(int)Math.round(rads*Math.cos(angle));
   73 g.setColor(Color.yellow);
   74 g.drawLine(a,a,a+xs,a-ys);
   75 //g.drawString(cal.get(Calendar.HOUR)+":"+cal.get(Calendar.
   76 // MINUTE)+":"+cal.get(Calendar.SECOND));
   77 }
   78 }
   79 public void itemStateChanged(ItemEvent e){
   80 repaint();
   81 }
   82 public void ponentResized(ComponentEvent e){
   83 repaint();
   84 }
   85 public void ponentMoved(ComponentEvent e){}
   86 public void ponentHidden(ComponentEvent e){}
   87 public void ponentShown(ComponentEvent e){}
   88 
   89 public static void main(String[] args){
   90 Clock show=new Clock();
   91 show.start();
   92 }
   93 } 
 
 七 java程序設計的內容簡介
 
 本書講解了Java語言的基本知識及程序設計的基本方法,使讀者掌握面向對象程序設計的基本概念,從而具有利用Java語言進行程序設計的能力,為將來從事軟體開發,特別是Web應用系統開發打下良好基礎。全書共分10章,從內容上大致分為三個部分:第一部分為第1章~第3章,介紹Java程序設計的基礎知識,包括Java語言概述、Java語言基礎以及演算法與程序控制結構。第二部分為第4章~第6章,介紹Java面向對象程序設計的基本方法與技術,這是Java的核心與特色內容,包括類與對象、封裝、繼承與多態以及異常處理與輸入/輸出。第三部分為第7章~第10章,介紹Java的實際應用,包括多線程、網路程序設計、資料庫應用以及圖形用戶界面開發技術。
  本書內容講解詳細,程序代碼均經過調試,案例實用。
  本書適合作為高等院校計算機程序設計課程的教材,也可作為具有一定程序設計基礎和經驗的讀者的參考用書。
 
 八 java程序設計的內容簡介
 
 本書共分四篇15章來闡述Java語言。其中,第一篇介紹了Java的基礎知識,包括Java的歷史和特徵、Java的開發環境和工具、Java語言的基本語法知識;第二篇介紹了面向對象編程的思想和相關概念,Java中類的定義和對象的創建,Java繼承、介面和包,數組與字元串,異常處理及JDK類庫的應用;第三篇介紹了Java的AWT和Swing圖形包的使用以及Java的多線程編程支持;第四篇通過一些簡單的例子介紹了Java在網路和資料庫方面的編程。本書的篇章內容採用循序漸進、由簡到繁、由易到難的學習思維特徵進行編排,書中例子以人們學習與認知過程為基礎,以實際開發的需求為目標。書中內容通俗易懂,豐富易學,每章都附有習題,幫助讀者及時了解與掌握相應章節的知識點並將其應用到實踐中。
  本書適合作為高職院校各專業學習Java語言的基礎教材,也可作為相關工程技術人員和科技工作者的參考用書。
 
 九 JAVA程序設計課程主講老師是誰
 
  JAVA程序設計主講老師是北京大學信息科學技術學院教師,在程序設計方面有多年的項目開發經驗和教學經驗,任教育部計算機教指委分委專家組成員。出版的教材包括《Java程序設計》(曾獲第六屆全國高校出版社優秀暢銷書獎)、《C#程序設計教程》、《VB程序設計》、《Visual C++.NET程序設計》等。在北京大學開設多門程序設計課程,課程內容以系統知識與實踐應用相結合,注重培養對知識體系的深入理解,在與實際工作生活相結合的應用實踐中分析問題、解決問題的能力。 
 
 十 Java程序設計與Web應用程序設計哪門課簡單
 
  java程序設計主要講解java的基礎知識,它是一種語言性的課程。
  
  web應用設計則是一種方向性的課程,這個web的設計你可以使用asp,也可以使用jsp,如果是通過jsp來進行web開發的話,需要java的知識作為基礎。
  
  因此,如果你有asp的相關知識的話,可以不學習java直接學習web應用程序設計,如果沒有的話,建議你先學習java程序設計,然後再學習web應用程序設計。