Lade Dokument...

JAVA-PictureViewerPlusPlus - Die Erweiterung des PictureViewerPlus in JAVA
PDF Dokument,
Themen: java programmierung Kategorie: Hausarbeiten
466Views
45Downloads
| Autor: | |
| Universität: | Fachhochschule Emden/Leer |
| Thema: | IT/Informatik |
| Lizenz: | Public Domain (nicht urheberrechtlich geschützt) |
Textauszug aus diesem Dokument
1 / 2 Datei: PictureViewerPlusPlus 3 @author: Edgar Nanninga 4 Matr.Nr.: 5 Datum: 28.04.2002 6 7 das Programm ist eine Erweiterung des PictureViewerPlus, 8 mit Dialogfenster zum Oeffnen einer Datei und einem Dialogfenster, 9 ob das Programm wirklich beendet werden soll. 10 / 11 12 import java.awt.; 13 import java.awt.event.; 14 import javax.swing.; 15 import java.io.; 16 17 public class PictureViewerPlusPlus extends JFrame implements ActionListener 18 19 // ActionHandling 20 public void actionPerformedActionEvent e 21 22 String cmd = Stringe.getActionCommand; 23 24 // wenn man im Menue auf "Beenden" klickt, oeffnet sich eine Dialogbox, die 25 // fragt, ob man das Programm wirklich beenden will 26 if cmd.equals"end" 27 28 int wahl = JOptionPane.showConfirmDialogthis, "Anwendung wirklich beenden?", "Frage", 29 JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE; 30 if wahl == JOptionPane.YES_OPTION System.exit0; 31 32 33 // wenn man im Menue auf "Oeffnen" klickt, oeffnet sich eine Dialogbox, die den Dateinamen abfragt 34 // das Bild wird dan auf dem Label angezeigt und ein Eintrag in der ComboBox erzeugt 35 else if cmd.equals"open" 36 37 String grafik = JOptionPane.showInputDialogthis, "Dateiname ?", "", JOptionPane.QUESTION_MESSAGE; 38 if grafik = null 39 40 41 ImageIcon ic = new ImageIcongrafik; 42 EPanel.bildflaeche.setIconic; 43 EPanel.cb.addItemgrafik; 44 EPanel.cb.setSelectedItemgrafik; 45 46 47 48 // EventHandler für die ComboBox 49 else if e.getSource instanceof JComboBox 50 51 String image = StringEPanel.cb.getSelectedItem; 52 ImageIcon ic = new ImageIconimage; 53 EPanel.bildflaeche.setIconic; 54 EPanel.sp.getViewport.setViewPositionnew Point0,0; 1
55 56 57 58 59 public PictureViewerPlusPlusString[] pics 60 61 super"PictureViewerPlus"; 62 setSize300,300; 63 setLocation100,100; 64 65 // Menuebar einfuegen 66 EMenuBar mb = new EMenuBarthis; 67 setJMenuBarmb; 68 69 // das Panel einfuegen 70 EPanel panel = new EPanelthis, pics; 71 getContentPane.addpanel; 72 73 addWindowListenernew WindowAdapter 74 75 public void windowClosingWindowEvent we 76 77 System.exit0; 78 79 80 ; 81 setVisibletrue; 82 83 84 public static void main String[] args 85 86 // PictureViewerPlusPlus aufrufen und die Argumente uebergeben 87 new PictureViewerPlusPlusargs; 88 89 90 91 //// 92 //Klasse fuer die Menueleiste 93 class EMenuBar extends JMenuBar 94 95 public EMenuBarActionListener al 96 97 JMenu datei = new JMenu"Datei"; 98 JMenuItem open = new JMenuItem"Oeffnen"; 99 open.addActionListeneral; 100 open.setActionCommand"open"; 101 datei.addopen; 102 103 datei.addSeparator; 104 105 JMenuItem ende = new JMenuItem"Beenden"; 106 ende.addActionListeneral; 107 ende.setActionCommand"end"; 108 datei.addende; 109 adddatei; 110 111 112 2
113 //// 114 // Klasse fuer das Panel mit dem Layout 115 116 class EPanel extends JPanel 117 118 public static JLabel bildflaeche; 119 public static JComboBox cb; 120 public static JScrollPane sp; 121 122 public EPanelActionListener al, String[] bilder 123 124 setLayoutnew BorderLayout; 125 126 JPanel main = new JPanel; 127 main.setLayoutnew BorderLayout; 128 129 JPanel pnorth = new JPanel; 130 pnorth.setLayoutnew BorderLayout; 131 132 JLabel bild = new JLabel"Bild: "; 133 134 cb = new JComboBox; 135 cb.addActionListeneral; 136 137 pnorth.addbild, BorderLayout.WEST; 138 pnorth.addcb; 139 140 JPanel pcenter = new JPanel; 141 pcenter.setLayoutnew BorderLayout; 142 143 bildflaeche = new JLabel; 144 sp = new JScrollPanebildflaeche; 145 pcenter.addsp; 146 147 main.addpnorth, BorderLayout.NORTH; 148 main.addpcenter; 149 150 addmain; 151 152 // falls argumente beim Aufruf des Programms uebergeben wurden, werden sie hier 153 // in die ComboBox und auf das Label eingefuegt 154 if bilder.length = 0 155 156 for int i = 0; i < bilder.length ; i 157 158 cb.addItembilder[i]; 159 160 161 else 162 163 cb.addItem""; 164 165 166 167 // Ende Programm 168 // Edgar Nanninga, 2002 169 // FHOOW Emden, medientechnik 170 // Praktikum Programmieren 2 3
Gesamtes Dokument lesen »
55 56 57 58 59 public PictureViewerPlusPlusString[] pics 60 61 super"PictureViewerPlus"; 62 setSize300,300; 63 setLocation100,100; 64 65 // Menuebar einfuegen 66 EMenuBar mb = new EMenuBarthis; 67 setJMenuBarmb; 68 69 // das Panel einfuegen 70 EPanel panel = new EPanelthis, pics; 71 getContentPane.addpanel; 72 73 addWindowListenernew WindowAdapter 74 75 public void windowClosingWindowEvent we 76 77 System.exit0; 78 79 80 ; 81 setVisibletrue; 82 83 84 public static void main String[] args 85 86 // PictureViewerPlusPlus aufrufen und die Argumente uebergeben 87 new PictureViewerPlusPlusargs; 88 89 90 91 //// 92 //Klasse fuer die Menueleiste 93 class EMenuBar extends JMenuBar 94 95 public EMenuBarActionListener al 96 97 JMenu datei = new JMenu"Datei"; 98 JMenuItem open = new JMenuItem"Oeffnen"; 99 open.addActionListeneral; 100 open.setActionCommand"open"; 101 datei.addopen; 102 103 datei.addSeparator; 104 105 JMenuItem ende = new JMenuItem"Beenden"; 106 ende.addActionListeneral; 107 ende.setActionCommand"end"; 108 datei.addende; 109 adddatei; 110 111 112 2
113 //// 114 // Klasse fuer das Panel mit dem Layout 115 116 class EPanel extends JPanel 117 118 public static JLabel bildflaeche; 119 public static JComboBox cb; 120 public static JScrollPane sp; 121 122 public EPanelActionListener al, String[] bilder 123 124 setLayoutnew BorderLayout; 125 126 JPanel main = new JPanel; 127 main.setLayoutnew BorderLayout; 128 129 JPanel pnorth = new JPanel; 130 pnorth.setLayoutnew BorderLayout; 131 132 JLabel bild = new JLabel"Bild: "; 133 134 cb = new JComboBox; 135 cb.addActionListeneral; 136 137 pnorth.addbild, BorderLayout.WEST; 138 pnorth.addcb; 139 140 JPanel pcenter = new JPanel; 141 pcenter.setLayoutnew BorderLayout; 142 143 bildflaeche = new JLabel; 144 sp = new JScrollPanebildflaeche; 145 pcenter.addsp; 146 147 main.addpnorth, BorderLayout.NORTH; 148 main.addpcenter; 149 150 addmain; 151 152 // falls argumente beim Aufruf des Programms uebergeben wurden, werden sie hier 153 // in die ComboBox und auf das Label eingefuegt 154 if bilder.length = 0 155 156 for int i = 0; i < bilder.length ; i 157 158 cb.addItembilder[i]; 159 160 161 else 162 163 cb.addItem""; 164 165 166 167 // Ende Programm 168 // Edgar Nanninga, 2002 169 // FHOOW Emden, medientechnik 170 // Praktikum Programmieren 2 3
Gesamtes Dokument lesen »


Kommentare zu diesem Dokument
Es wurden noch keine Kommentare abgegeben. Sei der Erste, der dieses Dokument kommentiert