欧美三级国产三级日韩三级_亚洲熟妇丰满大屁股熟妇_欧美亚洲成人一区二区三区_国产精品久久久久久模特

學(xué)習(xí)筆記二十四:繪圖技術(shù) - 新聞資訊 - 云南小程序開(kāi)發(fā)|云南軟件開(kāi)發(fā)|云南網(wǎng)站建設(shè)-昆明葵宇信息科技有限公司

159-8711-8523

云南網(wǎng)建設(shè)/小程序開(kāi)發(fā)/軟件開(kāi)發(fā)

知識(shí)

不管是網(wǎng)站,軟件還是小程序,都要直接或間接能為您產(chǎn)生價(jià)值,我們?cè)谧非笃湟曈X(jué)表現(xiàn)的同時(shí),更側(cè)重于功能的便捷,營(yíng)銷(xiāo)的便利,運(yùn)營(yíng)的高效,讓網(wǎng)站成為營(yíng)銷(xiāo)工具,讓軟件能切實(shí)提升企業(yè)內(nèi)部管理水平和效率。優(yōu)秀的程序?yàn)楹笃谏?jí)提供便捷的支持!

您當(dāng)前位置>首頁(yè) » 新聞資訊 » 技術(shù)分享 >

學(xué)習(xí)筆記二十四:繪圖技術(shù)

發(fā)表時(shí)間:2020-10-19

發(fā)布人:葵宇科技

瀏覽次數(shù):41


人的大年夜腦和肢體一樣,多用則靈,不消則廢?!┮陨?


本講內(nèi)容:畫(huà)圖技巧




一、畫(huà)圖道理
Component類(lèi)供給了兩個(gè)和畫(huà)圖相干最重要的辦法:
1、paint(Graphics g)繪制組件的外不雅。
2、repaint()刷新組件的不雅。
當(dāng)組件第一次在屏幕顯示的時(shí)刻,程度換輝動(dòng)調(diào)用paint()辦法來(lái)繪制組件
在以下情況paint()將會(huì)被調(diào)用:
1、窗口最小化,再最大年夜化。
[img]http://img.blog.csdn.net/20150106155110218?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGlndW9qaW4xMjMw/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center
3、repaint函數(shù)被調(diào)用。

2、窗口的大年夜小產(chǎn)生變更。
public class Text extends JFrame{
	MyPanel mb=null;
	
	public static void main(String[] args) {
		Text t=new Text();
	}
	
	public Text() {
		mb=new MyPanel();
		this.add(mb);
		
		//設(shè)置窗體屬性
		this.setTitle("畫(huà)圖—小勁");
		this.setIconImage((new ImageIcon("images\\2.gif")).getImage());
		this.setLocation(300, 300);
		this.setSize(400,400);
		this.setResizable(false);
		this.setVisible(true);
		this.setDefaultClo搜刮引擎優(yōu)化peration(JFrame.EXIT_ON_CLOSE);
	}
}

//定義一個(gè)MyPanel  用于畫(huà)圖和實(shí)現(xiàn)畫(huà)圖的區(qū)域
class MyPanel extends JPanel{
	//這個(gè)辦法是持續(xù)父類(lèi)JPanel的,Graphics 畫(huà)圖的重要類(lèi)   畫(huà)筆的意思
	public void paint(Graphics g) {
		super.paint(g);//一般要寫(xiě),調(diào)用父類(lèi)函數(shù)完成初始化義務(wù)
		g.drawOval(0, 0, 80, 90);//橢圓,左上角坐標(biāo)為(0,0)橫長(zhǎng)80豎長(zhǎng)90(<span style="font-family: Arial;">先畫(huà)坐標(biāo))</span>
		g.drawLine(100, 0, 200, 100);//線,始點(diǎn)坐標(biāo)(100,0)終點(diǎn)坐標(biāo)(200,100)
		g.drawRect(220, 20, 60, 80);//矩形,左上角坐標(biāo)為(220,20)橫長(zhǎng)60豎長(zhǎng)80
		g.draw3DRect(300, 20, 60, 80, true);//3d矩形
		g.setColor(Color.blue);//如不雅不設(shè)制揭捉色,默認(rèn)是黑色
		g.fillRect(10, 120, 60, 80);//填充色彩
		g.fill3DRect(10, 220, 60, 80, true);
		g.setColor(Color.red);//如不雅不設(shè)置會(huì)用膳綾擎的色彩
		g.fillOval(100, 120, 80, 80);
		
	}
}


