📄 optiondialog.java
字号:
/* * @(#)OtionDialog.java * * Copyright (c) 2002, Jang-Ho Hwang * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * 3. Neither the name of the Jang-Ho Hwang nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $Id: OptionDialog.java,v 1.13 2004/08/04 07:05:49 xrath Exp $ */package rath.jmsn.ui;import java.awt.*;import java.awt.event.*;import javax.swing.*;import javax.swing.event.*;import javax.swing.filechooser.*;import java.io.File;import java.io.IOException;import rath.msnm.MSNMessenger;import rath.msnm.LocalCopy;import rath.msnm.entity.MsnFriend;import rath.msnm.PhotoFormatter;import rath.jmsn.ToolBox;import rath.jmsn.MainFrame;import rath.jmsn.NativeToolkit;import rath.jmsn.util.MusicBox;import rath.jmsn.util.Msg;import rath.jmsn.util.AutoNickChangeServer;/** * Option dialog. * * @author Jang-Ho Hwang, rath@linuxkorea.co.kr * @version $Id: OptionDialog.java,v 1.13 2004/08/04 07:05:49 xrath Exp $ */public class OptionDialog extends DefaultDialog implements ToolBox{ private JTextField nickField = null; private JTextField downField = null; private JTextField chatlogField = null; private JTextField bgImageField = null; private JButton findButton0, findButton1, findButton2; private JButton colorButton = null; private JCheckBox loginCheck = null; private JCheckBox messageCheck = null; private JCheckBox fileAutoAcceptCheck = null; private JCheckBox tstampCheck = null; private JCheckBox emoticonCheck = null; private JCheckBox fixedFontFaceCheck = null; private JCheckBox photoShowMe = null; private JCheckBox photoShowOther = null; private JTextField photoPath = null; private JButton photoChoose = null; private JLabel photoView = null; private Image photo; private MSNMessenger msnm = null; private String initFriendlyName = null; private JTextField autoPrefixNickField = null; private JTextField autoPostfixNickField = null; private JTextField autoNickPassField = null; private JButton anStartButton = null; private JButton anStopButton = null; public OptionDialog( Frame owner, MSNMessenger msnm ) { super( owner ); this.msnm = msnm; setTitle( Msg.get("title.option") ); createUI(); } private void createUI() { setSize( 400, 360 ); JPanel panel = (JPanel)getContentPane(); JTabbedPane pane = new JTabbedPane(); pane.setBorder( BorderFactory.createEmptyBorder(5,5,5,5) ); pane.add( createGeneralTab(), "General" ); pane.add( createMediaTab(), "Graphics" ); pane.add( createPhotoTab(), "Photo" ); pane.add( createAutoNickTab(), "Auto Nickname" ); panel.add( pane, "Center" ); panel.add( createBottomPanel(), "South" ); } public void useImage() { String path = photoPath.getText(); PhotoFormatter pf = new PhotoFormatter(); try { photoView.setIcon( new ImageIcon(pf.resize(new File(path))) ); } catch( IOException ex ) {} } private JPanel createPhotoTab() { JPanel panel = new JPanel(new BorderLayout(5,5)); panel.setBorder( BorderFactory.createEmptyBorder(10,10,10,10) ); JPanel top = new JPanel(); top.setLayout( new BoxLayout(top, BoxLayout.Y_AXIS) ); JLabel l0 = new JLabel(Msg.get("label.photo.title")); l0.setFont( FONT ); top.add( l0 ); top.add( createDummyPanel(5) ); photoPath = new JTextField(); photoPath.setEditable(false); photoPath.setFont( FONT ); photoChoose = new JButton(Msg.get("button.find")); photoChoose.setFont( FONT ); photoChoose.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { File dir = selectFile( photoPath.getText(), new FileFilter() { public boolean accept( File f ) { if( f.isDirectory() ) return true; String name = f.getName().toLowerCase(); if( name.endsWith(".gif") || name.endsWith(".jpg") || name.endsWith(".png") ) return true; return false; } public String getDescription() { return "Image Files (*.gif, *.jpg, *.png)"; } }); if( dir!=null ) { String path = dir.getAbsolutePath(); photoPath.setText( path ); photoShowMe.setSelected( true ); useImage(); } } }); JPanel p0 = new JPanel(new BorderLayout(4, 4)); p0.add( photoPath, "Center" ); p0.add( photoChoose, "East" ); p0.setMaximumSize( new Dimension(Short.MAX_VALUE, 24) ); p0.setAlignmentX( 0.0f ); top.add( p0 ); top.add( createDummyPanel(8) ); JPanel center = new JPanel(); center.setLayout( new BoxLayout(center, BoxLayout.Y_AXIS) ); photoShowMe = new JCheckBox(Msg.get("label.photo.show.me")); photoShowMe.setFont( FONT ); photoShowMe.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { if( !photoShowMe.isSelected() ) { photoView.setIcon( null ); } else { useImage(); } } }); photoShowOther = new JCheckBox(Msg.get("label.photo.show.other")); photoShowOther.setFont( FONT ); center.add( photoShowMe ); center.add( photoShowOther ); photoView = new JLabel(); photoView.setPreferredSize(new Dimension(98, 98)); photoView.setBackground( Color.white ); photoView.setBorder( BorderFactory.createLineBorder(Color.black,1) ); JPanel east = new JPanel(new BorderLayout()); east.add( photoView, "North" ); east.add( new JPanel(), "Center" ); panel.add( top, "North" ); panel.add( center, "Center" ); panel.add( east, "East" ); return panel; } private JPanel createGeneralTab() { JPanel panel = new JPanel(); BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS); panel.setBorder( BorderFactory.createEmptyBorder(10,10,10,10) ); panel.setLayout( layout ); /* Change the nickname */ JPanel nickPanel = new JPanel(new BorderLayout(5,5)); nickPanel.setMaximumSize( new Dimension(Short.MAX_VALUE, 24) ); nickPanel.setAlignmentX( 0.0f ); JLabel nickLabel = new JLabel( Msg.get("label.friendlyname") ); nickLabel.setFont( FONT ); nickField = new JTextField(); nickField.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { processConfirm(); } }); nickField.setFont( FONT ); nickPanel.add( nickLabel, "West" ); nickPanel.add( nickField, "Center" ); panel.add( nickPanel ); panel.add( createDummyPanel(5) ); /* Toggle who logined sound effect */ loginCheck = new JCheckBox(Msg.get("label.sound.login")); loginCheck.setFont( FONT ); /* Toggle whose message received sound effect */ messageCheck = new JCheckBox(Msg.get("label.sound.msg")); messageCheck.setFont( FONT ); /* Toggle File Auto Accept */ fileAutoAcceptCheck = new JCheckBox(Msg.get("label.file.auto.accept")); fileAutoAcceptCheck.setFont( FONT ); panel.add( loginCheck ); panel.add( messageCheck ); panel.add( fileAutoAcceptCheck ); panel.add( createDummyPanel(24) ); JLabel downLabel = new JLabel( Msg.get("label.folder.download") ); downLabel.setFont( FONT ); panel.add( downLabel ); JPanel downPanel = new JPanel(new BorderLayout(5,5)); downPanel.setAlignmentX( 0.0f ); downPanel.setMaximumSize( new Dimension(Short.MAX_VALUE,24) ); downField = new JTextField(); downField.setEditable( false ); downField.setFont( FONT ); findButton0 = new JButton( Msg.get("button.find") ); findButton0.setFont( FONT ); findButton0.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { File dir = selectDirectory( downField.getText() ); if( dir!=null ) downField.setText( dir.getAbsolutePath() ); } }); downPanel.add( downField, "Center" ); downPanel.add( findButton0, "East" ); panel.add( downPanel ); panel.add( createDummyPanel(5) ); JLabel logLabel = new JLabel( Msg.get("label.folder.chatlog") ); logLabel.setFont( FONT ); panel.add( logLabel ); JPanel logPanel = new JPanel(new BorderLayout(5,5)); logPanel.setAlignmentX( 0.0f ); logPanel.setMaximumSize( new Dimension(Short.MAX_VALUE,24) ); chatlogField = new JTextField(); chatlogField.setEditable( false ); chatlogField.setFont( FONT ); findButton1 = new JButton( Msg.get("button.find") ); findButton1.setFont( FONT ); findButton1.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { File dir = selectDirectory( chatlogField.getText() ); if( dir!=null ) chatlogField.setText( dir.getAbsolutePath() ); } }); logPanel.add( chatlogField, "Center" ); logPanel.add( findButton1, "East" ); panel.add( logPanel ); return panel; } private JPanel createMediaTab() { JPanel panel = new JPanel(); BoxLayout layout = new BoxLayout(panel, BoxLayout.Y_AXIS); panel.setBorder( BorderFactory.createEmptyBorder(10,10,10,10) ); panel.setLayout( layout ); JLabel bgImgLabel = new JLabel( Msg.get("label.buddy.backimg") ); bgImgLabel.setFont( FONT ); panel.add( bgImgLabel ); panel.add( createDummyPanel(5) ); JPanel bgImgPanel = new JPanel(new BorderLayout(5,5)); bgImgPanel.setAlignmentX( 0.0f ); bgImgPanel.setMaximumSize( new Dimension(Short.MAX_VALUE,24) ); bgImageField = new JTextField(); bgImageField.setFont( FONT ); findButton2 = new JButton( Msg.get("button.find") ); findButton2.setFont( FONT ); findButton2.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { File dir = selectFile( bgImageField.getText(), new FileFilter() { public boolean accept( File f ) { if( f.isDirectory() ) return true; String name = f.getName().toLowerCase(); if( name.endsWith(".gif") || name.endsWith(".jpg") ) return true; return false; } public String getDescription() { return "JPEG, GIF Files (*.gif, *.jpg)"; } }); if( dir!=null ) bgImageField.setText( dir.getAbsolutePath() ); } }); bgImgPanel.add( bgImageField, "Center" ); bgImgPanel.add( findButton2, "East" ); panel.add( bgImgPanel ); panel.add( createDummyPanel(4) ); JPanel buddyFontPanel = new JPanel(new FlowLayout(FlowLayout.LEFT,10,2)); buddyFontPanel.setAlignmentX( 0.0f ); buddyFontPanel.setMaximumSize( new Dimension(Short.MAX_VALUE,24) ); JLabel l0 = new JLabel( Msg.get("label.chooselistfont.color") ); l0.setFont( FONT ); colorButton = new JButton(""); colorButton.setOpaque(true); colorButton.setBorder( BorderFactory.createLineBorder(Color.black,1) ); colorButton.setPreferredSize(new Dimension(45,18)); colorButton.addActionListener( new ActionListener() { public void actionPerformed( ActionEvent e ) { Color c = JColorChooser.showDialog( OptionDialog.this, Msg.get("label.chooselistfont.color"), colorButton.getBackground() ); colorButton.setBackground( c ); } }); buddyFontPanel.add( l0, "Center" ); buddyFontPanel.add( colorButton, "East" ); panel.add( buddyFontPanel ); final NativeToolkit tk = NativeToolkit.getInstance(); if( tk.isWin2k ) { panel.add( createDummyPanel(10) ); JLabel l1 = new JLabel( Msg.get("label.transparent.level") ); l1.setFont( FONT ); panel.add( l1 ); JPanel sliderPanel = new JPanel(new BorderLayout(5,5)); sliderPanel.setAlignmentX(0.0f); sliderPanel.setMaximumSize( new Dimension(Short.MAX_VALUE, 30) ); final JSlider slider = new JSlider(30, 255); slider.setFont( FONT ); int value = Integer.parseInt(System.getProperty("jmsn.transparency", "255")); if( value!=-1 ) slider.setValue( value ); else slider.setEnabled( false ); slider.addChangeListener( new ChangeListener() { public void stateChanged( ChangeEvent e ) { int value = slider.getValue(); tk.makeTransparency( MainFrame.INSTANCE, value ); tk.makeTransparency( OptionDialog.this, value ); System.setProperty( "jmsn.transparency", String.valueOf(value) ); } }); final JCheckBox check = new JCheckBox( Msg.get("checkbox.use") );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -