4 1 import javax swing import javax swing
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-1.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-2.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-3.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-4.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-5.jpg)
![範例4 -1 import javax. swing. *; //引用套件 import javax. swing. event. *; import java. 範例4 -1 import javax. swing. *; //引用套件 import javax. swing. event. *; import java.](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-6.jpg)
![cp. add(lb. Left); //將元件加入面版 cp. add(lb. Center); cp. add(lb. Right); cp. add(lb. Leading. Top); cp. add(lb. Left); //將元件加入面版 cp. add(lb. Center); cp. add(lb. Right); cp. add(lb. Leading. Top);](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-7.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-8.jpg)
![欲運用某字型時,可以建立描述這個字型的Font物件,以下為Font類別的建構子。 public Font(String name, int style, int size) 加背景顏色—黃 lb. Green. set. Opaque(true); lb. 欲運用某字型時,可以建立描述這個字型的Font物件,以下為Font類別的建構子。 public Font(String name, int style, int size) 加背景顏色—黃 lb. Green. set. Opaque(true); lb.](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-9.jpg)
![範例4 -2 import javax. swing. *; //引用套件 import java. awt. *; public class Color. 範例4 -2 import javax. swing. *; //引用套件 import java. awt. *; public class Color.](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-10.jpg)
![Container cp = get. Content. Pane(); //取得內容面版 cp. set. Layout(new Grid. Layout(2, 2, 10)); Container cp = get. Content. Pane(); //取得內容面版 cp. set. Layout(new Grid. Layout(2, 2, 10));](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-11.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-12.jpg)
![範例 4 -3 import javax. swing. *; //引用套件 import java. awt. *; public class 範例 4 -3 import javax. swing. *; //引用套件 import java. awt. *; public class](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-13.jpg)
![class Bitc. Icon implements Icon { //宣告實作Icon介面的圖示類別 private int width, height; public Bitc. Icon(int class Bitc. Icon implements Icon { //宣告實作Icon介面的圖示類別 private int width, height; public Bitc. Icon(int](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-14.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-15.jpg)
![import javax. swing. *; //引用套件 import javax. swing. event. *; Ex 4 -4 import import javax. swing. *; //引用套件 import javax. swing. event. *; Ex 4 -4 import](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-16.jpg)
![JLabel lb. Bitc. Right = new JLabel("文字置於圖示右方、靠上", new Image. Icon(". \Icon\Bitc. gif"), Swing. Constants. JLabel lb. Bitc. Right = new JLabel("文字置於圖示右方、靠上", new Image. Icon(". \Icon\Bitc. gif"), Swing. Constants.](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-17.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-18.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-19.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-20.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-21.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-22.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-23.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-24.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-25.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-26.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-27.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-28.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-29.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-30.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-31.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-32.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-33.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-34.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-35.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-36.jpg)
![Practice 4. 2 課本 10 -43 (習題 10. 6 第 17 題) 假設有一個 Car Practice 4. 2 課本 10 -43 (習題 10. 6 第 17 題) 假設有一個 Car](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-37.jpg)
- Slides: 37
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-1.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-2.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-3.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-4.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-5.jpg)
![範例4 1 import javax swing 引用套件 import javax swing event import java 範例4 -1 import javax. swing. *; //引用套件 import javax. swing. event. *; import java.](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-6.jpg)
範例4 -1 import javax. swing. *; //引用套件 import javax. swing. event. *; import java. awt. event. *; public class Label. EX extends JFrame { Label. EX() { JLabel lb. Right = new JLabel("靠右", JLabel. RIGHT); JLabel lb. Left = new JLabel("靠左", JLabel. LEFT); JLabel lb. Center = new JLabel("置中", JLabel. CENTER); JLabel lb. Leading. Top = new JLabel("靠前緣", JLabel. LEADING); lb. Leading. Top. set. Vertical. Alignment(Swing. Constants. TOP); //設定垂直方向靠上對齊 JLabel lb. Trailing. Bottom = new JLabel("靠後緣", JLabel. TRAILING); lb. Trailing. Bottom. set. Vertical. Alignment(Swing. Constants. BOTTOM); //設定垂直方向靠下對齊 Container cp = get. Content. Pane(); //取得內容面版 cp. set. Layout(new Grid. Layout(2, 3, 10)); //取得佈局管理員
![cp addlb Left 將元件加入面版 cp addlb Center cp addlb Right cp addlb Leading Top cp. add(lb. Left); //將元件加入面版 cp. add(lb. Center); cp. add(lb. Right); cp. add(lb. Leading. Top);](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-7.jpg)
cp. add(lb. Left); //將元件加入面版 cp. add(lb. Center); cp. add(lb. Right); cp. add(lb. Leading. Top); cp. add(lb. Trailing. Bottom); set. Default. Close. Operation(JFrame. EXIT_ON_CLOSE); //設定關閉視窗將預設結束程式 set. Size(300, 250); //設定視窗的大小為 300 x 250 set. Visible(true); //顯示視窗框架 } public static void main(String args[]) { new Label. EX(); //宣告視窗框架物件 } }
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-8.jpg)
![欲運用某字型時可以建立描述這個字型的Font物件以下為Font類別的建構子 public FontString name int style int size 加背景顏色黃 lb Green set Opaquetrue lb 欲運用某字型時,可以建立描述這個字型的Font物件,以下為Font類別的建構子。 public Font(String name, int style, int size) 加背景顏色—黃 lb. Green. set. Opaque(true); lb.](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-9.jpg)
欲運用某字型時,可以建立描述這個字型的Font物件,以下為Font類別的建構子。 public Font(String name, int style, int size) 加背景顏色—黃 lb. Green. set. Opaque(true); lb. Green. set. Background(Color. yellow);
![範例4 2 import javax swing 引用套件 import java awt public class Color 範例4 -2 import javax. swing. *; //引用套件 import java. awt. *; public class Color.](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-10.jpg)
範例4 -2 import javax. swing. *; //引用套件 import java. awt. *; public class Color. Font. EX extends JFrame { Color. Font. EX() { JLabel lb. Red = new JLabel("紅"); lb. Red. set. Foreground(Color. RED); //以Color類別的常數取得代表紅色的Color物件, //並設定為標籤的前景顏色 JLabel lb. Green = new JLabel("綠"); lb. Green. set. Foreground(new Color(0, 255, 0)); //以整數的RGB值宣告代表綠色的Color物件, //並設定為標籤的前景顏色 JLabel lb. Blue = new JLabel("藍"); lb. Blue. set. Foreground(new Color(0. 0 f, 1. 0 f)); //以浮點數的RGB值宣告代表藍色的Colord物件, //並設定為標籤的前景顏色 JLabel lb. Times. Bold 15 = new JLabel("Times New Roman"); lb. Times. Bold 15. set. Font( new Font("Times New Roman", Font. BOLD, 20)); //設定標籤內文字使用的字型
![Container cp get Content Pane 取得內容面版 cp set Layoutnew Grid Layout2 2 10 Container cp = get. Content. Pane(); //取得內容面版 cp. set. Layout(new Grid. Layout(2, 2, 10));](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-11.jpg)
Container cp = get. Content. Pane(); //取得內容面版 cp. set. Layout(new Grid. Layout(2, 2, 10)); //取得佈局管理員 cp. add(lb. Red); //將元件加入面版 cp. add(lb. Green); cp. add(lb. Blue); cp. add(lb. Times. Bold 15); set. Default. Close. Operation(JFrame. EXIT_ON_CLOSE); //設定關閉視窗將預設結束程式 pack(); //設定以適當大小顯示 set. Visible(true); //顯示視窗框架 } public static void main(String args[]) { new Color. Font. EX(); //宣告視窗框架物件 } }
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-12.jpg)
![範例 4 3 import javax swing 引用套件 import java awt public class 範例 4 -3 import javax. swing. *; //引用套件 import java. awt. *; public class](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-13.jpg)
範例 4 -3 import javax. swing. *; //引用套件 import java. awt. *; public class Icon. EX extends JFrame{ Icon. EX(){ JLabel lb. Icon = new JLabel(new Bitc. Icon(80, 80)); //以標籤顯示圖示 JLabel lb. Image. Icon = new JLabel(new Image. Icon(". \Icon\Bitc. gif")); //以圖檔建立顯示於標籤的圖示 Container cp = get. Content. Pane(); //取得內容面版 cp. set. Layout(new Grid. Layout(1, 2, 10)); //取得佈局管理員 cp. add(lb. Icon); //將元件加入面版 cp. add(lb. Image. Icon); set. Default. Close. Operation(JFrame. EXIT_ON_CLOSE); //設定關閉視窗將預設結束程式 pack(); //以適當大小顯示視窗 set. Visible(true); //顯示視窗框架 } public static void main(String args[]) { new Icon. EX(); //宣告視窗框架物件 } }
![class Bitc Icon implements Icon 宣告實作Icon介面的圖示類別 private int width height public Bitc Iconint class Bitc. Icon implements Icon { //宣告實作Icon介面的圖示類別 private int width, height; public Bitc. Icon(int](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-14.jpg)
class Bitc. Icon implements Icon { //宣告實作Icon介面的圖示類別 private int width, height; public Bitc. Icon(int w, int h){ //建構子 width = w; height = h; } //繪製圖示 public void paint. Icon(Component c, Graphics g, int x, int y){ g. draw. Rect(5, 5, 70); //繪製矩形 g. draw. String("位元文化", 15, 45); //繪製文字 } public int get. Icon. Width(){ //取得圖示寬度 return width; } public int get. Icon. Height(){ //取得圖示高度 return height; } }
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-15.jpg)
![import javax swing 引用套件 import javax swing event Ex 4 4 import import javax. swing. *; //引用套件 import javax. swing. event. *; Ex 4 -4 import](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-16.jpg)
import javax. swing. *; //引用套件 import javax. swing. event. *; Ex 4 -4 import java. awt. *; import java. awt. event. *; public class Label. Icon. EX extends JFrame{ Label. Icon. EX(){ JLabel lb. Bitc. Center = new JLabel("文字置於圖示中央", new Image. Icon(". \Icon\Bitc. gif"), Swing. Constants. CENTER); //同時顯示文字與圖示的標籤, 圖示置中 lb. Bitc. Center. set. Horizontal. Text. Position(Swing. Constants. CENTER); //設定文字的水平方向相對於圖示採置中對齊 JLabel lb. Bitc. Top = new JLabel("文字置於圖示中央、靠上", new Image. Icon(". \Icon\Bitc. gif"), Swing. Constants. CENTER); //同時顯示文字與圖示的標籤, 圖示置中 lb. Bitc. Top. set. Horizontal. Text. Position(Swing. Constants. CENTER); //設定文字的水平方向相對於圖示採置中對齊 lb. Bitc. Top. set. Vertical. Text. Position(Swing. Constants. TOP); //設定文字的垂直方向相對於圖示採置上對齊 JLabel lb. Bitc. Bottom = new JLabel("文字置於圖示中央、靠下", new Image. Icon(". \Icon\Bitc. gif"), Swing. Constants. CENTER); //同時顯示文字與圖示的標籤, 圖示置中 lb. Bitc. Bottom. set. Horizontal. Text. Position(Swing. Constants. CENTER); //設定文字的水平方向相對於圖示採置中對齊 lb. Bitc. Bottom. set. Vertical. Text. Position(Swing. Constants. BOTTOM); //設定文字的垂直方向相對於圖示採置下對齊 JLabel lb. Bitc. Left = new JLabel("文字置於圖示左方、靠下", new Image. Icon(". \Icon\Bitc. gif"), Swing. Constants. CENTER); //同時顯示文字與圖示的標籤, 圖示置中 lb. Bitc. Left. set. Horizontal. Text. Position(Swing. Constants. LEFT); //設定文字的水平方向相對於圖示採置左對齊 lb. Bitc. Left. set. Vertical. Text. Position(Swing. Constants. BOTTOM); //設定文字的垂直方向相對於圖示採置下對齊
![JLabel lb Bitc Right new JLabel文字置於圖示右方靠上 new Image Icon IconBitc gif Swing Constants JLabel lb. Bitc. Right = new JLabel("文字置於圖示右方、靠上", new Image. Icon(". \Icon\Bitc. gif"), Swing. Constants.](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-17.jpg)
JLabel lb. Bitc. Right = new JLabel("文字置於圖示右方、靠上", new Image. Icon(". \Icon\Bitc. gif"), Swing. Constants. CENTER); //同時顯示文字與圖示的標籤, 圖示置中 lb. Bitc. Right. set. Horizontal. Text. Position(Swing. Constants. RIGHT); //設定文字的水平方向相對於圖示採置右對齊 lb. Bitc. Right. set. Vertical. Text. Position(Swing. Constants. TOP); //設定文字的水平方向相對於圖示採置上對齊 Container cp = get. Content. Pane(); //取得內容面版 cp. set. Layout(new Grid. Layout(2, 3, 10)); //取得佈局管理員 cp. add(lb. Bitc. Center); //將元件加入面版 cp. add(lb. Bitc. Top); cp. add(lb. Bitc. Bottom); cp. add(lb. Bitc. Left); cp. add(lb. Bitc. Right); set. Default. Close. Operation(JFrame. EXIT_ON_CLOSE); //設定關閉視窗將預設結束程式 pack(); //以適當大小顯示視窗 set. Visible(true); //顯示視窗框架 } public static void main(String args[]) { new Label. Icon. EX(); //宣告視窗框架物件 } }
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-18.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-19.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-20.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-21.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-22.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-23.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-24.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-25.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-26.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-27.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-28.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-29.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-30.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-31.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-32.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-33.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-34.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-35.jpg)
![](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-36.jpg)
![Practice 4 2 課本 10 43 習題 10 6 第 17 題 假設有一個 Car Practice 4. 2 課本 10 -43 (習題 10. 6 第 17 題) 假設有一個 Car](https://slidetodoc.com/presentation_image_h/b9df6e83984ed6864cae6a8ddac0198f/image-37.jpg)
Practice 4. 2 課本 10 -43 (習題 10. 6 第 17 題) 假設有一個 Car 類別,表示車子的資訊 class Car { protected String owner; protected String id; final void show() { System. out. println("車主姓名: " + owner); System. out. println("車牌號碼: "+id); } 請依課本完成繼承之相關題目。
Java awt import
Import javax.swing
Java applet swing
Import java
Import javax.swing.* meaning in java
Java import javax
Import javax.swing.*
Extends jframe
Import javax.servlet
Import javax.jws.webservice;
Java import javax
Swing hello world
Java import java.util.*
Import numpy as np import matplotlib.pyplot as plt
Import java.awt.event
Jaxb remove namespace from root element
What is javax.servlet.servlet mcq
Whats soa mean
Reti di calcolatori corradi
Difference stateless and stateful
Full swing values
Java swing eclipse
Maximum symmetrical swing
Swing mvc example
Factor x^3-64
Swing components
Java gui
Electro swing history
Jazz prezentace
5 axial steps
Java swing layouts
Flap valve
The tool used for making internal threads is called as
Java swing layout
Each of the boxes shown is pulled for 10 m
Java swing draw text
The jazz style called swing flourished in america from
Java swings tutorial