-
Bug
-
Resolution: Won't Fix
-
P5
-
None
-
1.1.2, 1.1.6, 1.1.7, 1.1.8, 1.2.1
-
generic, x86
-
generic, windows_nt
Name: joT67522 Date: 10/17/97
When adding a MouseListener to a Scrollbar object,
the only events passed up are mouse_pressed, and enter/exit.
This interferes with a component that wants to implement
two different paint operations based on whether the scrollbar
is tracking(partial repaint), or done tracking (full repaint).
i.e., you need to also receive the mouse_released event to
determine whether or not it is time to do the full repaint.
company - The Registry, Inc. , email - ###@###.###
======================================================================
Name: krT82822 Date: 07/29/99
Here is the code. If you run it, you will notice that the
scrollbar never throws a button released event.
It is very big flaw, and should be addressed immediatly.
/*
This simple extension of the java.awt.Frame class
contains all the elements necessary to act as the
main window of an application.
*/
import java.awt.*;
public class Frame1 extends Frame
{
public Frame1()
{
// This code is automatically generated by Visual Cafe when you add
// components to the visual environment. It instantiates and initializes
// the components. To modify the code, only use code syntax that matches
// what Visual Cafe can generate, or Visual Cafe may be unable to back
// parse your Java file into its visual environment.
//{{INIT_CONTROLS
setLayout(null);
setSize(405,305);
setVisible(false);
add(verticalScrollbar1);
verticalScrollbar1.setBounds(180,84,29,203);
setTitle("AWT Application");
//}}
//{{INIT_MENUS
//}}
//{{REGISTER_LISTENERS
SymWindow aSymWindow = new SymWindow();
this.addWindowListener(aSymWindow);
SymAction lSymAction = new SymAction();
SymMouse aSymMouse = new SymMouse();
verticalScrollbar1.addMouseListener(aSymMouse);
//}}
}
public Frame1(String title)
{
this();
setTitle(title);
}
/**
* Shows or hides the component depending on the boolean flag b.
* @param b if true, show the component; otherwise, hide the component.
* @see java.awt.Component#isVisible
*/
public void setVisible(boolean b)
{
if(b)
{
setLocation(50, 50);
}
super.setVisible(b);
}
static public void main(String args[])
{
try
{
//Create a new instance of our application's frame, and make it visible.
(new Frame1()).setVisible(true);
}
catch (Throwable t)
{
System.err.println(t);
t.printStackTrace();
//Ensure the application exits with an error condition.
System.exit(1);
}
}
public void addNotify()
{
// Record the size of the window prior to calling parents addNotify.
Dimension d = getSize();
super.addNotify();
if (fComponentsAdjusted)
return;
// Adjust components according to the insets
setSize(getInsets().left + getInsets().right + d.width, getInsets().top + getInsets().bottom + d.height);
Component components[] = getComponents();
for (int i = 0; i < components.length; i++)
{
Point p = components[i].getLocation();
p.translate(getInsets().left, getInsets().top);
components[i].setLocation(p);
}
fComponentsAdjusted = true;
}
// Used for addNotify check.
boolean fComponentsAdjusted = false;
//{{DECLARE_CONTROLS
java.awt.Scrollbar verticalScrollbar1 = new java.awt.Scrollbar(Scrollbar.VERTICAL);
//}}
//{{DECLARE_MENUS
//}}
class SymWindow extends java.awt.event.WindowAdapter
{
public void windowClosing(java.awt.event.WindowEvent event)
{
Object object = event.getSource();
if (object == Frame1.this)
Frame1_WindowClosing(event);
}
}
void Frame1_WindowClosing(java.awt.event.WindowEvent event)
{
// to do: code goes here.
Frame1_WindowClosing_Interaction1(event);
}
class SymAction implements java.awt.event.ActionListener
{
public void actionPerformed(java.awt.event.ActionEvent event)
{
Object object = event.getSource();
}
}
class SymMouse extends java.awt.event.MouseAdapter
{
public void mouseReleased(java.awt.event.MouseEvent event)
{
Object object = event.getSource();
if (object == verticalScrollbar1)
verticalScrollbar1_MouseReleased(event);
}
public void mousePressed(java.awt.event.MouseEvent event)
{
Object object = event.getSource();
if (object == verticalScrollbar1)
verticalScrollbar1_MousePressed(event);
}
}
void verticalScrollbar1_MousePressed(java.awt.event.MouseEvent event)
{
System.out.println("pressed");
}
void verticalScrollbar1_MouseReleased(java.awt.event.MouseEvent event)
{
System.out.println("released");
}
void Frame1_WindowClosing_Interaction1(java.awt.event.WindowEvent event)
{
try {
// Frame1 Hide the Frame1
this.setVisible(false);
System.exit(0);
} catch (Exception e) {
}
}
}
(Review ID: 93230)
======================================================================
Name: krT82822 Date: 07/29/99
The mouseReleased() method of MouseListener is not called
when the left mouse button is released on a Scrollbar that
has a MouseListener (see code below).
The mouseReleased() method is called if the right mouse button
is used, but not if the left mouse button is used.
The goal of using a MouseListener on the Scrollbar is to
find out when the user stops tracking (See bug 4052356).
When the code below is run and the scroll bar is clicked using
the right mouse button, the following is printed:
Mouse pressed
Mouse released
Mouse clicked
However, when the scroll bar is clicked using the left mouse
button, the following is printed:
Mouse pressed
------------------------------------
import java.awt.*;
import java.awt.event.*;
public class ScrollTest extends Frame implements MouseListener
{
Scrollbar sb;
Panel p;
public ScrollTest()
{
p = new Panel();
p.setLayout(new BorderLayout(0,0));
sb = new Scrollbar(Scrollbar.VERTICAL, 50,10,0,100);
p.add(BorderLayout.EAST, sb);
add(p);
sb.addMouseListener(this);
}
public void mouseClicked(MouseEvent e)
{
System.out.println("Mouse clicked");
}
public void mouseEntered(MouseEvent e)
{
// System.out.println("Mouse entered");
}
public void mouseExited(MouseEvent e)
{
// System.out.println("Mouse exited");
}
public void mousePressed(MouseEvent e)
{
System.out.println("Mouse pressed");
}
public void mouseReleased(MouseEvent e)
{
System.out.println("Mouse released");
}
public static void main(String[] args)
{
ScrollTest test = new ScrollTest();
test.setSize(200, 200);
test.show();
}
}
(Review ID: 93229)
======================================================================
- relates to
-
JDK-4034982 WinNT: Scrollbars don't receive mouseDragged events
-
- Closed
-
-
JDK-4088022 MouseEvents on a scroll bar are inconsistent between mouse buttons.
-
- Closed
-
-
JDK-4137888 PopupMenu is not working with 1.1.5 (while it is working fine with 1.1.4)!!!
-
- Closed
-
-
JDK-4318862 Mouse Events not triggered properly
-
- Closed
-
-
JDK-4052356 AWT Scrollbar does not support TRACK_ENDED event
-
- Closed
-