二、畫(huà)圖片、字符串
public class Text extends JFrame{
	MyPanel mb=null;
	
	public static void main(String[] args) {
		Text t=new Text();
	}
	
	public Text() {
		mb=new MyPanel();
		this.add(mb);
		
		//設(shè)置窗體屬性
		this.setTitle("畫(huà)圖—小勁");
		this.setIconImage((new ImageIcon("images\\1.gif")).getImage());
		this.setLocation(300, 300);
		this.setSize(400,400);
		this.setResizable(false);
		this.setVisible(true);
		this.setDefaultClo搜刮引擎優(yōu)化peration(JFrame.EXIT_ON_CLOSE);
	}
}

class MyPanel extends JPanel{
	public void paint(Graphics g) {
		super.paint(g);
		//畫(huà)圖用到的圖片要拷貝在src目次下/表示當(dāng)前目次
		Image p=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/p1.jpg"));
		g.drawImage(p,30,20,300,250,this);//畫(huà)圖片
		g.setColor(Color.red);//設(shè)置畫(huà)筆的色彩
		g.setFont(new Font("漢文彩云",Font.BOLD,50));//畫(huà)字符串   BOLD,50粗體大年夜小50
		g.drawString("陽(yáng)西一中", 90, 330);
	}
}

[img]http://img.blog.csdn.net/20150106172243015?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGlndW9qaW4xMjMw/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center



三、綜合案例
public class Text extends JFrame{
	JPanel mb1;
	JButton an1,an2,an3,an4,an5,an6,an7,an8;
	MyPanel mb=null;
	
	public static void main(String[] args) {
		Text t=new Text();
	}
	
	public Text() {
		mb1 = new JPanel(new GridLayout(6,3,200,2));
		an1=new JButton("黑客技巧");
		an2=new JButton("軟件破解");
		an3=new JButton("編程大年夜牛");
		an4=new JButton("網(wǎng)頁(yè)設(shè)計(jì)");
		an5=new JButton("PHP技巧");
		an6=new JButton("C++技巧");
		an7=new JButton("Java技巧");
		an8=new JButton("linux技巧");
		mb1.add(an1); mb1.add(an2); mb1.add(an3); mb1.add(an4);
		mb1.add(an5); mb1.add(an6); mb1.add(an7); mb1.add(an8);
		
		mb=new MyPanel();
		
		this.add(mb1,BorderLayout.SOUTH);
		this.add(mb);
		
		//設(shè)置窗體屬性
		this.setTitle("技巧大年夜牛—小勁");
		this.setIconImage((new ImageIcon("images\\1.gif")).getImage());
		this.setLocation(300, 300);
		this.setSize(400,400);
		this.setResizable(false);
		this.setVisible(true);
		this.setDefaultClo搜刮引擎優(yōu)化peration(JFrame.EXIT_ON_CLOSE);
	}
}

class MyPanel extends JPanel{
	public void paint(Graphics g) {
		super.paint(g);
		Image p=Toolkit.getDefaultToolkit().getImage(Panel.class.getResource("/p2.jpg"));
		g.drawImage(p, 20, 30, 85, 100, this);
		g.drawString("我是蛋疼的法度榜樣猿", 130, 50);
		g.drawString("我是90's 后", 130, 70);
		g.drawString("我是黑闊", 130, 90);
		g.drawString("我習(xí)慣一小我孤單的感到", 130, 110);
	}
}

[img]http://img.blog.csdn.net/20150106174422470?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGlndW9qaW4xMjMw/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center


本講就到這里,Take your time and enjoy it



相關(guān)案例查看更多