Ignore:
Timestamp:
2010-10-02T16:39:43+02:00 (15 years ago)
Author:
postfix
Message:
 
Location:
applications/editors/josm/plugins/smed/src/smed
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/smed/src/smed/plug/ifc/SmedPluggable.java

    r23426 r23443  
    99    boolean start();
    1010    boolean stop();
     11    boolean hasFocus();
     12    boolean lostFocus();
     13    int getIndex();
     14    void setIndex(int index);
    1115    String getName();
    1216    String getFileName();
  • applications/editors/josm/plugins/smed/src/smed/tabs/SmedTabbedPane.java

    r23437 r23443  
    3232        static private List<SmedPluggable> plugins = null;
    3333        static private JTabbedPane tabbedPane = null;
     34        @SuppressWarnings("unused")
     35        private int activeIndex = -1;
    3436       
    3537    public SmedTabbedPane() {
     
    4244
    4345            if(plugins != null) {
     46
     47                if(tabbedPane == null) tabbedPane = new JTabbedPane();
     48
    4449                ImageIcon icon = null;
    45                 if(tabbedPane == null) {
    46                         tabbedPane = new JTabbedPane();
    47                         tabbedPane.addChangeListener(new ChangeListener() {
    48 
    49                                                 @Override
    50                                                 public void stateChanged(ChangeEvent event) {
    51                                                         System.out.println("hello world");
    52                                                 }
    53                         });
    54                 }
    5550
    5651                JComponent panel;
     
    6863                                tabbedPane.addTab(p.getName(),icon, panel, p.getInfo());
    6964                                tabbedPane.setMnemonicAt(i, KeyEvent.VK_1 + i);
     65                                if(i == 0) {
     66                                        p.hasFocus();
     67                                        activeIndex = 0;
     68                                }
     69                                p.setIndex(i);
    7070                       
    7171                                i++;
     
    8080                //The following line enables to use scrolling tabs.
    8181                tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
     82               
     83                // add ChangeListener
     84                tabbedPane.addChangeListener(new ChangeListener() {
     85
     86                                        @Override
     87                                        public void stateChanged(ChangeEvent event) {
     88                                                System.out.println("hello world");
     89                                                System.out.println("activeIndex:\t" + activeIndex);
     90                                                JTabbedPane pane = (JTabbedPane) event.getSource();
     91                                               
     92                                                for(SmedPluggable p : plugins) {
     93                                                        if(p.getIndex() == activeIndex) p.lostFocus();
     94                                                }
     95                                               
     96                                                System.out.println(pane.getSelectedIndex());
     97                                                activeIndex = pane.getSelectedIndex();
     98                                                for(SmedPluggable p : plugins) {
     99                                                        if(p.getIndex() == activeIndex) p.hasFocus();
     100                                                }
     101                                        }
     102                });
     103
    82104                }
    83105        } catch (IOException e) {
     
    89111    public static List<SmedPluggable> getPlugins() { return plugins; }
    90112    public static JTabbedPane getTabbedPane() { return tabbedPane; }
    91 
    92     /*
    93         @Override
    94         public void stateChanged(ChangeEvent event) {
    95                 System.out.println("hello world");
    96                
    97         }
    98         */
    99113}
Note: See TracChangeset for help on using the changeset viewer.