📄 sy02000c.java
字号:
package jm.form.gui.swing.game.sy.sy02;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.io.File;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JPanel;
import jm.framework.gui.PanelCtrlHandler;
import jm.framework.gui.module.JMIcon;
/**
* <p>Title: JM 整合Swing控件,使用配置信息</p>
* 发送文件
* <p>Copyright: Copyright (c) 2004-2006</p>
*
* <p>Company: 1SHome</p>
*
* <p>@author Spook</p>
*
* @since 1.3
* @see JDK 1.5.0.6
*/
public class SY02000C extends JPanel {
public static final String TYPE = "FILE";
PanelCtrlHandler ClosePanel = null;
private BorderLayout borderLayout1 = new BorderLayout();
private JButton CommandButton = new JButton();
JFileChooser Chooser = null;
File File_ = null;
private JLabel SendFileNameLabel = new JLabel();
public SY02000C (PanelCtrlHandler closePanel) {
try {
ClosePanel = closePanel;
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* 退出
* @param type String
*/
public void doClose (String type) {
this.setVisible(false);
ClosePanel.doClose(type);
}
/**
* 是否退出
* @return boolean
*/
public boolean getClose () {
return isVisible();
}
/**
* 设置显示信息(百分比)
* @param proress String
*/
public void loadProgress (String proress) {
SendFileNameLabel.setText(" 完成 " + proress);
SendFileNameLabel.setToolTipText("双击取消本次操作");
SendFileNameLabel.setToolTipText(File_.getPath());
CommandButton.setText("");
CommandButton.setPreferredSize(new Dimension(22, 1));
CommandButton.setToolTipText("取消本次操作");
CommandButton.setIcon(new JMIcon("image/button/cancel.gif"));
}
////////////////////////////////////////////////////////////////////////////
/**
* 配置画面
* @throws Exception
*/
private void jbInit () throws Exception {
this.setLayout(borderLayout1);
CommandButton.setContentAreaFilled(false);
CommandButton.addMouseListener(new MouseAdapter() {
public void mouseClicked (MouseEvent e) {
if (e.getButton() == MouseEvent.BUTTON3) {
doClose(TYPE);
}else {
doSelect(null);
}
}
});
loadButton();
SendFileNameLabel.addMouseListener(new MouseAdapter() {
public void mouseClicked (MouseEvent e) {
if (e.getClickCount() == 2) {
doClose(TYPE);
}
}
});
this.add(SendFileNameLabel, java.awt.BorderLayout.CENTER);
this.add(CommandButton, java.awt.BorderLayout.EAST);
}
/**
* 选择文件
*/
private void loadButton () {
SendFileNameLabel.setText(" ");
CommandButton.setText("选择文件");
CommandButton.setPreferredSize(new Dimension(80, 1));
CommandButton.setToolTipText("鼠标左击选择要发送的文件,鼠标右击取消本次操作");
CommandButton.setIcon(null);
}
/**
* 取消本次操作
*/
private void loadLabel () {
SendFileNameLabel.setText(File_.getName());
SendFileNameLabel.setToolTipText(File_.getPath());
CommandButton.setText("");
CommandButton.setPreferredSize(new Dimension(22, 1));
CommandButton.setToolTipText("取消本次操作");
CommandButton.setIcon(new JMIcon("image/button/cancel.gif"));
}
/**
* 初始化选择文件窗口
*/
private void loadChooser () {
Chooser = new JFileChooser();
}
/**
* 按钮点击
* @param e ActionEvent
*/
private void doSelect (ActionEvent e) {
if (File_ == null) {
if (Chooser == null) {
loadChooser();
}
int returnVal = Chooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File_ = Chooser.getSelectedFile();
loadLabel();
}
} else {
File_ = null;
doClose(TYPE);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -