Change Cursor On Mouseover A Rectangle
Jan 13, 2014
I want that the cursor change when the mouse is over one of the rectangles. Rectangles are displayed but nothing happens when the mouse is over.
class Resizing extends JPanel {
java.awt.List myGuiList = new java.awt.List();
java.util.List<Rectangle> paths = new ArrayList<Rectangle>();
public Resizing() {
paths.add(new Rectangle(100, 100, 75, 50));
paths.add(new Rectangle(200, 100, 75, 50));
[Code] .....
View Replies
ADVERTISEMENT
Jan 13, 2014
I want that the cursor change when the mouse is over one of the rectangles. Rectangles are displayed but nothing happens when the mouse is over.
class Resizing extends JPanel {
java.awt.List myGuiList = new java.awt.List();
java.util.List<Rectangle> paths = new ArrayList<Rectangle>();
public Resizing() {
paths.add(new Rectangle(100, 100, 75, 50));
paths.add(new Rectangle(200, 100, 75, 50));
[Code] ......
View Replies
View Related
Jan 17, 2014
I'm programming in school using Netbeans and we've just started with graphical programming (i.e JPanel, JClass, JFrame). This is my first assignment and the purpose of this program is that when you press the mouse you will fill 4 circles with diffrent colors. I've managed to draw 4 circles with diffrent colors but I want my cursor to change color simultaneously. Here's my code so far ....
//Java klass "Klick"
public class Klick {
//Medlemsvariabler.
private int x = 0;
private int y = 0;
private int r = 1;
public int antal = Rityta.antalKlick;
[Code]...
View Replies
View Related
Feb 24, 2014
I decided to change the mouse cursor based on the theme of the game. This is the code that I wrote for the declaration of the cursor:
ImageIcon imageIcon = new ImageIcon ("cursor / cursor.gif");
Image img = imageIcon.getImage ();
Toolkit t = Toolkit.getDefaultToolkit ();
Cursor cursor = t.createCustomCursor (img, new Point (0,0), "cur");
this.setCursor (cursor);
Having to click on different JButton in the menu of the game, a few screens later, I have to manage something in particular, such as determining the point of clicks that allows the action to take place?
In particular I would like to change the point of hotspots. The size of 136x163 is cursor.gif
Image - TinyPic - Servizio di hosting d'immagini, condivisione immagini & hosting di video gratuito
As you can see in the image I want to create the point of hotspots in the red dot of the image. How should I do to pass the correct coordinates in Point?
View Replies
View Related
Jun 9, 2014
What I'm trying to do is basically draw a Rectangle outline through left-click and then dragging the mouse to the size one wants.
After one has created this rectangle, the user can change the color of the rectangle through clicking the 3 sliders found on the top in the program. Upon the change in color, the rectangle should change from "g.drawRect" to "g.fillRect" and use the desired color.
I have the basic outline of the program done, but working with the last part (the color and changing of the Rectangle type after changing the color)
Is there like a "then" command in Java? Like: after you've done x, do y. That would make this heaps easier.
import java.awt.event.*;
import java.awt.*;
import java.applet.*;
//Diese Applikation offnet ein Fenster,
//in welchem durch einen gehaltenen linken Mouse Klick
//ein Reckteck gezeichnet wird
public class WhatIsTheProblem006 extends Applet
implements AdjustmentListener {
[Code] ....
View Replies
View Related
Jan 19, 2012
I set out to make a Tic-tac-toe (Cross and Noughts) game to test my learning so far. While things have gone pretty well so far, I am absolutely stumped by my current issue. When I compile and run the code, the Grid of buttons that I generate do not appear. However, if I mouse over the window, they seem to then get refreshed/repainted. I cannot for the life of me figure out why this is happening. From Googling the issue, it seems this is either an issue with the layout manager or related to a thread conflict with the GUI? [URL] ....
I'm listing out the code for the game class and the button class.
import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.util.*;
public class CrossNoughtsGame {
private JFrame frame;
private JPanel mainPanel;
private ArrayList<CNButton> buttonList = new ArrayList<CNButton>();
private boolean isX = true;
[Code] ....
View Replies
View Related
Dec 2, 2014
I am doing project on glossary in java. Basically what i need to do is, i have a case study in the text field, when i mouse over the certain text that i already store in database. The text will be highlighted and automatically display the tool tip and content the data that i stored in my database.
View Replies
View Related
Mar 30, 2015
I'm having issues with JButtons and painting methods, whenever I click a grid on the board, the buttons in the JPanel disappear. Here is the board class:
package GUI;
public class Board extends JPanel implements Observer {
/**
*
*/
// private static final long serialVersionUID = 1L;
private final int boardSizeX;
private final int boardSizeY;
private final int L = 20;
[Code] ....
I know the code is messy in places, this will be fixed later, just need some pointers on how to solve the JButton issue.
View Replies
View Related
Nov 4, 2014
I am developing an application where blind person can interact with computer i have completed the part where computer responds as per command given by user.The part where i am stuck is i want to give voice feedback as user moves the curser for example if mouse is on d drive then user should get feedback that its d drive....i want to do it for whole windows ...
View Replies
View Related
May 15, 2014
My problem is simple. Just set busy cursor on a scene. The scenarios is like this: I have simple application with a button on it. When I click the button, I will:
1. Set mouse cursor to BUSY
2. Do some work
3. Set mouse cursor back to DEFAULT.
I search the web and found some sample codes to set cursor. But they don't satisfy my need. So I wrote a simple application:
public class MainFormApp extends Application {
@Override
public void start(Stage stage) throws Exception {
stage.initStyle(StageStyle.DECORATED);
Pane root = new Pane();
root.setPrefSize(500, 300);
Button btn = new Button("Click me");
[Code] ....
When I run application and click the button, cursor does not change to BUSY. I also tried to use Platform.runLater() but no luck.
View Replies
View Related
Mar 25, 2014
I've been creating a digital clock using Java, and have made the mouse cursor invisible after a set period of time (40-seconds) and had the thought to make it visible again if mouse was moved.
Here's the code that makes it invisible:
ActionListener mouseTimeout = new ActionListener() {
public void actionPerformed(ActionEvent e) {
setCursor(blankCursor);
}
};
/* Make mouse cursor disappear after 40 seconds */
Timer mTimeout = new Timer(40000, mouseTimeout);
mTimeout.start();
And here is what I have so far for making it visible again:
MouseMotionListener mouse = new MouseMotionListener() {
@Override
public void mouseDragged(MouseEvent e)
{
}
@Override
public void mouseMoved(MouseEvent e)
{
}
};
I have tried using "setCursor(DEFAULT_CURSOR)" but NetBeans says that it "cannot find symbol" .....
View Replies
View Related
Sep 30, 2014
I have now slowly moving on the learning Database Connectivity.Found a simple example on one site and tried to execute it, Creating a database, connecting to it and displaying the output.
I am getting trouble with recordset in displaying all the records in the badabase. It displays the very first record correctly but if I try to enclose it in while(rs.next()) loop, it generates an error message saying "Invalid operation at current cursor position".
package database_console;
import java.sql.Statement;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.ResultSet;
[code]....
View Replies
View Related
Dec 7, 2014
This is my code. It is running great until I enter in the final color and hit enter. I get an Array Index out of bounds error, which I show at the bottom. I have fiddled with it, by moving the all answers correct into an if..else statement, hoping it would fix it. Needless to say, it didn't work.
Also, I am trying to figure out how to make the cursor appear in each guess box. It does in the first one, but after I hit enter, I have to click in the box each time to get one.
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class RobertMaloneChapter17 extends JFrame
{
//final variables to set the width and height of my frame
[Code] ....
My Errors:
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 5
at RobertMaloneChapter17$Listener.actionPerformed(RobertMaloneChapter17.java:67)
at javax.swing.JTextField.fireActionPerformed(JTextField.java:508)
at javax.swing.JTextField.postActionEvent(JTextField.java:721)
[Code] ....
View Replies
View Related
Jun 13, 2014
I know how add new button to HTMLEditor, and I want set to my button action to paste some text in the current cursor position.
//HTMLEditor html;//String IMAGE_URL = "http://...";Node node = html.lookup(".top-toolbar");
if (node instanceof ToolBar) { ToolBar bar = (ToolBar) node;
ImageView graphic = new ImageView(new Image(IMAGE_URL, 32, 32, true, true));
Button myButton = new Button("", graphic); bar.getItems().add(myButton);
myButton.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent arg0) {
//needs code
} });}
View Replies
View Related
May 21, 2015
I am working on a Java program that calls a stored procedure in an Oracle 11.2g database and retrieves a set of records via a ref cursor. The program follows the standard Connection/CallableStatement/ResultSet pattern. A ResultSet object is used to access and iterate through the returned cursor, processing each record in turn.
One of the database fields returned in the cursor is a CLOB, which I'm retrieving using the NClob class's getNClob() method. Two other methods - length() and getSubString() are then used to get the length of the CLOB and copy of it off to a String object respectively.
The problem is that these latter two method calls are relatively slow, taking around 80ms to complete for modestly sized CLOBs of, say, around 10KB in size.
Is this the most efficient way to access a CLOB and retrieve its contents? If so, is there anything I can do, to make it run faster?
View Replies
View Related
Mar 5, 2015
We are running a set of unit tests using the latest ojdbc 7 driver and the highest open cursor keeps going up, until it hits our 300 limit, then throws the cursor limit exception. If we run these tests using ojdbc 12.0.1.1, the highest open cursor stays at 17 and doesn't cause this exception.
The query used to monitor these cursors is below:
SELECT max(a.value) as highest_open_cur, p.value as max_open_cur FROM v$sesstat a, v$statname b, v$parameter p WHERE a.statistic# = b.statistic# and b.name = 'opened cursors current' and p.name= 'open_cursors' group by p.value
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
Java 8 version 31
View Replies
View Related
Jun 24, 2014
Tried creating a simple sample but all works as expected.
The following code prevents the cursor from moving when inside a cell of a JTable.
public void keyPressed(KeyEvent e) {
if ( (e.getKeyCode() == KeyEvent.VK_KP_LEFT) || (e.getKeyCode() == KeyEvent.VK_KP_RIGHT)
|| (e.getKeyCode() == KeyEvent.VK_RIGHT) || (e.getKeyCode() == KeyEvent.VK_LEFT) )
{
//Do nothing
e.consume();
}
}
});
When editing a cell, the existing code would use the right/left cursor keys to move from cell to cell as opposed to from character to character when editing a cell. I planned to override the functionality by tossing in the above code as a test to see if it stops the functionality before I override it.
After placing in the above code, the above functionality no longer occurs, but now the cursor moves within the cell as I wanted which is to move from character to character instead of cell to cell. Its great it works, but it really shouldn't. Essentially the default behavior has been restored when it should have really disabled the left/right keys.
I assume there is some underlying class someplace that is doing something to affect the behavior. Since a sample can't be provided I am wondering in what scenarios would the e.consume() restore default functionality?
View Replies
View Related
Apr 23, 2015
When I hover over a JTextField, I want to change the writing cursor from this to the system regular mouse pointer. How could I do it?
View Replies
View Related
Aug 31, 2014
I'm trying to create a cursor for a game that moves square by square. While it will move to the next square, though, it leaves the image of the previous cursor on the last square it was on.
As a visual explanation, this is what the program looks like on launch:
This is what it's suppose to look like after you press the right arrow key once (made by forcibly changing launch coordinates):
And this is what it actually looks like after you press the right arrow key once:
Here is the code for the program:
package cursortest;
import javax.swing.*;
import java.awt.*;
import javax.imageio.*;
import java.io.*;
import java.awt.event.*;
public class CursorTest extends JPanel implements KeyListener{
[Code] ......
I'm fully aware that I could just use g.clearRect on the area and remove it for sure, but I know for a fact I shouldn't have to as I have another program I made a long time ago that tried to do something similar without needing to resort to that.
View Replies
View Related
Apr 12, 2014
obstacleX = (int) (obstacleX - 0.1);
if(obstacleX <= 0){
obstacleX = 600;
}
repaint();
Thats my code, and the rectangle (ObstacleX is the X cordinate for the rectangle) goes fine on the first few times across the screen, then starts to go hyperspeed....
View Replies
View Related
Sep 17, 2014
I have to do the following: A bounding rectangle is the minimum rectangle that encloses a set of points in a two-dimensional plane. Write a method that returns a bounding rectangle for a set of points in a two-dimensional plane, as follows:
public static MyRectangle2D getRectangle(double[][] points)
The Rectangle2D class is defined in Programming Exercise 10.13. Write a test program that prompts the user to enter five points and displays the bounding rectangle's center, width, and height. Here is a sample run:
Enter five points: 1.0 2.5 3 4 5 6 7 8 9 10.The bounding rectangle's center (5.0, 6.25), width 8.0, height 7.5
This is my code so far, taking in account that Rectangle2D is already done in a previous problem.the thing is that i don't know if i have to erase public static void or do i leave it or how do i start it?
package theboundingrectangle;
import java.util.Scanner;
public static MyRectangle2D getRectangle(double[][] points)
public class TheBoundingRectangle {
public static void main(String[] args) {
// TODO code application logic here
}
}
View Replies
View Related
Apr 21, 2015
in order to speed up my application I want 'paintComponent(Graphics g)' to only write the visible area in my viewport. I can not find how to get that Rectangle from my JScrollPane.
View Replies
View Related
Jan 30, 2014
So I've been getting back into Java and downloaded eclipse back onto my laptop. However when I go to make a simple rectangle into a JFrame, the frame will pop up but no rectangle will be shown. Here is my main class, which sets up the JFrame...
mport javax.swing.JFrame;
public class Frame{
public static void main(String[] args) {
JFrame frame = new JFrame();
frame.setTitle("I hope this fucking works");
frame.setSize(400,400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
[code]....
View Replies
View Related
Apr 13, 2014
Is there a way to simply slap a rectangle into a JPanel (make it appear) with out creating an inner Class or helper Method, all within "Main"? And if not, why?
Making a JFrame is easy.
Adding a JPanel is a snap.
import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class TheJFrame {
public static void main(String[] args) {
// TODO Auto-generated method stub
[code]....
View Replies
View Related
Nov 14, 2014
MyGraphics worked before I added a background but, even now when I take the background away it isn't showing up.
package com.snow.game;
import javax.swing.*;
import java.awt.*;
class MyGraphics extends JComponent { //creating a class for graphics
public void draw(Graphics g){
//calling Graphics making a new graphics (g) now you can use it to make objects
g.drawRect(10, 10, 50, 50); //Draws a rectangle
[Code] ......
View Replies
View Related
Nov 7, 2014
I was tasked with building a program that, when is given a string by the user, takes it and prints it out as a rectangle. For example, if the user types in "COMPUTER", the output would be:
COMPUTER
OMPUTERC
MPUTERCO
PUTERCOM
UTERCOMP
TERCOMPU
ERCOMPUT
RCOMPUTE
So far, I have created 2 separate strings, and have gotten the output to look like:
COMPUTER
OMPUTERC
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
So, it works once, but then it doesn't work again. Here is my code:
i was tasked with building a program that, when is given a string by the user, takes it and prints it out as a rectangle. For example, if the user types in "COMPUTER", the output would be:
COMPUTER
OMPUTERC
MPUTERCO
PUTERCOM
UTERCOMP
TERCOMPU
ERCOMPUT
RCOMPUTE
So far, I have created 2 separate strings, and have gotten the output to look like:
COMPUTER
OMPUTERC
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
OMPUTERO
So, it works once, but then it doesn't work again. Here is my code:
import java.util.Scanner;
public class WordRectangle {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Scanner userInput = new Scanner (System.in);
[code]....
View Replies
View Related