1 19 20 23 24 package org.netbeans.modules.web.monitor.client; 25 26 import java.awt.event.ActionEvent ; 27 import java.awt.event.ActionListener ; 28 import java.util.logging.Logger ; 29 import javax.swing.Icon ; 30 import javax.swing.ImageIcon ; 31 import javax.swing.JButton ; 32 33 import org.openide.util.NbBundle; 34 35 36 class SortButton extends JButton { 37 38 private int state = DisplayTable.NEUTRAL; 39 40 private Icon [] icon = new Icon [3]; 41 42 public SortButton(final DisplayTable dt) { 43 super(); 44 icon[0] = new ImageIcon (TransactionView.class.getResource 45 ("/org/netbeans/modules/web/monitor/client/icons/unsorted.gif")); icon[1] = new ImageIcon (TransactionView.class.getResource 47 ("/org/netbeans/modules/web/monitor/client/icons/a2z.gif")); icon[2] = new ImageIcon (TransactionView.class.getResource 49 ("/org/netbeans/modules/web/monitor/client/icons/z2a.gif")); setIcon(icon[state]); 51 setBorder(null); 52 setBorderPainted(false); 53 setToolTipText(NbBundle.getBundle(TransactionView.class).getString("ACS_SortButtonUnsortedA11yDesc")); 54 55 addActionListener(new ActionListener () { 56 public void actionPerformed(ActionEvent e) { 57 58 Logger.getLogger(SortButton.class.getName()).info("Sort requested"); 59 60 state++; 61 state=state%3; 62 63 Logger.getLogger(SortButton.class.getName()).info("State is: " + String.valueOf(state)); 64 JButton b = (JButton )e.getSource(); 65 b.setIcon(icon[state]); 66 67 if(state == DisplayTable.NEUTRAL) 68 { 69 SortButton.this.setToolTipText(NbBundle.getBundle(TransactionView.class).getString("ACS_SortButtonUnsortedA11yDesc")); 71 } 72 else if(state == DisplayTable.A2Z) { 73 SortButton.this.setToolTipText(NbBundle.getBundle(TransactionView.class).getString("ACS_SortButtonSortAZA11yDesc")); 74 } else if(state == DisplayTable.Z2A) { 75 SortButton.this.setToolTipText(NbBundle.getBundle(TransactionView.class).getString("ACS_SortButtonSortZAA11yDesc")); 76 } 77 dt.setSorting(state); 78 } 79 }); 80 } 81 82 int getMode() { 83 return state; 84 } 85 } | Popular Tags |