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

📄 optiondialog.java

📁 java实现msn的功能
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        panel.add( tstampCheck );

		// Toggle Emoticon display.
		emoticonCheck = new JCheckBox( Msg.get("label.emoticon.view") );
		emoticonCheck.setFont( FONT );
		emoticonCheck.setAlignmentX( 0.0f );
		emoticonCheck.setMaximumSize( new Dimension(Short.MAX_VALUE,24) );
		panel.add( emoticonCheck );

		fixedFontFaceCheck = new JCheckBox( Msg.get("label.use.fixed.font") );
		fixedFontFaceCheck.setFont( FONT );
		fixedFontFaceCheck.setAlignmentX( 0.0f );
		fixedFontFaceCheck.setMaximumSize( new Dimension(Short.MAX_VALUE, 24) );
		panel.add( fixedFontFaceCheck );

		return panel;
	}

	private JPanel createAutoNickTab()
	{
		JPanel panel = new JPanel();
		BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS);
		panel.setBorder( BorderFactory.createEmptyBorder(10,10,10,10) );
		panel.setLayout( layout );
		
		JLabel l0 = new JLabel( "Enter your friendly name as a prefix and postfix" );
		l0.setFont( FONT );
		panel.add( l0 );


		JPanel p0 = new JPanel(new BorderLayout(5,5));
		p0.setAlignmentX( 0.0f );
		p0.setMaximumSize( new Dimension(Short.MAX_VALUE,24) );

		JLabel l1 = new JLabel( "Prefix" );
		l1.setFont( FONT );
		p0.add( l1, "West" );

		autoPrefixNickField = new JTextField();
		autoPrefixNickField.setFont( FONT );
		p0.add( autoPrefixNickField, "Center");		
		panel.add( p0 );

		panel.add( createDummyPanel(5) );

		JPanel p3 = new JPanel(new BorderLayout(5,5));
		p3.setAlignmentX( 0.0f );
		p3.setMaximumSize( new Dimension(Short.MAX_VALUE,24) );

		JLabel l3 = new JLabel( "Postfix" );
		l3.setFont( FONT );
		p3.add( l3, "West" );

		autoPostfixNickField = new JTextField();
		autoPostfixNickField.setFont( FONT );
		p3.add( autoPostfixNickField, "Center");		
		panel.add( p3 );

		panel.add( createDummyPanel(10) );


		JPanel p1 = new JPanel(new BorderLayout(5,5));
		p1.setAlignmentX( 0.0f );
		p1.setMaximumSize( new Dimension(Short.MAX_VALUE,24) );

		JLabel l2 = new JLabel( "Access Password" );
		l2.setFont( FONT );

		autoNickPassField = new JTextField("jmsn");
		autoNickPassField.setFont( FONT );

		p1.add( l2, "West" );
		p1.add( autoNickPassField, "Center" );

		panel.add( p1 );

		panel.add( createDummyPanel(12) );

		JPanel p2 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 4, 4));
		p2.setAlignmentX( 0.0f );
		p2.setMaximumSize( new Dimension(Short.MAX_VALUE,32) );

		anStartButton = new JButton("Start");
		anStartButton.setFont( FONT );
		anStartButton.addActionListener( new ActionListener() {
			public void actionPerformed( ActionEvent e )
			{				
				try
				{
					AutoNickChangeServer.getInstance().start();

					anStopButton.setEnabled( true );
					anStartButton.setEnabled( false );
				}
				catch( Exception ex ) 
				{
					ex.printStackTrace();
				}
			}
		});
		anStopButton = new JButton("Stop");
		anStopButton.setFont( FONT );
		anStopButton.addActionListener( new ActionListener() {
			public void actionPerformed( ActionEvent e )
			{
				anStopButton.setEnabled( false );
				anStartButton.setEnabled( true );
				
				try
				{
					AutoNickChangeServer.getInstance().stop();
				}
				catch( Exception ex ) {}
			}
		});

		p2.add( anStartButton );
		p2.add( anStopButton );

		panel.add( p2 );

		return panel;
	}

	private JPanel createDummyPanel( int height )
	{
		JPanel d0 = new JPanel();
		d0.setAlignmentX( 0.0f );
		d0.setMaximumSize( new Dimension(Short.MAX_VALUE, height) );
		return d0;
	}

	private JPanel createBottomPanel()
	{
		JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 10,4));
		JButton confirmButton = new JButton(Msg.get("button.ok"));
		confirmButton.addActionListener( new ActionListener() {
			public void actionPerformed( ActionEvent e )
			{
				processConfirm();
			}
		});
		confirmButton.setFont( FONT );
		JButton cancelButton = new JButton(Msg.get("button.cancel"));
		cancelButton.addActionListener( new ActionListener() {
			public void actionPerformed( ActionEvent e )
			{
				dispose();
			}
		});
		cancelButton.setFont( FONT );
		bottomPanel.add( confirmButton );
		bottomPanel.add( cancelButton );
		return bottomPanel;
	}

    /**
     * 荤侩磊啊 犬牢 滚瓢阑 喘范阑锭, 泅犁 汲沥茄 沥焊甸 吝 康备焊粮秦具 且 蔼甸捞 乐促搁
     * 捞 皋家靛俊辑 葛滴 历厘窍霸 等促.
     * 拱沸 肺弊牢 登绢乐瘤 臼促搁 公矫窍绊 弊成 dispose 瞪 巴捞促.
     */
	private void processConfirm()
	{
		if( !msnm.isLoggedIn() )
		{
			dispose();
			return;
		}

		File downDir = new File( downField.getText() );
		downDir.mkdirs();
		File logDir = new File( chatlogField.getText() );
		logDir.mkdirs();

		boolean sndLogin = loginCheck.isSelected();
		boolean sndMessage = messageCheck.isSelected();
		boolean autoAccept = fileAutoAcceptCheck.isSelected();
        boolean tstampView = tstampCheck.isSelected();
		boolean emoticonView = emoticonCheck.isSelected();
		boolean useFixedFont = fixedFontFaceCheck.isSelected();

		LocalCopy local = msnm.getLocalCopy();
		local.setProperty( MainFrame.DOWNLOAD_PROP, downDir.getAbsolutePath() );
		local.setProperty( MainFrame.CHATLOG_PROP, logDir.getAbsolutePath() );
		local.setProperty( MainFrame.BACKIMAGE_PROP, bgImageField.getText() );
		local.setProperty( MainFrame.SOUND_LOGIN_PROP+".enable", String.valueOf(sndLogin) );
		local.setProperty( MainFrame.SOUND_MESSAGE_PROP+".enable", String.valueOf(sndMessage) );
		local.setProperty( MainFrame.AUTO_ACCEPT_FILE_PROP, String.valueOf(autoAccept) );
        local.setProperty( MainFrame.TIMESTAMP_DISPLAY, String.valueOf(tstampView) );
		local.setProperty( MainFrame.EMOTICON_DISPLAY, String.valueOf(emoticonView) );
		local.setProperty( MainFrame.BUDDYLIST_FONT_COLOR,
			 String.valueOf(colorButton.getBackground().getRGB()) );
		local.setProperty( MainFrame.USE_FIXED_CHAT_FONT, String.valueOf(useFixedFont) );
		local.setProperty( MainFrame.AUTONICK + ".enable", String.valueOf(!anStartButton.isEnabled()) );
		local.setProperty( MainFrame.AUTONICK + ".prefix", autoPrefixNickField.getText() );
		local.setProperty( MainFrame.AUTONICK + ".postfix", autoPostfixNickField.getText() );
		local.setProperty( MainFrame.AUTONICK + ".password", autoNickPassField.getText() );		
		local.storeInformation();

		MusicBox.setEnabled( MusicBox.SOUND_LOGIN, sndLogin );
		MusicBox.setEnabled( MusicBox.SOUND_MESSAGE_1, sndMessage );
		MusicBox.setEnabled( MusicBox.SOUND_MESSAGE_2, sndMessage );
		System.setProperty( "jmsn.file.auto.accept", String.valueOf(autoAccept) );

		try
		{
			if( msnm!=null && msnm.isLoggedIn() &&
				!initFriendlyName.equals(nickField.getText()) )
				msnm.setMyFriendlyName( nickField.getText() );

			File file = new File(bgImageField.getText());
			if( file.exists() )
			{
				ImageIcon icon = new ImageIcon( file.getAbsolutePath() );
				MainFrame.INSTANCE.buddies.setBackgroundImage( icon.getImage() );
			}
			else
				MainFrame.INSTANCE.buddies.setBackgroundImage( null );
		}
		catch( IOException e ) {}

		MainFrame.INSTANCE.buddies.renderer.setForeColor( colorButton.getBackground() );
		MainFrame.INSTANCE.buddies.repaint();	
		dispose();
	}

	private File selectDirectory( String current )
	{
		JFileChooser file = new JFileChooser(current);
		file.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );
		if( file.showOpenDialog(this)==JFileChooser.APPROVE_OPTION )
		{
			return file.getSelectedFile();
		}
		return null;
	}

	private File selectFile( String current, FileFilter filter )
	{
		JFileChooser file = new JFileChooser(current);
		file.addChoosableFileFilter( filter );
		file.setFileSelectionMode( JFileChooser.FILES_ONLY );
		if( file.showOpenDialog(this)==JFileChooser.APPROVE_OPTION )
		{
			return file.getSelectedFile();
		}
		return null;
	}

	/**
	 * Option Dialog啊 积己瞪锭 捞傈 汲沥蔼阑 阂矾坷绰 殿狼 霖厚累诀阑 茄促.
     * 措脚 捞矾茄 汲沥蔼甸篮 措何盒 荤侩磊喊肺 阿阿 历厘登绰 蔼捞骨肺,
     * 荤侩磊啊 肺弊牢登绢乐瘤 臼促搁, 措何盒狼 亲格阑 disable 惑怕肺 父电促.
	 */
	private void processReady()
	{
		if( msnm.isLoggedIn() )
		{
			this.initFriendlyName = msnm.getOwner().getFormattedFriendlyName();
			nickField.setText( initFriendlyName );
		}
		else
		{
			nickField.setText( Msg.get("label.login.please") );
			nickField.setEnabled( false );

			loginCheck.setEnabled( false );
			messageCheck.setEnabled( false );
			fileAutoAcceptCheck.setEnabled( false );

            tstampCheck.setEnabled( false );
			emoticonCheck.setEnabled( false );
			colorButton.setEnabled( false );
			fixedFontFaceCheck.setEnabled( false );

			findButton0.setEnabled( false );
			findButton1.setEnabled( false );
			findButton2.setEnabled( false );
			return;
		}

		LocalCopy local = msnm.getLocalCopy();

		boolean loginEnable = local.getPropertyBoolean(
			MainFrame.SOUND_LOGIN_PROP + ".enable", true);
		boolean messageEnable = local.getPropertyBoolean(
			MainFrame.SOUND_MESSAGE_PROP + ".enable", true);
		boolean fileAutoAccept = local.getPropertyBoolean(
			MainFrame.AUTO_ACCEPT_FILE_PROP, false);
        boolean tstampEnable = local.getPropertyBoolean(
            MainFrame.TIMESTAMP_DISPLAY, false);
		boolean emoticonEnable = local.getPropertyBoolean(
			MainFrame.EMOTICON_DISPLAY, true);
		boolean fixedFontEnable = local.getPropertyBoolean(
			MainFrame.USE_FIXED_CHAT_FONT, false);
		boolean autoNickEnable = local.getPropertyBoolean(
			MainFrame.AUTONICK + ".enable", false );

		loginCheck.setSelected( loginEnable );
		messageCheck.setSelected( messageEnable );
		fileAutoAcceptCheck.setSelected( fileAutoAccept );
        tstampCheck.setSelected( tstampEnable );
		emoticonCheck.setSelected( emoticonEnable );
		fixedFontFaceCheck.setSelected( fixedFontEnable );

		anStartButton.setEnabled( !autoNickEnable );
		anStopButton.setEnabled( autoNickEnable );

		String downdir = local.getProperty( MainFrame.DOWNLOAD_PROP );
		String logdir = local.getProperty( MainFrame.CHATLOG_PROP );
		String backImageFile = local.getProperty( MainFrame.BACKIMAGE_PROP, "" );
		String autoNickPrefix = local.getProperty( MainFrame.AUTONICK + ".prefix", "" );
		String autoNickPostfix = local.getProperty( MainFrame.AUTONICK + ".postfix", "" );
		String autoNickPass = local.getProperty( MainFrame.AUTONICK + ".password", "jmsn");

		new File(downdir).mkdirs();
		new File(logdir).mkdirs();

		downField.setText( downdir );
		chatlogField.setText( logdir );
		bgImageField.setText( backImageFile );

		autoPrefixNickField.setText( autoNickPrefix );
		autoPostfixNickField.setText( autoNickPostfix );
		autoNickPassField.setText( autoNickPass );

		String foreColor = local.getProperty( MainFrame.BUDDYLIST_FONT_COLOR, "000000" );
		colorButton.setBackground( new Color(Integer.parseInt(foreColor)) );
	}

	public void show()
	{
		processReady();
		super.show();
	}
}

⌨️ 快捷键说明

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