0

continue of above...post

in that example that i see the image.actaully i put it but its not work 4 me.

can u help me..i put my code here..

-----------------------------------
TransparentBackground.java
-----------------------------------

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

package swingdemo;
import java.util.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
*
* @author vinod
*/

public class TransparentBackground extends JComponent implements ComponentListener, WindowFocusListener,
Runnable,MouseListener {

private JFrame frame;
private Image background;
private long lastupdate = 0;
public boolean refreshRequested = true;

@Override
protected void processMouseEvent(MouseEvent e) {
JOptionPane.showMessageDialog(null, "processMouseEvent Called");
}

public TransparentBackground(JFrame frame) {
this.frame = frame;
updateBackground( );
frame.addComponentListener(this);
frame.addMouseListener(this);
frame.addWindowFocusListener(this);
new Thread(this).setPriority(Thread.MAX_PRIORITY);
new Thread(this).start( );
}

public void componentShown(ComponentEvent evt) {
// JOptionPane.showMessageDialog(null, "componentShown Data");
repaint( );
}
public void componentResized(ComponentEvent evt)
{
JOptionPane.showMessageDialog(null, "componentResized Called");
repaint( );
}
public void componentMoved(ComponentEvent evt)
{
JOptionPane.showMessageDialog(null, "componentMoved Called");
repaint( );
}
public void componentHidden(ComponentEvent evt)
{
// JOptionPane.showMessageDialog(null, "componentHidden Called");
}

public void windowGainedFocus(WindowEvent evt) { refresh( ); }
public void windowLostFocus(WindowEvent evt) { refresh( ); }

public void refresh( ) {
if(frame.isVisible( )) {
repaint( );
refreshRequested = true;
lastupdate = new Date( ).getTime( );
}
}

public void run( ) {
try {
while(true) {
Thread.sleep(250);
long now = new Date( ).getTime( );
if(refreshRequested &&
((now - lastupdate) > 1000)) {
if(frame.isVisible( )) {
Point location = frame.getLocation( );
frame.setVisible(false);
updateBackground( );
frame.setVisible(true);
frame.setLocation(location);
refresh( );
}
lastupdate = now;
refreshRequested = false; ...
0

Hi Ezzaral,

ya,u r right. i got one link after that post.

[url]http://www.onjava.com/pub/a/onjava/excerpt/swinghks_hack41/index.html?page=3[/url]

in this we take screenshot of and put it in background of our window.
and this process is continuosly work in thread.
ok it nice and some what help ful to me. but window is still not moving.

ok in one of the above post Mr.UNOwen's question was to change the shape of window.
i found one link 4 that.
plz check this.

[url]http://www-106.ibm.com/developerworks/java/library/j-iframe/[/url]

Thanking you,
Ajay Patel

0

Hello Mr.UNOwen,

I have same problem and i need solution if u got that.

I am creating one applet and i draw one object on it but

I want a window of applet in the shape of the objct that i draw on window.
i need that window transparent such that I can draw object such that it looks as though the window is in the shape of
that object.So is there a way to get what's displayed behind the window and display it.

Thanks,
[B]Ajay Patel[/B]