|
Using OYOAHA
LookAndFeel:
| java.lang.Object |
| + |
javax.swing.LookAndFeel |
| |
+ |
javax.swing.plaf.basic.BasicLookAndFeel |
| |
|
+ |
javax.swing.plaf.metal.MetalLookAndFeel |
| |
|
|
+ |
com.oyoaha.swing.plaf.oyoaha.OyoahaLookAndFeel |
Constructor
public OyoahaLookAndFeel()
public OyoahaLookAndFeel(boolean enableRollover)
Methods
to set a MetalTheme:
public void setCurrentTheme(javax.swing.plaf.metal.MetalTheme
theme)
public void setCurrentTheme(java.io.File file)
public void setCurrentTheme(java.net.URL url)
public void setCurrentTheme(java.io.InputStream stream)
Methods to set a oyoaha theme:
public void setOyoahaTheme(java.io.File file)
public void setOyoahaTheme(java.net.URL url)
public void setOyoahaTheme(java.io.InputStream stream)
MetalTheme and OyoahaTheme can be used at same time.
By default rollover is enabled.
Some OyoahaTheme may use color and font information found
in MetalTheme.
For more information about MetalTheme look:
- the MetalLookAndFeel documention
- the MetalTheme documention
- the Metalworks demo from the JDK
To
use oyoaha lookandfeel without oyoaha theme:
import
com.oyoaha.swing.plaf.oyoaha.*;
import javax.swing.*;
try
{ |
| |
OyoahaLookAndFeel
lnf = new OyoahaLookAndFeel();
UIManager.setLookAndFeel(lnf); |
}
catch
(Exception e)
{
} |
To use
oyoaha lookandfeel with a oyoaha theme (*.otm) File:
import
com.oyoaha.swing.plaf.oyoaha.*;
import
javax.swing.*;
import java.io.*;
try
{ |
| |
File
file = new File(System.getProperty("user.dir"),
"gang.otm");
OyoahaLookAndFeel lnf = new OyoahaLookAndFeel();
if(file.exists())
lnf.setOyoahaTheme(file);
UIManager.setLookAndFeel(lnf); |
}
catch
(Exception e)
{
} |
To use
oyoaha lookandfeel with a oyoaha theme loaded from resource:
import
com.oyoaha.swing.plaf.oyoaha.*;
import javax.swing.*;
import java.net.*;
try
{ |
| |
OyoahaLookAndFeel
lnf = new OyoahaLookAndFeel();
URL url = getClass().getResource("gang.otm");
lnf.setOyoahaTheme(url);
UIManager.setLookAndFeel(lnf); |
}
catch (Exception
e)
{
} |
To use
oyoaha lookandfeel with a oyoaha theme and a MetalTheme loaded
from resource:
import
com.oyoaha.swing.plaf.oyoaha.*;
import javax.swing.*;
import java.net.*;
try
{ |
| |
URL
url = getClass().getResource("pink.theme");
OyoahaLookAndFeel.setCurrentTheme(url); OyoahaLookAndFeel
lnf = new OyoahaLookAndFeel();
url = getClass().getResource("gang.otm");
lnf.setOyoahaTheme(url);
UIManager.setLookAndFeel(lnf); |
}
catch
(Exception e)
{
} |
Here's
a code snippets which is provided by Bradlee bradleej@austin.rr.com,
thanks to him :-)
It's for use in an application environment, a properties file
which allows changing the runtime look without recompiling
the application. Basically the properties file looks like
this:
tgang.otm
// Copy and paste one of the following values to use that
theme
//Valid valudes for the first line are:
zipper.otm
slushy.otm
tgang.otm
flat1.otm
anidaisy.otm
At the top line, before the comment, tgang.otm is being specified
as the current look and feel. All that is required to change
that is for the user to select one of the other otm names
listed and cut & paste that to the first line.
import
com.oyoaha.swing.plaf.oyoaha.*;
import javax.swing.*;
//----------------------------------------------------------------------
/** Main path
*
*/
private static final String THEME= "com" + File.separator
+ "myapplication" + File.separator + "themes"
+ File.separator;
//----------------------------------------------------------------------
//Set the look and feel of the frame.
private void setLookAndFeel()
{ |
| |
try
{ |
| |
OyoahaLookAndFeel
lnf = new OyoahaLookAndFeel();
URL url = new File(THEME+getLookAndFeel()).toURL();
lnf.setOyoahaTheme(url);
UIManager.setLookAndFeel(lnf); |
}
catch
(Exception e)
{
} |
|
}
//----------------------------------------------------------------------
/** Read the specified look and feel from the properties
file...
*/
//----------------------------------------------------------------------
private String getLookAndFeel()
{ |
| |
BufferedReader
in=null;
String LandF=null;
try
{ |
| |
in
= new BufferedReader(new InputStreamReader(new FileInputStream(new
File(PATH+"lookandfeel.properties"))));
LandF = in.readLine();
in.close(); |
}
catch
(Exception e)
{
}
return LandF; |
|
| } |
|