Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.gui > #218
| From | "Rick" <rick@THRWHITE.remove-dii-this> |
|---|---|
| Subject | MouseListener - Changing |
| Message-ID | <1164700226.141122.130840@14g2000cws.googlegroups.com> (permalink) |
| Newsgroups | comp.lang.java.gui |
| Date | 2011-04-27 15:26 +0000 |
| Organization | TDS.net |
To: comp.lang.java.gui
Here is the code I have. Basically all I want to do is change the
background of the frame to black when I click the mouse (mouseClicked)
and change it back to white when I release the mouse (mouseReleased).
I can't access frame directly to do frame.setBackground(Color.BLACK),
and that is where I am stuck.
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class BackgroundChange extends JFrame
{
public BackgroundChange()
{
}
public static void main(String[] args)
{
BackgroundChange frame = new BackgroundChange();
frame.setTitle("Background Change");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300,300);
frame.setVisible(true);
frame.setBackground(Color.WHITE);
}
}
class BackgroundChangePanel extends BackgroundChange implements
MouseListener
{
public BackgroundChangePanel()
{
addMouseListener(this);
}
public void mouseClicked(MouseEvent e)
{
}
public void mouseEntered(MouseEvent e)
{
}
public void mouseExited(MouseEvent e)
{
}
public void mouseReleased(MouseEvent e)
{
}
public void mousePressed(MouseEvent e)
{
}
}
---
* Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24
Back to comp.lang.java.gui | Previous | Next — Next in thread | Find similar
MouseListener - Changing "Rick" <rick@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000 Re: MouseListener - Chang "Michael Rauscher" <michael.rauscher@THRWHITE.remove-dii-this> - 2011-04-27 15:26 +0000
csiph-web