09 dezembro 2008

Dicas rápidas

Splash Screen

Em linha de comando:

java -splash:images/nome_da_sua_imagem.extensao SplashDemo


No manifest.mf


Manifest-Version: 1.0
Main-Class: NomedaClasse
SplashScreen-Image: NomedaImagem.extensao


Aplicação no System Tray


import java.awt.*;

public class Teste
{
public static void main(String [] args) throws Exception{
SystemTray tray = SystemTray.getSystemTray();
Image image = Toolkit.getDefaultToolkit().getImage("image.gif");
tray.add(new TrayIcon(image));
}
}


Impressão


import java.io.File;

public class Teste
{
public static void main(String [] args) throws Exception{
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
desktop.print(new File("c:/seuarquivo.txt"));
}
}


Abrir browser default


import java.io.File;

public class Teste
{
public static void main(String [] args) throws Exception{
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
desktop.browse(new URI("http://www.site.com"));
}
}



Edição de arquivos


import java.io.File;

public class Teste
{
public static void main(String [] args) throws Exception{
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
desktop.edit(new File("c:/seuarquivo.txt"));
}
}


Cliente de e-mail padrão


import java.io.File;

public class Teste
{
public static void main(String [] args) throws Exception{
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
desktop.mail();
//ou
desktop.mail(new URI("mailto:nome@isp.com"));
}
}


Abrir arquivo


import java.io.File;

public class Teste
{
public static void main(String [] args) throws Exception{
java.awt.Desktop desktop = java.awt.Desktop.getDesktop();
desktop.open(new File("c:/seuarquivo.txt"));
}
}

Um comentário:

Fernando Scherrer disse...

Haw!

  Opa! Muito bom...!

Valewz!