【正文】
(new Dimension(200,400))。 jsp=new JSplitPane(,true,treepane,desktop)。 (true)。 //===================splitpane end==================== (toppane,)。 (jsp,)。 internalX=0。 internalY=0。 } //構(gòu)造函數(shù)完 public void actionPerformed(ActionEvent e) { if(()==Exit){ //“退出”操作 dispose()。 (0)。 } if(()==About Me){ //“關(guān) 于”操作 (this, About,)。 } } class OpenListener implements ActionListener{ //打開文件 File file。 17 public void actionPerformed(ActionEvent e){ if(()==treeopen){ file=()。 if(file==null){ (null,Please select a file in the TREEVIEW ! , Confirm,)。 } } if(()==openItem||()==openBtn){ JFileChooser chooser = new JFileChooser()。 ExampleFileFilter filter = new ExampleFileFilter()。 (jpg)。 (gif)。 (png)。 (JPG , GIF amp。 PNG Images)。 (filter)。 (打開圖象文件 )。 int returnVal = (null)。 if(returnVal == ) { file=()。 } else file=null。 } if(file!=null){ JImageFrame imageframe=new JImageFrame((),true,true,true,true,file)。 (internalX,internalY,500,400)。 if(internalX100){ internalX+=30。 internalY+=30。 } else{ internalX=10。 internalY=10。 } Icon icon = new ImageIcon(images/)。 (icon)。 (imageframe,new Integer(1))。 (true)。 } } } public class CloseallListener implements ActionListener{ //關(guān)閉圖像窗口 public void actionPerformed(ActionEvent ec){ ()。 18 (backgr, new Integer())。 internalX=0。 internalY=0。 repaint()。 } } public class TileActionListener implements ActionListener { //平鋪圖像窗 口 public void actionPerformed(ActionEvent ev) { JInternalFrame[] allframes = ()。 // How many frames do we have? int count = 。 if (count == 0) return。 int sqrt = (int)(count)。 // Determine the necessary grid size int rows = sqrt。 int cols = sqrt。 if (rows * cols count) { cols++。 if (rows * cols count) { rows++。 } } Dimension size = ()。 // Define some initial values for size amp。 location. int w = / cols。 int h = / rows。 int x = 0。 // Iterate over the frames, deiconifying any iconified frames and then int y = 0。 // relocating amp。 resizing each. for (int i = 0。 i rows。 i++) { for (int j = 0。 j cols amp。amp。 ((i * cols) + j count)。 j++) { JInternalFrame f = allframes[(i * cols) + j]。 if (!() amp。amp。 ()) { try { (false)。 } catch (PropertyVetoException ignored) {} } ().resizeFrame(f, x, y, w, h)。 x += w。 } y += h。 // start the next row x = 0。 } } } class BrowseListener implements ActionListener{ //瀏覽圖像 File parentFile,file。 19 File[] files。 JInternalFrame frame。 int i=0。 public void actionPerformed(ActionEvent e){ if(()!=null){ frame=()。 try{ (true)。 }catch (PropertyVetoException ignored) {} JImageFrame image=(JImageFrame)frame。 //類型轉(zhuǎn)換! ! file=()。 parentFile=()。 try{ ImageFilter filter=new ImageFilter()。 files=(filter)。 } catch(Exception ex){ ()。 } if(()==next) i=(i+1)%。 if(()==back) i=(i1=0)?(i1):()。 (files[i])。 } } } class ScaleListener implements ActionListener{ //縮放圖像 JInternalFrame frame。 double p。 public void actionPerformed(ActionEvent e){ if(()!=null){ frame=()。 JImageFrame image=(JImageFrame)frame。 if(()==Zoom Out) p=。 if(()==Zoom In) p=。 (p)。 } } } class ReloadListener implements ActionListener{ //重載原圖 JInternalFrame frame。 public void actionPerformed(ActionEvent e){ if(()!=null){ frame=()。 JImageFrame image=(JImageFrame)frame。 20 ()。 } } } public static void main(String args[]){ JSplashWindow splash = new JSplashWindow()。 ()。 } } Design of JavaBased Graphics User Interface Abstract: In this paper, we discuss the design of Javabased graphics user interface. We introduce Graphics User Interface and Swing in brief and discuss in detail the design procedure of a image viewer. To implement the image viewer, we use some standard or extended graphics interface ponents in mom use and some kinds of events processing graphics interface. Test and operation results indicate that the image viewer works well. It can open files whose format is gif、 jpg or png, and has some easy operations such as “back”、 ”next”、 ”zoom out”、 ”zoom in” and so on. Keywords: Java, Swing, Graphics User Interface, Software design