🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #10828

Can't change cursor

#10828
From: Dave Sowerby
Date: Sat, 07 Aug 1999 00:00
75 lines
2477 bytes
The simplest of problems ..

using setCursor appears to nothing whatsoever, ie.e the default cursor 
remains. To ensure I hadn't done somthing obscure, I generated a basic 
app using the wizard and added a couple of buttons to change cursor, but 
still nothing.  What have I missed?

The code:

package untitled3;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class Frame1 extends Frame {
	JButton jButton1 = new JButton();
	JButton jButton2 = new JButton();

	//Construct the frame
  public Frame1() {
		enableEvents(AWTEvent.WINDOW_EVENT_MASK);
		try  {
			jbInit();
		}
		catch(Exception e) {
			e.printStackTrace();
		}
	}

	//Component initialization
  private void jbInit() throws Exception  {
		jButton1.setText("jButton1");
		jButton1.setBounds(new Rectangle(4, 23, 115, 27));
		jButton1.addActionListener(new 
java.awt.event.ActionListener() {

			public void actionPerformed(ActionEvent e) {
				jButton1_actionPerformed(e);
			}
		});
		this.getContentPane().setLayout(null);
		this.setSize(new Dimension(400, 300));
		this.setTitle("Frame Title");
		jButton2.setText("jButton2");
		jButton2.setBounds(new Rectangle(263, 73, 137, 27));
		jButton2.addActionListener(new 
java.awt.event.ActionListener() {

			public void actionPerformed(ActionEvent e) {
				jButton2_actionPerformed(e);
			}
		});
		this.getContentPane().add(jButton1, null);
		this.getContentPane().add(jButton2, null);
	}

	//Overridden so we can exit on System Close
  protected void processWindowEvent(WindowEvent e) {
		super.processWindowEvent(e);
		if(e.getID() == WindowEvent.WINDOW_CLOSING) {
			System.exit(0);
		}
	}

	void jButton1_actionPerformed(ActionEvent e) {
    Cursor c=Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR);
    this.getContentPane().setCursor(c);
	}

	void jButton2_actionPerformed(ActionEvent e) {
    this.setCursor(Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR));

	}
}
Technical Details
Message-ID: <37ABE950.2F89@virgin.net>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,82b4f2c4612deaa1,start
X-Google-Attributes: gid111d45,public
From: Dave Sowerby <david.sowerby@virgin.net>
Subject: Can't change cursor
Date: 1999/08/07
Message-ID: <37ABE950.2F89@virgin.net>
X-Deja-AN: 509876978
Content-Transfer-Encoding: 7bit
Organization: Another Netscape Collabra Server User
Content-Type: text/plain; charset=us-ascii
Mime-Version: 1.0
Newsgroups: borland.public.jbuilder.java.swing