📄 mediaconfigdialog.java
字号:
/*** $Id: MediaConfigDialog.java,v 1.4 2001/05/07 12:37:22 kunugi Exp $**** Copyright (c) 2000-2001 Jeff Gay** on behalf of ICEMail.org <http://www.icemail.org>** Copyright (c) 1998-2000 by Timothy Gerard Endres** ** This program is free software.** ** You may redistribute it and/or modify it under the terms of the GNU** General Public License as published by the Free Software Foundation.** Version 2 of the license should be included with this distribution in** the file LICENSE, as well as License.html. If the license is not** included with this distribution, you may find a copy at the FSF web** site at 'www.gnu.org' or 'www.fsf.org', or you may write to the** Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139 USA.**** THIS SOFTWARE IS PROVIDED AS-IS WITHOUT WARRANTY OF ANY KIND,** NOT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY. THE AUTHOR** OF THIS SOFTWARE, ASSUMES _NO_ RESPONSIBILITY FOR ANY** CONSEQUENCE RESULTING FROM THE USE, MODIFICATION, OR** REDISTRIBUTION OF THIS SOFTWARE. */package org.icemail.mail;import java.awt.Container;import java.awt.Dimension;import java.awt.GridBagConstraints;import java.awt.GridBagLayout;import java.awt.Frame;import java.awt.Insets;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JCheckBox;import javax.swing.JDialog;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JSeparator;import javax.swing.JTextField;import javax.swing.border.EmptyBorder; import org.icemail.util.AWTUtilities; import org.icemail.util.ComponentFactory; import org.icemail.util.JFCUtilities; import org.icemail.util.UserProperties; /** * A dialog which allows the media options to be configured. * The options are stored as part of the configuration properties. * * @see Configuration */public class MediaConfigDialog extends JDialog{ private JCheckBox incomingFlag_; private JTextField incomingPath_; /** * Construct a dialog for configuring media options. * * @param parent parent frame to return to after disposed */ public MediaConfigDialog( Frame parent ) { super( parent, true ); establishContents(); pack(); Dimension sz = getSize(); int w = UserProperties.getProperty( "mediaConfigDialog.width", sz.width ); int h = UserProperties.getProperty( "mediaConfigDialog.height", sz.height ); setSize( w, h ); setLocation( AWTUtilities.computeDialogLocation( this ) ); } private void establishContents() { setTitle( ICEMail.getBundle().getString( "MediaConfig.Title" ) ); Container cont = getContentPane(); cont.setLayout( new GridBagLayout() ); ActionListener xlistener = new IActionListener(); int row = 0; int cols = 3; JPanel rsrcPan = new JPanel(); rsrcPan.setLayout( new GridBagLayout() ); rsrcPan.setBorder( new EmptyBorder( 4, 4, 4, 4 ) ); AWTUtilities.constrain( cont, rsrcPan, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, 0, row++, 2, 1, 1.0, 0.0 ); int rsrcRow = 0; JLabel lbl; lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "MediaConfig.Event" ); lbl.setHorizontalAlignment( JLabel.LEFT ); AWTUtilities.constrain( rsrcPan, lbl, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, rsrcRow, 1, 1, 0.0, 0.0 ); lbl = ComponentFactory.getLabel( ICEMail.getBundle(), "MediaConfig.URL" ); lbl.setHorizontalAlignment( JLabel.LEFT ); AWTUtilities.constrain( rsrcPan, lbl, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, rsrcRow++, 2, 1, 1.0, 0.0 ); JSeparator sep = new JSeparator(); lbl.setHorizontalAlignment( JLabel.LEFT ); AWTUtilities.constrain( rsrcPan, sep, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 0, rsrcRow++, cols, 1, 1.0, 0.0 ); incomingFlag_ = ComponentFactory.getCheckBox( ICEMail.getBundle(), "MediaConfig.NewMail", false ); incomingFlag_.setHorizontalAlignment( JLabel.LEFT ); AWTUtilities.constrain( rsrcPan, incomingFlag_, GridBagConstraints.NONE, GridBagConstraints.WEST, 0, rsrcRow, 1, 1, 0.0, 0.0 ); incomingFlag_.setSelected( UserProperties.getProperty( Configuration.P_INCOMING_SOUND_FLAG, false ) ); incomingPath_ = ComponentFactory.getTextField( ICEMail.getBundle(), "MediaConfig.Path", null ); AWTUtilities.constrain( rsrcPan, incomingPath_, GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST, 1, rsrcRow, 1, 1, 1.0, 0.0 ); incomingPath_.setText( UserProperties.getProperty( Configuration.P_INCOMING_SOUND_URL, "" ) ); JButton b; b = ComponentFactory.getButton( ICEMail.getBundle(), "MediaConfig.Builtin", xlistener, null ); Insets i = b.getMargin(); i.top = i.left = i.bottom = i.right = 2; b.setMargin( i ); AWTUtilities.constrain( rsrcPan, b, GridBagConstraints.NONE, GridBagConstraints.CENTER, 2, rsrcRow++, 1, 1, 0.0, 0.0 ); JPanel btnPan = new JPanel(); btnPan.setLayout( new GridBagLayout() ); btnPan.setBorder( JFCUtilities.StandardBorder ); AWTUtilities.constrain( cont, btnPan, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, 0, row++, cols, 1, 1.0, 0.0 ); JButton btn; btn = ComponentFactory.getButton( ICEMail.getBundle(), "MediaConfig.Save", xlistener, null ); AWTUtilities.constrain( btnPan, btn, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, 0, 0, 1, 1, 1.0, 0.0 ); btn = ComponentFactory.getButton( ICEMail.getBundle(), "MediaConfig.Cancel", xlistener, null ); AWTUtilities.constrain( btnPan, btn, GridBagConstraints.HORIZONTAL, GridBagConstraints.CENTER, 1, 0, 1, 1, 1.0, 0.0 ); }//............................................................ private class IActionListener implements ActionListener { /** * Invoked when an action occurs. * <p> * Implementation of java.awt.event.ActionListener.actionPerformed() * * @param event the action event that occured */ public void actionPerformed( ActionEvent event ) { boolean disposeIt = false; String command = event.getActionCommand(); if ( command.equals( "SAVE" ) ) { boolean on = incomingFlag_.isSelected(); String path = incomingPath_.getText(); ICEMailMedia.setIncomingSound( on, path ); disposeIt = true; } else if ( command.equals( "CANCEL" ) ) { disposeIt = true; } else if ( command.equals( "BUILTIN" ) ) { incomingPath_.setText( UserProperties.getProperty( Configuration.P_INCOMING_SOUND_BUILTIN, "" ) ); } if ( disposeIt ) { dispose(); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -