Java Swing JXDatePicker

前端 未结 5 541
执笔经年
执笔经年 2020-12-11 06:15

I\'m using SwingX JXDatePicker and I can\'t figure out how to provide next/previous year buttons (as by default it only provides next/previous month buttons).

Also,

5条回答
  •  盖世英雄少女心
    2020-12-11 07:04

    improvement :

    the datetimePicker is too far from the button so

    at line 139 :

    public Popup getPopup(Container c) {
    
        if (popup == null) {
    
            Point p = c.getLocation();
    
            PopupFactory factory = PopupFactory.getSharedInstance();
    
    
     // FramePrinc.Location.x ==>  public static Point Location ;  in class FramePrinc
    
         popup = factory.getPopup(c, this, FramePrinc.Location.x,FramePrinc.Location.y);
    
        }
    
        return popup;
    
    }
    

    and inside the action you get the location of the component

    datePicker.addActionListener(new ActionListener() {
    
            public void actionPerformed(ActionEvent e) {
    
                //Add this Line and you will get a good result
    
                Location = datePickerButton.getLocationOnScreen();
    
                dp.setDate(testDate.getText());
    
                dp.popupShow(datePicker);
            }
        });
    

    So :

    • create another class : for example FramePrinc
    • create public static Point Location
    • add you dateTimePiker inside a panel
    • put the line that i said inside the button action

    good luck

    Grine_Amine Improvement :)

提交回复
热议问题