⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mainwindow.java

📁 JMule是一个基于Java开发
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     				        		 JOptionPane.showMessageDialog(_this, "An error occured, most probably the file format is wrong", "Error Message",JOptionPane.ERROR_MESSAGE);	     				        	}     				        });	     				      }	                 	 }                  })).start();        	  }        	}        });        				import_server_list.addActionListener(new ActionListener() {			 public void actionPerformed(ActionEvent event) {				 System.out.println("Import server list entered");				 file_chooser.showDialog(_this, "Choose");   			 }		});				new_downloads.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {			    System.out.println("New downloads menu item pressed");				}		});		new_servers.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {			    System.out.println("New serververs menu item pressed");				}		});		ui_chooser.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {			    final UIChooserWizad ui_chooser = new UIChooserWizad(_this); 			    ui_chooser.setSize(500, 400);			    SwingUtils.setWindowLocationRelativeTo(ui_chooser,_this);				ui_chooser.setVisible(true);			}		});				config_wizard.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {				SetupWizard setup_wizard = new SetupWizard();				setup_wizard.pack();				setup_wizard.setVisible(true);			}		});				options.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {				SettingsDialog settings_dialog = new SettingsDialog(_this);				settings_dialog.setSize(379, 495);				SwingUtils.setWindowLocationRelativeTo(settings_dialog,_this);				settings_dialog.setVisible(true);			}		});				// --------------------------------------------------------------				open_support.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {				BrowserLauncher.openURL(JMConstants.OPEN_SUPPORT);			}		});				project_forums.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {				BrowserLauncher.openURL(JMConstants.JMULE_FORUMS);			}		});				bug_tracker.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {				BrowserLauncher.openURL(JMConstants.JMULE_BUG_TRACKER);			}		});				check_for_updates.addActionListener(new ActionListener() {			public void actionPerformed(ActionEvent event) {				VersionChecker version_checker = new VersionChecker(_this);			    SwingUtils.setWindowLocationRelativeTo(version_checker, _this);			    version_checker.setVisible(true);				}		});	}		private void setView(JPanel new_view) {		center_panel.remove( the_current_view );		center_panel.add( new_view );		center_panel.updateUI();		the_current_view = new_view;	}	public enum ServerStatusTypes {		DISCONNECTED { public String toString() { return _._("mainwindow.statusbar.label.disconnected"); } },		CONNECTING { public String toString() { return _._("mainwindow.statusbar.label.connecting"); }	},		CONNECTED { public String toString() { return _._("mainwindow.statusbar.label.connected"); } };		public abstract String toString();	}		public enum ClientIDTypes {		LOW_ID { public String toString() { return _._("mainwindow.statusbar.label.low_id"); } },		HIGH_ID { public String toString() { return _._("mainwindow.statusbar.label.high_id"); } },		// when the system is disconnected		NO_ID { public String toString() { return ""; } };	    public abstract String toString();		}		class StatusBar extends JPanel implements Refreshable {				private JLabel server_status = new JLabel(_._("mainwindow.statusbar.label.disconnected"));		private JLabel client_id = new JLabel();		private JLabel download_speed = new JLabel();		private JLabel upload_speed = new JLabel();		private JFrame frame;		private AdjustSpeedLimitsDialog speed_limits_dialog;				private JPopupMenu popup_menu = new JPopupMenu();				class MousePopupListener extends MouseAdapter {		    public void mousePressed(MouseEvent e) {		      checkPopup(e);		    }		    public void mouseClicked(MouseEvent e) {		      checkPopup(e);		    }		    public void mouseReleased(MouseEvent e) {		      checkPopup(e);		    }		    private void checkPopup(MouseEvent e) {		      if (e.isPopupTrigger()) {		        popup_menu.show(e.getComponent(), e.getX(), e.getY());		      }		    }		 }				private String download_speed_limit="";		private String upload_speed_limit="";				String downloadSpeed;		String uploadSpeed;				public StatusBar(final JFrame frame) {			this.frame = frame;			speed_limits_dialog = new AdjustSpeedLimitsDialog(frame);			this.setPreferredSize(new java.awt.Dimension(100, 25));			this.setLayout(new BorderLayout());			this.setBorder(javax.swing.BorderFactory.createEtchedBorder(javax.swing.border.EtchedBorder.RAISED));			JPanel left_panel = new JPanel();			left_panel.setLayout(new GridLayout(1,2,10,0));			server_status.setIcon(ImgRep.getIcon("toolbar_disconnected.png"));			left_panel.add(server_status);			left_panel.add(client_id);			JPanel right_panel = new JPanel();			right_panel.setLayout(new GridLayout(1,2,10,0));			download_speed.setIcon(ImgRep.getIcon("down.gif"));			upload_speed.setIcon(ImgRep.getIcon("up.gif"));			right_panel.add(download_speed);			right_panel.add(upload_speed);			this.add(left_panel,BorderLayout.WEST);			this.add(right_panel,BorderLayout.EAST);						JMenuItem adjust_speeds = new JMenuItem("Adjust speed limits");			adjust_speeds.addActionListener(new ActionListener() {				public void actionPerformed(ActionEvent event) {					SwingUtils.setWindowLocationRelativeTo(speed_limits_dialog, frame);					speed_limits_dialog.setVisible(true);									}			});			popup_menu.add(adjust_speeds);			this.addMouseListener(new MousePopupListener());		}				public void setServerStatus(ServerStatusTypes statusType, String server) {			switch(statusType) {			   case DISCONNECTED : server_status.setText(ServerStatusTypes.DISCONNECTED.toString());			                       server_status.setToolTipText("");			                       server_status.setIcon(ImgRep.getIcon("toolbar_disconnected.png")); break;			   case CONNECTING   : server_status.setText(ServerStatusTypes.CONNECTING.toString());			                       server_status.setToolTipText("Connecting to " + server); break;			   case CONNECTED    : server_status.setText(ServerStatusTypes.CONNECTED.toString());			                       server_status.setToolTipText(server);			                       server_status.setIcon(ImgRep.getIcon("toolbar_connected.png")); break;			}		}				public void setClientIDType(ClientIDTypes clientIDType, String clientID) {			switch(clientIDType) {			   case LOW_ID       : client_id.setForeground(Color.RED);				                   client_id.setText("LOW ID");			                       client_id.setToolTipText(clientID); break;			   case HIGH_ID      : client_id.setForeground(Color.BLACK);				                   client_id.setText("HIGH ID");			                       client_id.setToolTipText(clientID); break;			   case NO_ID        : client_id.setText("");	                               client_id.setToolTipText(""); break;			}		}				public void setDownloadSpeedLimit(String downloadSpeedLimit) {			download_speed_limit = downloadSpeedLimit;		}				public void setUploadSpeedLimit(String uploadSpeedLimit) {			upload_speed_limit = uploadSpeedLimit;		}				public void refresh() {			downloadSpeed = SpeedFormatter.formatSpeed( _peer_manager.getDownloadSpeed() );			uploadSpeed = SpeedFormatter.formatSpeed( _peer_manager.getUploadSpeed() );			download_speed.setText( ( download_speed_limit != "" ? "[" : "" ) + 					                download_speed_limit + 					                ( download_speed_limit != "" ? "] " : "" ) + 					                downloadSpeed + " ");			upload_speed.setText( ( upload_speed_limit != "" ? "[" : "" ) + 					             upload_speed_limit + 					              ( upload_speed_limit != "" ? "] " : "" ) + 					              uploadSpeed + " ");		}	}		private void setStatusBar() {		status_bar = new StatusBar(this);		//status_bar.setBorder(javax.swing.BorderFactory.createEtchedBorder());		this.getContentPane().add(status_bar, BorderLayout.SOUTH);		_ui_updater.addRefreshable(status_bar);				if( _config.getDownloadLimit() != 0 ) status_bar.setDownloadSpeedLimit(SpeedFormatter.formatSpeed(_config.getDownloadLimit()));		if( _config.getUploadLimit() != 0 ) status_bar.setUploadSpeedLimit(SpeedFormatter.formatSpeed(_config.getUploadLimit()));				_config.addConfigurationListener(new ConfigurationAdapter() {			public void downloadLimitChanged(long downloadLimit) {			   if(downloadLimit != 0)					   status_bar.setDownloadSpeedLimit(SpeedFormatter.formatSpeed(downloadLimit));			   else 				   status_bar.setDownloadSpeedLimit("");			}						public void uploadLimitChanged(long uploadLimit) {				if(uploadLimit != 0)				   status_bar.setUploadSpeedLimit(SpeedFormatter.formatSpeed(uploadLimit));				else				   status_bar.setUploadSpeedLimit("");			}		});	}		// window listener methods	public void windowActivated(WindowEvent e) {}	public void windowClosed(WindowEvent e) {}	public void windowClosing(WindowEvent e) {		shutdownTheSystem();	}    public void windowDeactivated(WindowEvent e) {}	public void windowDeiconified(WindowEvent e) {}	public void windowIconified(WindowEvent e) {}		public void windowOpened(WindowEvent e) {}		private void shutdownTheSystem() {		if(_pref.isPromptOnExitEnabled()) {		   int value = JOptionPane.showConfirmDialog(null,"Are you sure you want to exit ?", "JMule", JOptionPane.YES_NO_OPTION);		   if(value == JOptionPane.YES_OPTION) {			  try {			      JMuleUIManager.getSingleton().shutdown();			  }catch(Throwable ex) {				  ex.printStackTrace();			  }			this.setVisible(false);		   } else return;	    }				try {		    JMuleUIManager.getSingleton().shutdown();		}catch(Throwable ex) {			ex.printStackTrace();		}	}		public static void main(String args[]) {				try { 					  JMuleCoreFactory.create().start();		  		}catch(Throwable t) {						t.printStackTrace();		}		SwingGUIUpdater.getInstance().start();		Localizer.initialize();		UIManager.put("ToolTip.foreground", new ColorUIResource(Color.BLACK));		UIManager.put("ToolTip.background", new ColorUIResource(0Xfdf7c2));		MainWindow mw = new MainWindow();		mw.pack();				mw.setVisible( true );		//Toolkit.getDefaultToolkit().beep();			}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -