Search in sources :

Example 1 with MTGEventProvider

use of org.magic.services.extra.MTGEventProvider in project MtgDesktopCompanion by nicho92.

the class MagicEventsDashlet method initGUI.

public void initGUI() {
    provider = new MTGEventProvider();
    JPanel panneauHaut = new JPanel();
    getContentPane().add(panneauHaut, BorderLayout.NORTH);
    cboYear = new JComboBox<>();
    cboYear.addItemListener(ie -> init());
    panneauHaut.add(cboYear);
    lblLoading = new JLabel("");
    lblLoading.setIcon(MTGConstants.ICON_LOADING);
    lblLoading.setVisible(false);
    cboMonth = new JComboBox<>();
    panneauHaut.add(cboMonth);
    panneauHaut.add(lblLoading);
    JScrollPane scrollPane = new JScrollPane();
    getContentPane().add(scrollPane, BorderLayout.CENTER);
    eventsModel = new MagicEventsTableModel();
    table = new JXTable();
    scrollPane.setViewportView(table);
    c = GregorianCalendar.getInstance();
    c.setTime(new Date());
    for (int i = c.get(Calendar.YEAR) - 1; i <= c.get(Calendar.YEAR) + 1; i++) cboYear.addItem(i);
    for (int i = 1; i < 13; i++) cboMonth.addItem(i);
    cboYear.setSelectedItem(c.get(Calendar.YEAR));
    cboMonth.setSelectedItem(c.get(Calendar.MONTH) + 1);
    cboYear.addItemListener(ie -> {
        if (ie.getStateChange() == ItemEvent.SELECTED) {
            init();
        }
    });
    cboMonth.addItemListener(ie -> {
        if (ie.getStateChange() == ItemEvent.SELECTED) {
            init();
        }
    });
    if (getProperties().size() > 0) {
        Rectangle r = new Rectangle((int) Double.parseDouble(getProperty("x")), (int) Double.parseDouble(getProperty("y")), (int) Double.parseDouble(getProperty("w")), (int) Double.parseDouble(getProperty("h")));
        setBounds(r);
    }
    setVisible(true);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) JXTable(org.jdesktop.swingx.JXTable) MTGEventProvider(org.magic.services.extra.MTGEventProvider) Rectangle(java.awt.Rectangle) JLabel(javax.swing.JLabel) MagicEventsTableModel(org.magic.gui.models.MagicEventsTableModel) Date(java.util.Date)

Aggregations

Rectangle (java.awt.Rectangle)1 Date (java.util.Date)1 JLabel (javax.swing.JLabel)1 JPanel (javax.swing.JPanel)1 JScrollPane (javax.swing.JScrollPane)1 JXTable (org.jdesktop.swingx.JXTable)1 MagicEventsTableModel (org.magic.gui.models.MagicEventsTableModel)1 MTGEventProvider (org.magic.services.extra.MTGEventProvider)1