Hello.....
I have a solution for you...
As per the check rules I can solve your first question ....
MythMouseListener.java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MythMouseListener extends JFrame implements
MouseListener
{
JTextArea t1;
JLabel l1;
String s;
public MythMouseListener() // constructor method
{
setTitle("My Mouse Listener"); // setting title to the frame
setSize(420,220); // setting size of the frame
getContentPane().setBackground(Color.CYAN); // setting backgroung
color
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null); // set no layout
// creating controls
t1=new JTextArea("Hello...How are you...?");
l1=new JLabel("");
// setting bounds to the controls
l1.setBounds(20,20,300,50);
t1.setBounds(20,80,360,80);
// adding controls
add(l1);
add(t1);
// adding mouse listener on JTextArea
t1.addMouseListener(this);
setVisible(true); // make frame visible
}
// overriding all mouse listener methods
@Override
public void mousePressed(MouseEvent e)
{
// TODO Auto-generated method stub
}
@Override
public void mouseReleased(MouseEvent e)
{
s=t1.getText().toLowerCase();
l1.setText(s);
}
@Override
public void mouseEntered(MouseEvent e) // when mouse entered on
jtextarea
{
s=t1.getText().toUpperCase(); // get data from jtextfield and make
it in uppercase
l1.setText(s); // display uppercase string in jlabel
}
// I am doing this mouseExited method also because i think this
is opposite operation of mouseEntered
// So if you want you can make this method empty
@Override
public void mouseExited(MouseEvent e)
{
s=t1.getText().toLowerCase(); / get data from jtextfield and make
it in lowercase
l1.setText(s); // display lowercase string in jlabel
}
@Override
public void mouseClicked(MouseEvent e)
{
// TODO Auto-generated method stub
}
public static void main(String args[])
{
new MythMouseListener(); // anonymous object of MythMouseListener
class
}
}
Output
C:\Users\AKSHAY\Desktop>javac MythMouseListener.java
C:\Users\AKSHAY\Desktop>java MythMouseListener


Thank you...
q2: Write a public class named MythMouseListener that implements the Mouselistener interface. This class will have...
Java question so right now this code is work perfectly the problem is I also want to know if possible to get the X and Y value outside the JFrame? import java.awt.FlowLayout; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.JFrame; import javax.swing.JLabel; public class MouseEventDemo extends JFrame implements MouseListener { //It is a class which generate a JFrame and implements MouseListener interface //These all are text that show x , y coordinates on mouse click event JLabel lclick; JLabel lpressed; JLabel lreleased;...
please write code in java, assignment is due soon Thanks. public interface Named The Named interface is a simple interface which applies to anything which has a name. The only thing required is the following method: String name() which returns the name of the instance. public interface MessageSink, It includes: void deliver(Named sender, String message) delivers the specified message from the given sender. public interface Sharable, which is Named, It includes no method. public abstract class GeneralCapability It incudes: The...
(The interface class-like) Assume you have the Edible interface with its abstract method. Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make implement the Edible interface. howToEat() and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML diagram for the classes and the interface 2. Use Arraylist class to create an...
Task 1: 1. Write a generic class named MyList, with a type parameter T. The type parameter T should be constrained to an upper bound: the Number class. The class should have as a field an ArrayList of type T. Write the class constructor to create the ArrayList. 2. Write a public method named add, which accepts a parameter of type T. When an argument is passed to the method, add it to the ArrayList. 3. Write a public method...
Create a data class named Automobile that implements the Comparable interface. Give the class data fields for make, model, year, and price. Then add a constructor, all getters, a toString method that shows all attribute values, and implement Comparable by using the year as the criterion for comparing instances. Write a program named TestAutos that creates an ArrayList of five or six Automobiles. Use a for loop to display the elements in the ArrayList. Sort the Arraylist of autos by...
Question: A. Write an Octagon class that inherits from GeometricObject and implements the Comparable interface, comparing the area of the shape. You can assume that all the sides are equal in length. B. Implement the Comparable interface in the Circle and Rectangle from Question2 comparing the area of each shape. (use the same classes in Question 2) C. Also add the overloaded toString() method to each class that prints a summary of the object. Then, in another class, create an...
Exercise 8 (The interface class-like) Assume you have the Edible interface with its abstract method Design a class named Animal and its two subclasses named Mammal and Dairy. Make Sheep and Bear as subclasses of Mammal and make Chicken and Cow as subclasses of Dairy. The Sheep and Dairy classes implement the Edible interface. howToEat) and sound() are the main two methods for all edible classes while sound() is the main method for the non-edible classes. 1. Draw the UML...
Define an interface named Shape with a single method named area that calculates the area of the geometric shape: public double area(); Next, define a class named Circle that implements Shape. The Circle class should have an instance variable for the radius, a constructor that sets the radius, an accessor and a mutator method for the radius, and an implementation of the area method. Define another class named Rectangle that implements Shape. The Rectangle class should have instance variables...
Java code please. Please help
* 95: Write a public class named TollInts with the following. * -A public constructor that takes 2 doubles as inputs. * -A public method named compute that takes no parameters and returns the the tangent of the * first constructor input subtracted by the the square root of the second constructor input * as a double. You will need to store the constructor input in instance variables to be able * to access them...
Consider the following Java interface. public interface Converter<A, B> { B convert(A xs); } (a) Write a default method convertAll in the interface Converter that takes ArrayList<A> xs as input and returns a new ArrayList<B>. If the ArrayList xs is [x1, : : :, xn], the method returns [convert(x1), : : :, convert(xn)]. In your method you may assume that xs is never null. If one of the calls to convert throws an exception, your method should not catch it....