List of usage examples for java.awt.dnd DropTarget addDropTargetListener
public synchronized void addDropTargetListener(DropTargetListener dtl) throws TooManyListenersException
From source file:tvbrowser.ui.mainframe.MainFrame.java
private MainFrame() { super(TVBrowser.MAINWINDOW_TITLE); mIsVisible = false;//from ww w .j av a 2 s. c o m mSettingsWillBeOpened = false; mAutoDownloadTimer = -1; mLastTimerMinutesAfterMidnight = -1; mLastAutoUpdateRun = System.currentTimeMillis(); mChannelDateArr = null; mOnAirRowProgramsArr = null; mStatusBar = new StatusBar(); if (OperatingSystem.isMacOs()) { /* create the menu bar for MacOS X */ try { Class<?> impl = Class.forName("tvbrowser.ui.mainframe.macosx.MacOSXMenuBar"); Class<? extends MainFrame> mainFrameClass = this.getClass(); Class<?> jlabelClass = Class.forName("javax.swing.JLabel"); Constructor<?> cons = impl.getConstructor(new Class[] { mainFrameClass, jlabelClass }); mMenuBar = (MenuBar) cons.newInstance(new Object[] { this, mStatusBar.getLabel() }); } catch (Exception e) { if (TVBrowser.isTransportable()) { mLog.info("Using default menu bar (instead of MacOSXMenuBar) for transportable version."); } mLog.warning("Could not instantiate MacOSXMenuBar\n" + e.toString()); if (e.getCause() != null) { StringWriter sw = new StringWriter(); e.getCause().printStackTrace(new PrintWriter(sw)); mLog.warning(sw.toString()); } mMenuBar = new DefaultMenuBar(this, mStatusBar.getLabel()); mLog.info("Using default menu bar"); } } else { mMenuBar = new DefaultMenuBar(this, mStatusBar.getLabel()); } // create content jcontentPane = (JPanel) getContentPane(); jcontentPane.setLayout(new BorderLayout()); JPanel skinPanel = new JPanel(); skinPanel.setLayout(new BorderLayout()); JPanel centerPanel = new JPanel(new BorderLayout()); centerPanel.setOpaque(false); centerPanel.setBorder(BorderFactory.createEmptyBorder()); mFilterPanel = new FilterPanel(); mFilterPanel.setVisible(false); mTimeChooserPanel = new TimeChooserPanel(this); centerPanel.add(mFilterPanel, BorderLayout.NORTH); Channel[] channelArr = ChannelList.getSubscribedChannels(); int startOfDay = Settings.propProgramTableStartOfDay.getInt(); int endOfDay = Settings.propProgramTableEndOfDay.getInt(); mProgramTableModel = new DefaultProgramTableModel(channelArr, startOfDay, endOfDay); mProgramTableScrollPane = new ProgramTableScrollPane(mProgramTableModel); centerPanel.add(mProgramTableScrollPane); createDateSelector(); skinPanel.add(centerPanel, BorderLayout.CENTER); mChannelChooser = new ChannelChooserPanel(this); /* create structure */ mRootNode = new Node(null); if (Settings.propPluginViewIsLeft.getBoolean()) { mPluginsNode = new Node(mRootNode); } else { mNavigationNode = new Node(mRootNode); } mMainframeNode = new Node(mRootNode); Node programtableNode = new Node(mMainframeNode); if (Settings.propPluginViewIsLeft.getBoolean()) { mNavigationNode = new Node(mMainframeNode); } else { mPluginsNode = new Node(mMainframeNode); } mTimebuttonsNode = new Node(mNavigationNode); mDateChannelNode = new Node(mNavigationNode); mDateNode = new Node(mDateChannelNode); mChannelNode = new Node(mDateChannelNode); mRootNode.setProperty(Settings.propViewRoot); mMainframeNode.setProperty(Settings.propViewMainframe); mNavigationNode.setProperty(Settings.propViewNavigation); mDateChannelNode.setProperty(Settings.propViewDateChannel); /* create views */ programtableNode.setLeaf(skinPanel); this.setShowPluginOverview(Settings.propShowPluginView.getBoolean()); this.setShowTimeButtons(Settings.propShowTimeButtons.getBoolean()); this.setShowDatelist(Settings.propShowDatelist.getBoolean()); this.setShowChannellist(Settings.propShowChannels.getBoolean()); updateToolbar(); dateChanged(new devplugin.Date(), null, null); mCenterComponent = mRootNode.getComponent(); if (mCenterComponent != null) { jcontentPane.add(mCenterComponent, BorderLayout.CENTER); } if (Settings.propIsStatusbarVisible.getBoolean()) { jcontentPane.add(mStatusBar, BorderLayout.SOUTH); } setJMenuBar(mMenuBar); addContextMenuMouseListener(mMenuBar); // set program filter FilterList filterList = FilterList.getInstance(); ProgramFilter filter = filterList.getFilterByName(Settings.propLastUsedFilter.getString()); if (filter == null) { filter = FilterManagerImpl.getInstance().getDefaultFilter(); } setProgramFilter(filter); // set channel group filter String channelGroupName = Settings.propLastUsedChannelGroup.getString(); if (channelGroupName != null) { FilterComponent component = FilterComponentList.getInstance() .getFilterComponentByName(channelGroupName); if (component != null && component instanceof ChannelFilterComponent) { setChannelGroup((ChannelFilterComponent) component); } } addKeyboardAction(); mTimer = new Timer(10000, new ActionListener() { public void actionPerformed(ActionEvent evt) { handleTimerEvent(); } }); mTimer.start(); setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); //create the drop target for installation of Plugins with Drag'N'Drop on MainFrame DropTarget target = new DropTarget(); try { target.addDropTargetListener(this); } catch (TooManyListenersException e1) { //ignore } this.setDropTarget(target); }