/*
* Copyright (C) 2004 Sun Microsystems, Inc. All rights reserved. Use is
* subject to license terms.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the Lesser GNU General Public License as
* published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
* USA.
*/
import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Dimension;
import java.awt.Color;
import java.awt.Point;
import java.awt.Container;
import java.awt.Component;
import java.awt.Toolkit;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.tree.*;
import javax.swing.table.TableColumn;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
import java.io.IOException;
import java.io.File;
import org.jdesktop.jdic.desktop.*;
/**
* JDIC API demo main class.
* <p>
* The main class for the demo. Class <code>FileExplorer</code> creates a UI
* interface demonstrating the usage of the public API of <code>org.jdesktop.jdic.desktop.*
* </code> classes.
*/
public class FileExplorer extends JPanel {
public static ImageIcon computerIcon;
public static ImageIcon driverIcon;
public static ImageIcon folderIcon;
public static ImageIcon fileIcon;
public static ImageIcon browseIcon;
public static String MY_COMPUTER_FOLDER_PATH = System.getProperty("java.io.tmpdir")
+ File.separator + "My Computer";
// Currently selected tree node in the left disk tree.
public static MyTreeNode selectedTreeNode = null;
// Currently selected file in the right table.
File selectedFile = null;
BorderLayout borderLayout1 = new BorderLayout();
JPopupMenu jDesktopPopupMenu = new JPopupMenu();
JMenuItem jMenuItemOpen = new JMenuItem();
JMenuItem jMenuItemEdit = new JMenuItem();
JMenuItem jMenuItemPrint = new JMenuItem();
JMenuItem jMenuItemBrowse = new JMenuItem();
JMenuItem jMenuItemMail = new JMenuItem();
JSplitPane jSplitPane = new JSplitPane();
JTree jTreeDisk = new JTree(createTreeModel());
JScrollPane tableScrollPane = new JScrollPane();
MyTableModel tableModel = new MyTableModel();
MyTable jTable = new MyTable();
JPanel jAddressPanel = new JPanel();
JLabel jAddressLabel = new JLabel();
JTextField jAddressTextField = new JTextField();
JButton jBrowseButton = new JButton();
MyStatusBar statusBar = new MyStatusBar();
public FileExplorer() {
try {
System.setSecurityManager(null);
jbInit();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception e) {}
JFrame frame = new JFrame("JDIC API Demo - FileExplorer");
Container contentPane = frame.getContentPane();
contentPane.setLayout(new GridLayout(1, 1));
contentPane.add(new FileExplorer());
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
frame.pack();
frame.setVisible(true);
}
private void jbInit() throws Exception {
try {
computerIcon = new ImageIcon(FileExplorer.class.getResource("images/Computer.gif"));
driverIcon = new ImageIcon(FileExplorer.class.getResource("images/Driver.gif"));
folderIcon = new ImageIcon(FileExplorer.class.getResource("images/Folder.gif"));
fileIcon = new ImageIcon(FileExplorer.class.getResource("images/File.gif"));
browseIcon = new ImageIcon(FileExplorer.class.getResource("images/Right.gif"));
} catch (Exception e) {
System.out.println("ERROR loading image files !");
}
this.setLayout(borderLayout1);
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
this.setPreferredSize(new Dimension(screenSize.width * 4 / 5,
screenSize.height * 7 / 10));
jMenuItemOpen.setText("Open");
jMenuItemOpen.addActionListener(new
FileExplorer_jMenuItemOpen_actionAdapter(this));
jMenuItemEdit.setText("Edit");
jMenuItemEdit.addActionListener(new
FileExplorer_jMenuItemEdit_actionAdapter(this));
jMenuItemPrint.setText("Print");
jMenuItemPrint.addActionListener(new
FileExplorer_jMenuItemPrint_actionAdapter(this));
jMenuItemBrowse.setText("Browse");
jMenuItemBrowse.addActionListener(new
FileExplorer_jMenuItemBrowse_actionAdapter(this));
jMenuItemMail.setText("Mail to ...");
jMenuItemMail.addActionListener(new
FileExplorer_jMenuItemMail_actionAdapter(this));
jTreeDisk.addTreeExpansionListener(new
FileExplorer_jTreeDisk_treeExpansionAdapter(this));
jAddressLabel.setBorder(BorderFactory.createEmptyBorder(0, 4, 0, 4));
jAddressLabel.setToolTipText("");
jAddressLabel.setText("Address");
jBrowseButton.setBorder(BorderFactory.createCompoundBorder(new EmptyBorder(0,
2, 0, 2),
new EtchedBorder()));
jBrowseButton.setToolTipText("Browse the given URL with system default browser");
jBrowseButton.setIcon(browseIcon);
jBrowseButton.setText("Browse ");
jBrowseButton.addActionListener(new
FileExplorer_jBrowseButton_actionAdapter(this));
jAddressPanel.setLayout(new BorderLayout());
jAddressTextField.addActionListener(new
FileExplorer_jAddressTextField_actionAdapter(this));
jAddressPanel.add(jAddressLabel, BorderLayout.WEST);
jAddressPanel.add(jAddressTextField, BorderLayout.CENTER);
jAddressPanel.add(jBrowseButton, BorderLayout.EAST);
jAddressPanel.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
jTreeDisk.addMouseListener(new FileExplorer_jTreeDisk_mouseAdapter(this));
jTreeDisk.addTreeWillExpandListener(new
FileExplorer_jTreeDisk_treeWillExpandAdapter(this));
jTreeDisk.setCellRenderer(new MyTreeRenderer());
jTreeDisk.getSelectionModel().setSelectionMode
(TreeSelectionModel.SINGLE_TREE_SELECTION);
jTreeDisk.setSelectionRow(0);
jTreeDisk.setBackground(Color.white);
jTreeDisk.setAlignmentX((float) 0.5);
jTreeDisk.setShowsRootHandles(false);
jTreeDisk.addTreeSelectionListener(new
FileExplorer_jTreeDisk_treeSelectionAdapter(this));
jTable.setBorder(null);
jTable.setModel(tableModel);
TableColumn column = jTable.getColumnModel().getColumn(0);
column.setCellRenderer(new MyTableRenderer());
column = jTable.getColumnModel().getColumn(1);
column.setCellRenderer(new MyTableRenderer());
jTable.setShowHorizontalLines(false);
jTable.setShowVerticalLines(false);
jTable.addMouseListener(new FileExplorer_jTable_mouseAdapter(this));
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
jdic-0.9.4-bin-windows.zip (163个子文件)
ChangeLog 10KB
FileExplorer.class 16KB
FileTypes.class 11KB
Browser.class 8KB
Tray.class 7KB
FileChooser.class 6KB
SimpleBrowser.class 3KB
MyTableModel.class 3KB
MyTreeNode.class 2KB
Browser$2.class 2KB
MyUtility.class 2KB
Tray$3.class 1KB
SimpleBrowser$1.class 1KB
MyStatusBar.class 1KB
MyStatusBar.class 1022B
MyTableRenderer.class 889B
MyTreeRenderer.class 810B
DiskObject.class 547B
FileExplorer_jTreeDisk_treeWillExpandAdapter.class 539B
Tray$2.class 531B
Tray$1.class 503B
FileExplorer_jTable_mouseAdapter.class 496B
Browser_jAddressTextField_actionAdapter.class 487B
MyTable.class 483B
Browser_jForwardButton_actionAdapter.class 481B
Browser_jRefreshButton_actionAdapter.class 481B
Browser_jStopButton_actionAdapter.class 475B
Browser_jBackButton_actionAdapter.class 475B
Browser_jGoButton_actionAdapter.class 471B
FileExplorer_jTreeDisk_treeExpansionAdapter.class 465B
Browser$1.class 457B
FileTypes_jRadioButtonUnregisterUser_actionAdapter.class 423B
FileExplorer_jTreeDisk_treeSelectionAdapter.class 422B
FileTypes_jRadioButtonUnregisterSys_actionAdapter.class 421B
FileTypes_jRadioButtonRegisterUser_actionAdapter.class 419B
FileTypes_jRadioButtonRegisterSys_actionAdapter.class 417B
FileExplorer_jAddressTextField_actionAdapter.class 417B
FileChooser_jFileChooser_propertyChangeAdapter.class 417B
FileExplorer_jMenuItemBrowse_actionAdapter.class 413B
FileChooser_jCreateMailButton_actionAdapter.class 413B
FileExplorer_jMenuItemPrint_actionAdapter.class 411B
FileTypes_jAddNewActionButton_actionAdapter.class 409B
FileExplorer_jMenuItemOpen_actionAdapter.class 409B
FileExplorer_jMenuItemMail_actionAdapter.class 409B
FileExplorer_jBrowseButton_actionAdapter.class 409B
FileExplorer_jMenuItemEdit_actionAdapter.class 409B
FileTypes_jRadioButtonGetMime_itemAdapter.class 405B
FileChooser_jBrowseButton_actionAdapter.class 405B
FileChooser_jUrlTextField_actionAdapter.class 405B
FileTypes_jRadioButtonGetExt_itemAdapter.class 403B
FileChooser_jPrintButton_actionAdapter.class 403B
FileChooser_jOpenButton_actionAdapter.class 401B
FileChooser_jEditButton_actionAdapter.class 401B
FileTypes_jCancelButton_actionAdapter.class 397B
FileTypes_jApplyButton_actionAdapter.class 395B
MyUtility$FileSystemRoot.class 373B
FileExplorer_jTreeDisk_mouseAdapter.class 367B
FileExplorer$1.class 302B
FileChooser$1.class 301B
FileTypes$1.class 299B
COPYING 27KB
stylesheet.css 1KB
jdic.dll 108KB
WinMsiWrapper.dll 108KB
tray.dll 44KB
MozEmbed.exe 184KB
jnlp2msi.exe 56KB
IeEmbed.exe 52KB
duke.gif 5KB
Computer.gif 990B
Folder.gif 904B
File.gif 897B
Driver.gif 879B
middle.gif 235B
Right.gif 82B
Right.gif 82B
inherit.gif 57B
index-all.html 66KB
WebBrowser.html 49KB
Association.html 28KB
AssociationService.html 26KB
TrayIcon.html 25KB
WebBrowserEvent.html 23KB
Action.html 19KB
Message.html 19KB
Desktop.html 18KB
WebBrowserListener.html 18KB
Association.html 13KB
WebBrowserEvent.html 13KB
AssociationAlreadyRegisteredException.html 13KB
AssociationNotRegisteredException.html 13KB
serialized-form.html 13KB
WebBrowser.Status.html 13KB
AssociationException.html 13KB
WebBrowserUtil.html 12KB
RegisterFailedException.html 12KB
DesktopException.html 12KB
SystemTray.html 12KB
constant-values.html 12KB
DesktopException.html 11KB
共 163 条
- 1
- 2
资源评论
- xiaoyaofeng3452013-09-17很不错的资源,可以用。刚好要做swing内置浏览器,这个可以实现
- fengyanglu2015-01-06还不错,JDIC对复杂页面支持比别的要好!
Shenmike
- 粉丝: 1
- 资源: 3
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功