From: <sa...@us...> - 2003-10-02 09:30:43
|
Update of /cvsroot/jrobin/src/jrobin/mrtg/client In directory sc8-pr-cvs1:/tmp/cvs-serv30096/jrobin/mrtg/client Modified Files: GraphFrame.java Log Message: Minor improvements to MRTG demo app (popup menus, etc...) Index: GraphFrame.java =================================================================== RCS file: /cvsroot/jrobin/src/jrobin/mrtg/client/GraphFrame.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** GraphFrame.java 4 Sep 2003 13:28:18 -0000 1.1 --- GraphFrame.java 2 Oct 2003 09:30:40 -0000 1.2 *************** *** 23,26 **** --- 23,28 ---- package jrobin.mrtg.client; + import jrobin.mrtg.MrtgException; + import javax.swing.*; import javax.swing.border.BevelBorder; *************** *** 117,120 **** --- 119,123 ---- graphLabel.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); content.add(graphLabel, BorderLayout.CENTER); + // botom panel JPanel bottomPanel = new JPanel(); *************** *** 155,158 **** --- 158,213 ---- mainContent.add(box, BorderLayout.EAST); + // popup menu + final JPopupMenu popup = new JPopupMenu(); + JMenuItem leftMenuItem = new JMenuItem("<< Left"); + leftMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + shift(false); + } + }); + JMenuItem rightMenuItem = new JMenuItem("Right >>"); + rightMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + shift(true); + } + }); + JMenuItem refreshMenuItem = new JMenuItem("Refresh graph"); + refreshMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + refreshButton.doClick(); + } + }); + JMenuItem saveMenuItem = new JMenuItem("Save graph..."); + saveMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + save(); + } + }); + JMenuItem closeMenuItem = new JMenuItem("Close window"); + closeMenuItem.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + close(); + } + }); + if(type != TYPE_CUSTOM) { + popup.add(leftMenuItem); + popup.add(rightMenuItem); + } + popup.add(refreshMenuItem); + popup.addSeparator(); + popup.add(saveMenuItem); + popup.addSeparator(); + popup.add(closeMenuItem); + MouseAdapter adapter = new MouseAdapter() { + public void mousePressed(MouseEvent e) { showPopup(e); } + public void mouseReleased(MouseEvent e) { showPopup(e); } + private void showPopup(MouseEvent e) { + if (e.isPopupTrigger()) { + popup.show(e.getComponent(), e.getX(), e.getY()); + } + } + }; + graphLabel.addMouseListener(adapter); + // populate controls fillDays(startDay); fillDays(endDay); *************** *** 173,176 **** --- 228,236 ---- rightButton.setMnemonic(KeyEvent.VK_R); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + try { + setIconImage(Resources.getImage(Client.ICON)); + } catch (MrtgException e) { + e.printStackTrace(); + } Util.centerOnScreen(this); } |