tmp.dvi



Similar documents
public class MyFrame { private JPanel panel1; private JPanel panel2; private JPanel panel3; private JPanel panel4; private JLabel label1; private JTex

2 static final int DO NOTHING ON CLOSE static final int HIDE ON CLOSE static final int DISPOSE ON CLOSE static final int EXIT ON CLOSE void setvisible

text_12.dvi

ソフトウェア基礎演習 課題

Java言語 第1回

目 次 Java GUI 3 1 概要 クラス構成 ソースコード例 課題...7 i

Microsoft Word - Java4.DOC

text_13.dvi

awt の主要なクラスを下記に示す クラス Component Container Button Label Panel Frame 説明画面にユーザインターフェイス要素として表示し, ユーザとのやり取りを行うコンポーネントを表すすべてのコンポーネントのスーパークラスになる ほかのコンポーネントを含

Safari AppletViewer Web HTML Netscape Web Web 15-1 Applet Web Applet init Web paint Web start Web HTML stop destroy update init Web paint start Web up

Microsoft PowerPoint - swing2.ppt

5 p Point int Java p Point Point p; p = new Point(); Point instance, p Point int 2 Point Point p = new Point(); p.x = 1; p.y = 2;

public class Kadai _02 { public static void main(string[] args) { MyFrame frame = new MyFrame("Kadai _02"); (2) フレームのクラス名は MyFrame とし 以下

2

Java 2 - Lesson01

I 4 p.2 4 GUI java.awt.event.* import /* 1 */ import mouseclicked MouseListener implement /* 2 */ init addmouselistener(this) this /* 3 */ this mousec

I. (i) Foo public (A). javac Foo.java java Foo.class (C). javac Foo java Foo (ii)? (B). javac Foo.java java Foo (D). javac Foo java Foo.class (A). Jav

B 10 : N ip2003f10.tex B : 9/12/ :02 p.1/71

Object MenuComponent MenuBar MenuItem Menu CheckboxMenuItem

次の演習課題(1),(2)のプログラムを完成させよ

ガイダンス

......() JButton

ガイダンス

ガイダンス

6 p.1 6 Java GUI GUI paintcomponent GUI mouseclicked, keypressed, actionperformed mouseclicked paintcomponent thread, 1 GUI 6.0.2, mutlithread C

r14.dvi

GUIプログラムⅣ

Thread

アプレットⅢ

IE6 2 BMI chapter1 Java 6 chapter2 Java 7 chapter3 for if 8 chapter4 : BMI 9 chapter5 Java GUI 10 chapter6 11 chapter7 BMI 12 chap

ÿþ˜u#u·0¹0Æ0à0

最初に

Microsoft PowerPoint - swing3.ppt

PowerPoint Presentation

<4D F736F F F696E74202D AC C8899E D834F E >

vol.30.}...`.X...b.h

Microsoft PowerPoint - prog12.ppt

:30 12:00 I. I V II. III. IV. ( a d) V. VI : A ActionListener aa addactionlistener AE ActionEvent K KeyListener ak addkeyliste

Java 2 - Lesson01

r2.dvi

r8.dvi

55 7 Java C Java TCP/IP TCP/IP TCP TCP_RO.java import java.net.*; import java.io.*; public class TCP_RO { public static void main(string[] a

Java - Visual Editor

Prog1_12th

GUIプログラムⅤ

問1

ガイダンス

Java 2 - Lesson01

Java プログラミング講習会 第 2 回 芝浦工業大学工学部情報工学科杉本徹 2017 年 3 月 27 日 public class Person { String familyname; String firstname; int age; } public void print() { Sy

Java 2 - Lesson01

LMNtal LMNtal LMNtal JAVA JAVA JAVA LMNtal LMNtal LMNtal

自宅でJava言語の開発環境を作る方法

I. java.awt.rectangle java.lang.math random Java TM API java.awt Rectangle Rectangle (x,y)... public int x Rectangle X public int y Rectangle Y public

ガイダンス

2

Microsoft PowerPoint - prog13.ppt

Prog2_11th

Java言語 第1回

アジェンダ 1 グラフィカルなインタフェース GUI(Graphical User Interface) の基礎 2 Swing を利用する Swing の基礎知識 2

Prog1_12th

Local variable x y i paint public class Sample extends Applet { public void paint( Graphics gc ) { int x, y;... int i=10 ; while ( i < 100 ) {... i +=

r14.dvi

I. (i) Java? (A). 2Apples (B). Vitamin-C (C). Peach21 (D). Pine_Apple (ii) Java? (A). Java (B). Java (C). Java (D). JavaScript Java JavaScript Java (i


Microsoft PowerPoint - prog13.ppt

1 Java Java GUI , 2 2 jlabel1 jlabel2 jlabel3 jtextfield1 jtextfield2 jtextfield3 jbutton1 jtextfield1 jtextfield2 jtextfield3

Java演習(9) -- クラスとメソッド --

ALG ppt

I HTML HashMap (i) (ii) :.java import java.net.*; import java.io.*; import java.util.hashmap; public class SimpleStopWatch { public static voi

PowerPoint Presentation

Assignment_.java /////////////////////////////////////////////////////////////////////// // 課題 星の画像がマウスカーソルを追従するコードを作成しなさい 次 ///////////////////

untitled

上達Java解答.doc

Microsoft PowerPoint - OOP.pptx

< F2D E E6A7464>

10/31 Java AWTの基本構造(Frameクラスの継承) 演習課題資料

II Java :30 12:00 I. I IV II. III. IV. ( a d) V. : this==null, T == N A ActionListener C class D actionperformed G getsource I implements K

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

r3.dvi

Java演習(4) -- 変数と型 --

I. (i) Java? (A). Foo_Bar (B). G day (C). 999 (D). Golgo13 (ii)? (A). Java public (B). Java (C). Java JavaScript (D). Java C Java C (iii)? (A). Java (

< F2D834F838C A815B A CC>

< F2D B838A835882CC8CF68EAE2E6A7464>

やさしいJavaプログラミング -Great Ideas for Java Programming サンプルPDF

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperforme

4 p.2 4 GUI return; public void mousepressed(mouseevent e) { /* 5 */ public void mousereleased(mouseevent e) { /* 5 */ public void mouseentered(mousee

GUIプログラムⅡ

データ構造とアルゴリズム論


Java演習(2) -- 簡単なプログラム --

< F2D B825082CC96E291E82E6A7464>

r2.dvi

3. Java 2 3 Java C ( ) 4 java main 5 byte short int long float 4 7 double 8 15 char 2 ASCII Unic

:30 12:00 I. I VII II. III. IV. ( a d) V. VI : this==null, T == N A ActionListener A addactionlistener C class D actionperformed

< F2D82B682E182F182AF82F12E6A7464>

class IntCell { private int value ; int getvalue() {return value; private IntCell next; IntCell next() {return next; IntCell(int value) {this.value =

< F2D92DE82E8914B82CC977088D32E6A7464>

データ構造とアルゴリズム論

Microsoft Word 年度情報コミュニケーション実験II(Ver0.9)c.docx

Chapter 20. [ ] ; [ ] = new [ ] ; Color colors [ ] = new Color[ 20 ]; // 20 Button operations [ ] = new Button[ 10 ]; // 10 colors[ 3 ] = new Color( 1

Transcription:

Part 2 Swing Chapter 14 18 14.1 JWindow 20 14.1.1 JWindow 25 14.1.2 JWindow 25 14.1.3 AWT 27 14.2 JDialog 28 14.2.1 JDialog 32 14.2.2 JDialog 33 14.2.3 AWT 36 14.3 JOptionPane 36 14.3.1 39 14.3.2 JOptionPane 41 14.3.3 43 14.3.4 49 14.3.5 52

6 14.3.6 58 14.3.7 JOptionPane 62 14.3.8 JOptionPane 65 14.3.9 JOptionPane 68 14.3.10 AWT 78 14.4 78 Chapter 15 80 15.1 JInternalFrame 81 15.1.1 JInternalFrame 85 15.1.2 JInternalFrame 87 15.1.3 JInternalFrame 94 15.1.4 AWT 100 15.2 JDesktopPane 100 15.2.1 JDesktopPane 107 15.2.2 JDesktopPane 107 15.2.3 JDesktopPane 107 15.2.4 AWT 109 15.3 DesktopManager 109 15.3.1 DefaultDesktopManager 117 15.4 118 Chapter 16 120 16.1 JFileChooser 121 16.1.1 126 16.1.2 130 16.1.3 134 16.1.4 144 16.1.5 149 16.1.6 JFileChooser 152 16.1.7 JFileChooser 156 16.1.8 JFileChooser 161 16.1.9 AWT 168

7 16.2 JColorChooser 168 16.2.1 170 16.2.2 175 16.2.3 JColorChooser 185 16.2.4 JColorChooser 186 16.2.5 JColorChooser 187 16.2.6 AWT 189 16.3 189 Chapter 17 190 17.1 193 17.1.1 AbstractListModel 195 17.1.2 DefaultListModel 196 17.2 202 17.3 204 17.4 JList 211 17.4.1 JList 212 17.4.2 JList 216 17.4.3 JList 233 17.4.4 AWT 238 17.5 238 Chapter 18 240 18.1 241 18.2 242 18.3 243 18.3.1 ComboBoxModel 245 18.3.2 MutableComboBoxModel 245 18.3.3 DefaultComboBoxModel 246 18.4 247 18.5 251 18.5.1 252 18.5.2 255 18.5.3 259

8 18.6 263 18.7 JComboBox 274 18.7.1 JComboBox 275 18.7.2 JComboBox 276 18.7.3 JComboBox 280 18.7.4 AWT 285 18.8 286 Chapter 19 288 19.1 290 19.1.1 292 19.2 293 19.2.1 294 19.2.2 TableModel 295 19.2.3 AbstractTableModel 297 19.2.4 DefaultTableModel 300 19.2.5 306 19.3 310 19.3.1 311 19.3.2 315 19.4 323 19.4.1 DefaultTableColumnModel 324 19.4.2 325 19.4.3 329 19.4.4 331 19.5 337 19.6 341 19.6.1 341 19.6.2 TableCellRenderer 347 19.6.3 CellEditor 353 19.6.4 TableCellEditor 355 19.6.5 TableCellEditor 357 19.7 368 19.7.1 368 19.7.2 371

9 19.8 373 19.8.1 377 19.9 382 19.9.1 JTableHeader 383 19.9.2 384 19.10 JTable 389 19.10.1 JTable 390 19.10.2 JTable 393 19.10.3 TableModelEvent 393 19.10.4 TableColumnModelEvent 397 19.10.5 ListSelectionEvent 399 19.10.6 JTable 401 19.10.7 AWT 408 19.11 408 Chapter 20 410 20.1 412 20.2 416 20.2.1 TreeNode 416 20.2.2 MutableTreeNode 417 20.2.3 DefaultMutableTreeNode 417 20.3 426 20.4 430 20.4.1 DefaultTreeModel 431 20.5 439 20.5.1 DefaultTreeSelectionModel 442 20.6 446 20.6.1 DefaultTreeCellRenderer 446 20.6.2 Metal 457 20.6.3 457 20.7 459 20.7.1 DefaultCellEditor 460 20.7.2 DefaultTreeCellEditor 461

10 20.8 466 20.8.1 Test 468 20.8.2 SelectableFile FileNode 470 20.8.3 471 20.8.4 473 20.9 JTree 476 20.9.1 JTree 477 20.9.2 JTree 479 20.9.3 JTree 493 20.9.4 AWT 500 20.10 500 Chapter 21 502 21.1 Swing 503 21.1.1 javax.swing.text 505 21.2 506 21.2.1 506 21.2.2 510 21.3 514 21.4 518 21.4.1 521 21.4.2 523 21.5 527 21.5.1 527 21.5.2 529 21.5.3 531 21.5.4 533 21.6 / 535 21.7 JTextComponent 539 21.7.1 JTextComponent 541 21.7.2 JTextComponent 543 21.8 548

11 Chapter 22 550 22.1 JTextField 551 22.1.1 555 22.1.2 558 22.1.3 562 22.1.4 JTextField 566 22.1.5 JTextField 567 22.1.6 JTextField 570 22.1.7 AWT 573 22.2 JPasswordField 574 22.2.1 JPasswordField 576 22.2.2 JPasswordField 576 22.3 JTextArea 578 22.3.1 JTextArea 582 22.3.2 JTextArea 582 22.3.3 AWT 585 22.4 JEditorPane 586 22.4.1 JEditorPane 589 22.4.2 JEditorPane 589 22.4.3 JEditorPane 592 22.5 JTextPane 595 22.5.1 595 22.5.2 597 22.5.3 JTextPane 605 22.5.4 JTextPane 605 22.5.5 AWT 608 22.6 608 Chapter 23 610 23.1 611 23.2 AttributeSet StyleConstants 614 23.3 617

12 23.4 621 23.4.1 622 23.5 StyleContext 626 23.6 633 23.7 636 Appendix A 637 Appendix B 641 655

CHAPTER 14 JWindow - JWindow - JWindow JDialog - JDialog - JDialog JOptionPane - - JOptionPane - - - -

Window Frame Dialog - 14-1 Frame

20 Chapter 14 Frame Dialog Window Window JRootPane JFrame Frame Window Dialog JWindow java.awt.window JRootPane JWindow JWindow - JWindow JLabel - - JWindow JLabel

14.1 JWindow 21 14-1 JWindow 14-1 JWindow import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Test extends JFrame { Toolkit toolkit = Toolkit.getDefaultToolkit(); JWindow window = new JWindow(); JLabel label = new JLabel(new ImageIcon("mandrill.jpg")); static public void main(string[] args) { JFrame frame = new Test(); public Test() { label.setborder(borderfactory.createraisedbevelborder()); window.getcontentpane().add(label, "Center"); centerwindow(); window.show(); window.addmouselistener(new MouseAdapter() { public void mousepressed(mouseevent e) { if(e.getclickcount() == 2) { window.dispose(); System.exit(0); ); private void centerwindow() { Dimension scrnsize = toolkit.getscreensize(); Dimension labelsize = label.getpreferredsize();

22 Chapter 14 int labelwidth = labelsize.width, labelheight = labelsize.height; window.setlocation(scrnsize.width/2 - (labelwidth/2), scrnsize.height/2 - (labelheight/2)); window.pack(); pack() show() pack() dispose() JWindow JComponent JWindow setborder() JWindow JWindow JRootPane - JWindow 14-2 JWindow

14.1 JWindow 23 - JFrame - 14-2 JWindow import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Test extends JApplet { JWindow window = new JWindow(); JMenuBar menubar = new JMenuBar(); JMenu filemenu = new JMenu("File"); JMenuItem quititem; public Test() { final Container contentpane = getcontentpane(); JButton button = new JButton("show window..."); JRootPane windowrootpane = window.getrootpane(); contentpane.setlayout(new FlowLayout()); contentpane.add(button); filemenu.add("new"); filemenu.add("open..."); filemenu.add("save"); filemenu.add("save As..."); filemenu.addseparator(); filemenu.add(quititem = new JMenuItem("Quit")); menubar.add(filemenu); window.getrootpane().setjmenubar(menubar); window.getrootpane().setborder(borderfactory.createraisedbevelborder()); button.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { Point pt = contentpane.getlocation(); SwingUtilities.convertPointToScreen(pt, contentpane); // window.setbounds(pt.x + 10, pt.y + 10, 200, 200); window.show(); quititem.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { window.dispose(); );

24 Chapter 14 ); JWindow JFrame JWindow JWindow - 14-1 JWindow java.awt.window - RootPane Container java.awt. Window A Accessible implements extends implements JRootPane rootpane JWindow rootpanecheckingenabled boolean 14-3 JWindow

14.1 JWindow 25 JWindow JWindow java.awt.window Accessible RootPaneContainer JWindow boolean protected JRootPane - JWindow 14-2 JWindow contentpane Container JPanel glasspane Component Component layeredpane JLayeredPane JLayeredPane rootpane JRootPane JRootPane contentpane JWindow glasspane layeredpane JLayeredPane rootpane JWindow JWindow AP I JWindow java.awt.window RootPaneContainer javax.accessibility.accessible

26 Chapter 14 public JWindow() public JWindow(Frame) public JWindow(GraphicsConfiguration) 1 public JWindow(Window) public JWindow(Window, GraphicsConfiguration) JWindow java.awt.frame JDialog JWindow SwingUtilities.getSharedOwnerFrame() protected void addimpl(component, Object, int) protected JRootPane createrootpane() protected boolean isrootpanecheckingenabled() protected void setrootpanecheckingenabled(boolean) protected void setrootpane(jrootpane) public void setlayout(layoutmanager) protected void windowinit() JWindow RootPaneContainer JWindow setrootpanecheckingenabled() isrootpanecheckingenabled() JWindow createrootpane() JRootPane JWindow protected setlayout() Window

14.1 JWindow 27 windowinit() JWindow JWindow protected RootPaneContainer public Container getcontentpane() public Component getglasspane() public JLayeredPane getlayeredpane() public JRootPane getrootpane() public void setcontentpane(container) public void setglasspane(component) public void setlayeredpane(jlayeredpane) RootPaneContainer RootPaneContainer JRootPane public AccessibleContext getaccessiblecontext() protected String paramstring() public void remove(component) 2 JWindow Accessible getaccessiblecontext() Accessible JComponent paramstring() JWindow java.awt.window Window Container remove()

28 Chapter 14 JWindow JDialog JRootPane JDialog JRootPane JDialog JOptionPane - - 14-4 JDialog ConstraintsPanel

14.2 JDialog 29 ConstraintsPanel - JPanel Frame null true JDialog getcontentpane() ConstraintsPanel pack() NOTE pack() public class Test extends JApplet { private ConstraintsPanel cp = new ConstraintsPanel(); private JPanel buttonspanel = new JPanel(); private JButton showbutton = new JButton("show dialog..."), okbutton = new JButton("OK"), applybutton = new JButton("Apply"), cancelbutton = new JButton("Cancel"); private JButton[] buttons = new JButton[] { okbutton, applybutton, cancelbutton, ; private JDialog dialog = new JDialog((Frame)null, // "Constraints Dialog",// true); // public Test() { Container contentpane = getcontentpane(); Container dialogcontentpane = dialog.getcontentpane(); contentpane.setlayout(new FlowLayout()); contentpane.add(showbutton); dialogcontentpane.add(cp, BorderLayout.CENTER); dialogcontentpane.add(buttonspanel, BorderLayout.SOUTH); dialog.pack(); //... for(int i=0; i < buttons.length; ++i) { buttonspanel.add(buttons[i]); addbuttonlisteners(); //...

30 Chapter 14 dispose() dispose() //... private void addbuttonlisteners() { showbutton.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { // setlocationrelativeto() // dialog.setlocationrelativeto(test.this); dialog.show(); ); okbutton.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { showstatus("ok button Activated"); dialog.dispose(); ); //... - - 14-3 JDialog import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Test extends JApplet { private ConstraintsPanel cp = new ConstraintsPanel(); private JPanel buttonspanel = new JPanel(); private JButton showbutton = new JButton("show dialog..."), okbutton = new JButton("OK"), applybutton = new JButton("Apply"), cancelbutton = new JButton("Cancel"); private JButton[] buttons = new JButton[] { okbutton, applybutton, cancelbutton, ; private JDialog dialog = new JDialog((Frame)null, // "Constraints Dialog",// true); // public Test() { Container contentpane = getcontentpane();

14.2 JDialog 31 Container dialogcontentpane = dialog.getcontentpane(); contentpane.setlayout(new FlowLayout()); contentpane.add(showbutton); dialogcontentpane.add(cp, BorderLayout.CENTER); dialogcontentpane.add(buttonspanel, BorderLayout.SOUTH); dialog.pack(); // // setlocationrelativeto() pack() // // setlocationrelativeto() // setlocationrelativeto() // dialog.setlocationrelativeto(this); for(int i=0; i < buttons.length; ++i) { buttonspanel.add(buttons[i]); addbuttonlisteners(); private void addbuttonlisteners() { showbutton.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { // setlocationrelativeto() // dialog.setlocationrelativeto(test.this); dialog.show(); ); okbutton.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { showstatus("ok button Activated"); dialog.dispose(); ); applybutton.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { showstatus("apply button Activated"); ); cancelbutton.addactionlistener(new ActionListener() { public void actionperformed(actionevent e) { showstatus("cancel button Activated"); dialog.dispose(); ); JDialog -