Diplaying non-rectangular windows using java.

I am seeking some information regarding rendering of irregular shaped windows using java. Would like to know if its possible to achieve that using only java, if not then which tool can be used, so that my application can be used across platforms. I have gathered some information but most of the tools are not platform independent, most are useful only for windows, there is no mention of whether the tools will be helpful in UNIX etc. environment.
Awaiting reply,
Shweta.

hi,
you can create a component you like.you must override the paint method
and paint the component itself. the Graphics Object in paint give you some methods to paint lines,areas and colors.
the example paint a clock :
import java.awt.Container;
import java.util.Calendar;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.event.WindowListener;
import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.awt.event.ActionEvent;
import javax.swing.Timer;
import java.awt.Label;
import java.util.TimeZone;
import java.util.SimpleTimeZone;
public class Uhr extends java.awt.Frame implements WindowListener,ActionListener
//{{DECLARE_CONTROLS
Calendar cal=null;
int sec;
int minute;
int hour;
double Rh,Rm,Rs;
int nullx,nully,mx,my,Rk;
Timer timer=null;
Label lab=null;
public Uhr()
super();
//{{INIT_CONTROLS
setSize(200,200);
setLayout(null);
setTitle("Pit-Timer");
cal=Calendar.getInstance();
TimeZone tz = TimeZone.getDefault();//new SimpleTimeZone(1,"GMT");//;
// String [] tza=new String[128];
// tza=TimeZone.getAvailableIDs();
// for (int i=0;i<tza.length;i++)
// System.out.println(tza);
cal.setTimeZone(tz);
sec=cal.get(Calendar.SECOND);//0..59
minute=cal.get(Calendar.MINUTE); //0..59
hour=cal.get(Calendar.HOUR_OF_DAY);//0..23
lab=new Label("Time");
lab.setBounds(20,170,180,25);
add(lab);
addWindowListener(this);
timer=new Timer(1000,this);
timer.setRepeats(true);
timer.start();
Rk=getSize().width/2;
Rs=Rk*0.9;
Rm=Rk*0.8;
Rh=Rk*0.6;
mx=getSize().width/2;
my=getSize().height/2;
public static void main(String[] args)
(new Uhr()).setVisible(true);
public void paint(Graphics gr)
//zeichnen Hintergrund
gr.setColor(Color.red);
gr.fillArc(mx-Rk/2, my-Rk/2,Rk, Rk, 0, 360);
//zeichnen Stundenskala
gr.setColor(Color.darkGray);
for (double alpha=0;alpha<Math.PI*2;alpha+=Math.PI/6)
gr.drawLine( mx+(new Double (Rk/2*Math.cos(alpha))).intValue(),
my+(new Double (Rk/2*Math.sin(alpha))).intValue(),
mx+(new Double (Rm/2*Math.cos(alpha))).intValue(),
my+(new Double (Rm/2*Math.sin(alpha))).intValue());
sekunde(gr);
minute(gr);
stunde(gr);
super.paint(gr);
public void sekunde(Graphics gr)
double alpha;
int x,y;
gr.setColor(Color.blue);
alpha=(Math.PI/30*(sec-15));
x=(new Double (Rs/2*Math.cos(alpha))).intValue();
y=(new Double (Rs/2*Math.sin(alpha))).intValue();
gr.drawLine(mx,my,mx+x,my+y);
public void minute(Graphics gr)
double alpha;
int x,y;
gr.setColor(Color.green);
alpha=(Math.PI/30*(minute-15));
x=(new Double (Rm/2*Math.cos(alpha))).intValue();
y=(new Double (Rm/2*Math.sin(alpha))).intValue();
gr.drawLine(mx,my,mx+x,my+y);
public void stunde(Graphics gr)
double alpha;
int x,y;
gr.setColor(Color.yellow);
alpha=(Math.PI/6*(hour-3));
x=(new Double (Rh/2*Math.cos(alpha))).intValue();
y=(new Double (Rh/2*Math.sin(alpha))).intValue();
gr.drawLine(mx,my,mx+x,my+y);
public void actionPerformed(ActionEvent e)
if (e.getSource()==timer)
sec++;
lab.setText("Time : "+new Integer(hour).toString()+":"+new Integer(minute).toString()+":"+
new Integer(sec).toString());
if (sec==60)
sec=0;
minute++;
if (minute==60)
minute=0;
hour++;
if (hour==24)
hour=0;
repaint();
public void windowActivated(WindowEvent e){}
//Invoked when a window is activated.
public void windowClosed(WindowEvent e)
{//Invoked when a window has been closed.
timer.stop();
dispose();
System.exit(0);
public void windowClosing(WindowEvent e)
timer.stop();
dispose();
System.exit(0);}
//Invoked when a window is in the process of being closed.
public void windowDeactivated(WindowEvent e){}
//Invoked when a window is de-activated.
public void windowDeiconified(WindowEvent e){}
//Invoked when a window is de-iconified.
public void windowIconified(WindowEvent e){}
//Invoked when a window is iconified.
public void windowOpened(WindowEvent e){}
//Invoked when a window has been opened.
bye

