資源描述:
《Java模擬Windows開始菜單》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在教育資源-天天文庫。
1、packagewindowcomponents;importjava.awt.BorderLayout;importjava.awt.Color;importjava.awt.Font;importjava.awt.FontMetrics;importjava.awt.GradientPaint;importjava.awt.Graphics;importjava.awt.Graphics2D;importjava.awt.Image;importjava.awt.Insets;importjava.awt.event.ActionEvent;impor
2、tjava.awt.event.ActionListener;importjava.awt.geom.AffineTransform;importjava.awt.image.BufferedImage;importjavax.swing.ImageIcon;importjavax.swing.JButton;importjavax.swing.JFrame;importjavax.swing.JMenuItem;importjavax.swing.JPanel;importjavax.swing.JPopupMenu;publicclassWindow
3、sStartMenuSimulation{/***@paramargs*/publicstaticvoidmain(String[]args){//TODOAuto-generatedmethodstubDemoWindow15dw=newDemoWindow15("模擬Windows開始菜單");dw.setBounds(dw.getToolkit().getScreenSize().width/3,dw.getToolkit().getScreenSize().height/3,dw.getToolkit().getScreenSize().widt
4、h/3,dw.getToolkit().getScreenSize().height/3);dw.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);dw.setVisible(true);}}classDemoWindow15extendsJFrameimplementsActionListener{//菜單項(xiàng)圖片ImageupdateImage=newImageIcon("images/update.gif").getImage();ImageprogramImage=newImageIcon("images
5、/program.gif").getImage();ImagedocumentImage=newImageIcon("images/document.gif").getImage();ImagesetImage=newImageIcon("images/set.gif").getImage();ImagefindImage=newImageIcon("images/find.gif").getImage();ImagehelpImage=newImageIcon("images/help.gif").getImage();ImagerunImage=ne
6、wImageIcon("images/run.gif").getImage();ImagelogoutImage=newImageIcon("images/logout.gif").getImage();ImageshutdownImage=newImageIcon("images/shutdown.gif").getImage();//按鈕圖片ImageIconwindowsImage=newImageIcon("images/windows.gif");//“開始”按鈕JButtonjb=newJButton("開始",windowsImage);S
7、tartMenusm=newStartMenu();//布局面板JPaneljp1=newJPanel();JPaneljp2=newJPanel();ImageMenu1im=null;publicDemoWindow15(Stringtitle){super(title);jb.setFont(newFont("宋體",Font.BOLD,18));jp2.setLayout(newBorderLayout());jp2.add(jb,BorderLayout.WEST);add(jp1,BorderLayout.CENTER);add(jp2,Bo
8、rderLayout.SOUTH);im=newImageMenu1("Wind