Open any file or folder using Desktop class

Complete source code below will show you, how to open C:\ drive using Desktop class. Desktop class is only can get when you use jdk 6.

******************************************************************
COMPLETE SOURCE CODE FOR : OpenFileUsingDesktopClass.java
******************************************************************


/*
*If you want to use Desktop class,
*you must make sure that jdk version
*that you use is 6. This facilities
*is exist in jdk 6.
*/
import java.awt.Desktop;

import java.io.File;

public class OpenFileUsingDesktopClass
{
public static void main(String[]args)
{
try
{
//Open C:\ drive
//Make sure that you change \ to \\
//You can change to other file or folder that you want
//Example for file that you want to open:
//C:\Sunset.jpg
//So, change C:\\ below to
//C:\\Sunset.jpg
Desktop.getDesktop().open(new File("C:\\"));
}
catch(Exception exception)
{
exception.printStackTrace();
}
}
}


******************************************************************
JUST COMPILE AND EXECUTE IT
******************************************************************


Click here to download jdk6
Click here to download jdk6 documentation

Set JButton text color using UIManager

Complete source code below will show you, how to set JButton text color using UIManager. When you set JButton text color using this style, it will make all JButton in your program will have same text color. So, if you want to set only one text color for JButton, i suggest you click here.

**********************************************************************
COMPLETE SOURCE CODE FOR : SetJButtonForegroundColorUseUiManager.java
**********************************************************************


import javax.swing.UIManager;

import javax.swing.plaf.ColorUIResource;

import javax.swing.*;

import java.awt.*;

public class SetJButtonForegroundColorUseUiManager
{
public static void main(String[]args)
{
/*
*Create color base on RGB color model
*that will use as JButton foreground color.
*Red=255
*Green=0
*Blue=0
*/
Color foregroundColor=new Color(255,0,0);

//Set JButton foreground color
UIManager.put("Button.foreground",new ColorUIResource(foregroundColor));

//Create a window using JFrame with title ( Set JButton foreground color using UIManager )
JFrame frame=new JFrame("Set JButton foreground color using UIManager");

//Create two button
JButton button1=new JButton("Button 1");
JButton button2=new JButton("Button 2");

//Set JFrame layout to FlowLayout
frame.setLayout(new FlowLayout());

//Add created button into frame
frame.add(button1);
frame.add(button2);

//Set JFrame default close operation
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//Set JFrame size
frame.setSize(400,400);

//Make JFrame locate at center
frame.setLocationRelativeTo(null);

//Make JFrame visible
frame.setVisible(true);
}
}


**********************************************************************
JUST COMPILE AND EXECUTE IT
**********************************************************************

RELAXING NATURE VIDEO