Similar Messages

  • Non rectangular windows using Swing

    Hi everybody
    I've been trying to create a non rectangular window (i.e. an oval window) subclassing javax.swing.JWindow but even though the drawing of the inside of the window works correctly, the problem is with the outer part, which is painted anyway using the background color while I'd like to have it
    transparent so to simulate a real oval window.
    i.e. I'd like to have something like (dots are just fillings to give the drawing some shape):
    |. Transparent background...|
    | ..... ----------------------- .......... |
    | .... / Window ............... \ ....... |
    | .... \ contents .............. / ....... | <--- Window's bounds
    | ..... ----------------------- .......... |
    |_____________________|
    Any idea about how to prevent the background from being painted??
    Thanks in advance
    andrea

    Here is what I have done to overcome a similar problem.
    These two classes help me show a 'Bubble' popup similar to what Windows XP have
    You can tweak it like you want.
    /* Subclass of Window to show the Bubbles */
    public class WindowBubble extends Window{
    public WindowBubble(Frame owner, String text, Point startingPoint){
    super(owner);
    JBubble bubble = new JBubble(text, startingPoint);
    setLocation(startingPoint);
    add(bubble);
    pack();
    /* This code is based on SUN's examples of how to create Oval-Components */
    public class JBubble extends JLabel {
    int capWidth = 30;
    Point start;
    String label;
    BufferedImage image;
    public JBubble() {
    this("", null);
    public JBubble(String label, Point p) {
    this.label = label;
    start=p;
    try {
    Robot r = new Robot();
    image = r.createScreenCapture(new Rectangle(start.x,start.y, getPreferredSize().width, getPreferredSize().height));
    }catch(Exception e){
    e.printStackTrace();
    this.setHorizontalAlignment(JLabel.CENTER );
    public String getLabel() {
    return label;
    public void setLabel(String label) {
    this.label = label;
    invalidate();
    repaint();
    public void paint(Graphics g) {
    int width = getSize().width - 1;
    int height = getSize().height - 1;
    g.drawImage(image,0,0,this);
    Color interior;
    interior = (Color)UIManager.get("ToolTip.background") ;
    // ***** paint the interior of the button
    g.setColor(interior);
    // left cap
    g.fillArc(0, 0, // start
    capWidth, height, // size
    90, 180); // angle
    // right cap
    g.fillArc(width - capWidth, 0, // start
    capWidth, height, // size
    270, 180); // angle
    // inner rectangle
    g.fillRect(capWidth/2, 0, width - capWidth, height);
    // ***** highlight the perimeter of the button
    // draw upper and lower highlight lines
    g.setColor(Color.black);
    g.drawLine(capWidth/2, 0, width - capWidth/2, 0);
    g.drawLine(capWidth/2, height, width - capWidth/2, height);
    // upper arc left cap
    g.drawArc(0, 0, // start
    capWidth, height, // size
    90, 180-40 // angle
    // lower arc left cap
    g.drawArc(0, 0, // start
    capWidth, height, // size
    270-40, 40 // angle
    // upper arc right cap
    g.drawArc(width - capWidth, 0,// start
    capWidth, height, // size
    90-40, 40 // angle
    // lower arc right cap
    g.drawArc(width - capWidth, 0, // start
    capWidth, height, // size
    270, 180-40 // angle
    // ***** draw the label centered in the button
    Font f = getFont(); if(f != null) {
    FontMetrics fm =
    getFontMetrics(getFont());
    g.setColor(getForeground());
    g.drawString(label, width/2 - fm.stringWidth(label)/2, height/2 + fm.getHeight()/2 - fm.getMaxDescent() );
    public Dimension getPreferredSize() {
    Font f = getFont();
    if(f != null) {
    FontMetrics fm = getFontMetrics(getFont());
    return new Dimension(fm.stringWidth(label) + capWidth*2, fm.getHeight() + 10);
    } else {
    return new Dimension(100, 50);
    public Dimension getMinimumSize() {
    return new Dimension(100, 50);

  • Non-rectangular windows

    The issue is old and I know it is a very strong need of the Java community. That is:
    "Can I have non-rectangular windows in a Java application?"
    By non-rectangular windows I mean windows like those in WinAmp or RealOne skins, which have round edges and have all of the transparent areas below them working and active.
    In http://developer.java.sun.com/developer/bugParade/bugs/4479178.html it is stated that this will be fixed in Tiger release in 2004.
    Can anyone please give me any information about this?
    I believe a workaround would be to use Eclipse SWT, but I would prefer to stick to standard Java libraries. Is it possible?

    See this article:
    http://www.ibm.com/developerworks/java/library/j-iframe/

  • How to access a file in Unix server from windows using java

    I want to access a file in unix server from windows using java program.
    I have the following code. I am able to open the url in a web browser.
    String urlStr="ftp:user:passwd@unix-server:ftp-port//javatest/test.csv;type=i";
    URL url = new URL(urlStr);
    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream)));
    String inputLine;
    while((inputLine=in.readLine()))!=null){
    System.out.println(inputLine);
    in.close();
    I get the following error
    java.io.FileNotFoundException: /javatest/test.csv
    at sun.net.www.protocol.ftp.FtpURLConnection.getInputStream(FtpURLConnection.java:333)
    at java.net.URL.openStream(URL.java:960)
    at com.test.samples.Test.main(Test.java:45)

    urlStr="ftp:user:passwd@unix-server:ftp-port//javatest/test.csv;type=i";
    I have given the format of the urlStr that I am using in the code. The actiual values are used in my code. I have tried pasting this url in the browser and it opens the file.

  • How to trace changes in directories and files in windows using java.

    Hi,
    Want to know how to trace changes in directories and files in windows using java.
    I need to create a java procedure that keeps track of any changes done in any directory and its files on a windows System and save this data.
    Edited by: shruti.ggn on Mar 20, 2009 1:56 AM

    chk out the bellow list,get the xml and make the procedure.....     
         Notes          
    1     Some of the similar software’s include HoneyBow, honeytrap, honeyC, captureHPC, honeymole, captureBAT, nepenthes.     
    2     Some of the other hacking software’s include keyloggers. Keyloggers are used for monitoring the keystrokes typed by the user so that we can get the info or passwords one is typing. Some of the keyloggers include remote monitoring capability, it means that we can send the remote file across the network to someone else and then we can monitor the key strokes of that remote pc. Some of the famous keyloggers include win-spy, real-spy, family keylogger and stealth spy.          
    3     Apart from theses tools mentioned above there are some more tools to include that are deepfreeze, Elcomsoft password cracking tools, Online DFS, StegAlyzer, Log analysis tools such as sawmill, etc.

  • Running programs WINDOWS using java

    Hi ,
    I would appreciate if anyone could tell me how to run programs WINDOWS using JAVA language .Thank you.

    I am not quite sure what you mean by that, but if you want to execute a program use:
    Runtime.exec(String)

  • Access to installed device drivers on windows using Java?

    Is it possible to get access to installed device drivers on windows using java.

    Java has APIs for accessing the OS, The OS has APIs for accessing devices.
    Java does not have APIs for direct access to devices.
    However, depending on the device, you get what you want most of the time. You would only access the device directly if the device isn't supported by the OS or Java directly.
    Which device do you have in mind?

  • Get Native Java Window using Java Access Bridge 2.0.1 & Java 1.6 and above

    I want to get the native java window (Like Java Monkey Application and Java Ferret Application) using java only, for that I tried different ways/options but unable to get the native java window and perform actions on that.
    It would be really great if you could guide me for that. I am still unable to start the Java Access Bridge.
    Please let me know the steps to get native java window using Java Access bridge and JDK 1.6.20.
    Also Note that, As per your previous suggestion, I tried to search and call initializeAccessBridge() and shutdownAccessBridge(), But unable to succeed it. I did not find such method in Accessbridge.jar.
    Please help me out.
    Best Regards

    You might want to check out this thread:
    Java Access Bridge and JRE 1.6
    If you have Java 6, you'll need to manually install Java Access Bridge 2.0.1. The JAB 2.0.2 installer for Java 6 is also available as a beta:
    http://jdk6.java.net/6uNea.html

  • Manage Windows Using Java Application

    Hi,
    I am now developing a project, where we need to track the total time working.
    Eg. If i am working with outlook in my machine in various times, at the end, it should give me the total time of working with outlook.
    For this, i need to get the Windows ID (this case outlook). How can i access OS windows using java applications.
    Any idea how to do this???

    Hello,
    Syntax for Running report as JSP is as follow. The parameters can be passed by using "+" or "&".
    http://server.com/Employee.jsp?server=sac&destype=cache&desformat=html&userid=scott/tiger@database
    Use can pass reference parameters(user parameters)while ruuning the report.
    User can use User Parameters in his reports:
    "select * from emp where hiredate = :P_1"
    User can pass this parameter to Reports(while running it as JSP)as a parameter.
    http://server.com/Employee.jsp?server=sac&destype=cache&desformat=html&userid=scott/tiger@database&P_1=17-09-2000
    With Regards
    Sachin

  • Want to create a new folder in Windows using Java?

    Hello everyone!!!
    The situation is I want to create a folder using Java.
    What I am doing is I am asking client to upload files.If the client is uploading for the first time a new folder is created on the server side and all the files related with that client will be uploaded in that folder only.Can anyone help me with the code.I am using html for letting client select the file to be uploaded and jsp to upload the file .The server I am using is Tomcat5.5 and OS is Windows Xp.
    Please help me with the code or any alternate logic.
    Thanks in advance.

    create a java.io.File object for the path you'd like your directory to have and call .mkdir() on it (or mkdirs() if you need to create a hierarchy of directories).

  • New to Java Script(Want to open a new window using Java Script)

    Hi all,
    I am new to using Java Script. Now I have a HTML(First.html) page with a ADD button at the end of the page. What I want to know is, if I drag and select some part of the First.html and click on the ADD button a second HTML page(Second.html) should open displaying only the selected contents....
    Please help :-(

    myRef = window.open(self.location,'mywin',
    'left=20,top=20,width=500,height=500,toolbar=1,resizable=0');

  • Non-Rectangular JFrames using JNA or IBM IFrame

    Hi,
    I want to make a non-rectangular frame with round-shaped edges. I searched through this forum. But still unsuccessful. I can even go for a platform dependent solution. But i don't want to use Robot class which is taking screen-captures at interval or at system-events. This approach is very slower and faulty. Is anybody having experience in using JNA or IBM IFrame libraries (or any other approach) for this purpose?
    Thanks in advance,
    Sunil

  • Setting system properties of windows using java

    Hi,
    I am doing a project in networking using java in which i need to get and set Operating system(Windows) properties .
    I am able to do the GET part but i face problem in setting the system properties permanently.
    Please help me!.
    --Amy                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Is there any way of setting the properties other than employing the useo of JNI.

  • How to reboot windows using java program?

    Hi,
    If I want to reboot the windows by Java Program,How?
    Thank you!

    what about windows server 2003?
    Runtime.getRuntime().exec("shutdown -r
    ");it will work only for windows xp

  • How to set schedule task in windows using java code

    Hi,
    i want to set the schedule task in windows os using the java code can any one help me on that
    can any one thinks i need to wright a dll file for that which set the schedule task for me which dll i can use in my java code.
    thanks in advance.

    Maybe this will help you?

Maybe you are looking for

  • Looking for 30-pin female to lightning male extender

    I purchased an iHome clock radio with 30-pin dock back when I had an iPhone 4. Since upgrading to the iPhone 5 and then the iPhone 6+, I've been unable to use the dock. I'd like to find a 30-pin female to lightning male adapter, but I'd like one that

  • Batchwise Purchase Price

    Hi , We are in the business of Pharma Products Trading . Our prices are always batch dependent . Also our sales price changes batchwise. . In fact we have our sales price derived in reverse manner from MRP ( Max Retail Price ) . Is there any way to c

  • Could someone tell me how i can find the wifi ip on my macbook white. My macbook is version 10.6

    Could someone tell me how i can find the wifi ip on my macbook white. My macbook is version 10.6

  • Tv tuner reception problem

    I just bought a Pavilion dv4t-1300se with an integrated hdtv hybrid tuner. I used the provided antenna to scan for analog (ntsc) and digital (atsc) channels. I only got one very hazy analog channel. I researched a bit on the channels that I should be

  • Printer selection shuts down...

    I have 2 HP printers connected to my G4 laptop. First one is as PSP2355. The most recent one is D5160. Both worked fine when I added the D5160 about a week ago. When I went to print two days ago, no printers could be found. Did the utility, it saw th