Examlex
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class JMouseActionFrame extends JFrame implements MouseListener
{
private int x, y;
private JLabel label = new JLabel("Do something with the mouse");
String msg = "";
public JMouseActionFrame()
{
setTitle("Mouse Actions"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout()); addMouseListener(this);
add(label);
}
public void mouseClicked(MouseEvent e)
{
int whichButton = e.getButton(); msg = "You pressed mouse ";
if(whichButton == MouseEvent.BUTTON1)
msg += "button 1.";
else
if(whichButton == MouseEvent.BUTTON2)
msg += "button 2.";
else
msg += "button 3.";
msg += " You are at position " +
e.getX() + ", " + e.getY() + ".";
if(e.getClickCount() == 2)
msg += " You double-clicked.";
else
msg += " You single-clicked.";
label.setText(msg);
}
@Override
public void mouseEntered(MouseEvent e)
{
msg = "You entered the frame.";
label.setText(msg);
}
@Override
public void mouseExited(MouseEvent e)
{
msg = "You exited the frame.";
label.setText(msg);
}
@Override
public void mousePressed(MouseEvent e)
{
}
@Override
public void mouseReleased(MouseEvent e)
{
}
@Override
public static void main(String[] args)
{
JMouseActionFrame mFrame = new JMouseActionFrame();
final int WIDTH = 750; final int HEIGHT = 300; mFrame.setSize(WIDTH, HEIGHT); mFrame.setVisible(true);
}
}
The above code shows a JMouseActionFrame application that demonstrates several of the mouse listener and event methods. The constructor sets a frame title by passing it to the parent of JMouseActionFrame , sets a close operation, sets the layout manager, enables the frame to listen for mouse events, and adds the JLabel to the JFrame . However, most of the action occurs in the mouseClicked() method. Describe what actions occur in this method.
Moving Average
A method that employs statistics to examine data over time by determining the means of various subsets within the full dataset.
Biodiesel Sales
The quantity of biodiesel fuel sold over a specific period, reflecting its market demand and adoption as an alternative energy source.
Moving Average
A statistical method used to analyze data points by creating a series of averages of different subsets of the full data set to identify trends.
Mattress Sales
The retail activity focused on selling mattresses to consumers, involving aspects of marketing, distribution, and product design specific to mattresses.
Q1: What does Glaucon want to demonstrate by
Q4: Utilitarianism is an egoistic moral theory.
Q5: A good paraphrase of Kant's second form
Q10: Which of the following describes a data
Q13: When, according to John Rawls, are economic
Q17: import java.nio.file.*; <br>import java.io.*; <br>import java.nio.channels.FileChannel; <br>import
Q17: Retributivists always support a lex talionis view
Q22: The cost benefit analysis is used by
Q22: FileSystems is a class that contains _
Q24: import javax.swing.*; <br>class FindPoints <br>{ <br> public