java Desktop 使用样例
来源:互联网 发布:java string 添加空格 编辑:程序博客网 时间:2024/06/05 11:43
package test;
import java.awt.Desktop;
import java.io.File;
import java.net.URI;
public class DeskTopTest {
private static Desktop desktop;
public static void main(String[] args) {
// browse();
edit();
open();
// print();
}
// 使用默认的浏览器打开网页
public static void browse() {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
try {
desktop.browse(new URI("www.baidu.com"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 使用设置的默认编辑器打开文件
public static void edit() {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
try {
desktop.edit(new File("D:\\DesktopTest.txt"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 使用系统默认的编辑器打开文件
public static void open() {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
try {
desktop.open(new File("D:\\DesktopTest.txt"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 使用配置的默认打印机打印文件
public static void print() {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
try {
desktop.print(new File("D:\\DesktopTest.txt"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
import java.awt.Desktop;
import java.io.File;
import java.net.URI;
public class DeskTopTest {
private static Desktop desktop;
public static void main(String[] args) {
// browse();
edit();
open();
// print();
}
// 使用默认的浏览器打开网页
public static void browse() {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
try {
desktop.browse(new URI("www.baidu.com"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 使用设置的默认编辑器打开文件
public static void edit() {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
try {
desktop.edit(new File("D:\\DesktopTest.txt"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 使用系统默认的编辑器打开文件
public static void open() {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
try {
desktop.open(new File("D:\\DesktopTest.txt"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
// 使用配置的默认打印机打印文件
public static void print() {
if (Desktop.isDesktopSupported()) {
desktop = Desktop.getDesktop();
try {
desktop.print(new File("D:\\DesktopTest.txt"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
0 0
- java Desktop 使用样例
- Desktop Java
- Google Desktop的使用
- Remote Desktop Manager使用
- Parallels Desktop怎么使用
- GitHub Desktop使用教程
- 使用github desktop
- GitHub Desktop的使用
- Java Desktop System
- Java Desktop开发资源- -
- Java Desktop开发资源
- solaris JAVA Desktop
- Java中的DeskTop类
- java.awt.Desktop 简介
- 开始使用 ubuntu 6.10 desktop
- 使用Communicator无法Share Desktop
- active desktop calendar 使用技巧
- ubuntu desktop下使用eclipse
- 博弈_总结
- Activity生命周期
- ubuntu桌面登录不上的故障解决:unable to connect to X server
- linux下获取cpu信息
- android之多媒体篇-录像
- java Desktop 使用样例
- 如何在XML中使用nbsp
- linux硬盘性能检测
- PD转换成PPT转换器的下载和使用
- 线段树_模板
- c:if 和c:when 的区别
- linux下log日志文件
- Android视图状态及重绘流程分析,带你一步步深入了解View(三)
- setProperty must be overridden by all subclasses of SOAPMessage 解决办法