Swing/AWT/SWT :: Scrolled Composite Doesn't Scroll By Mouse Wheel

Sep 7, 2014

Mouse wheel is working properly on macosx but not working on windows.

Here is my layout structure, i implemented mousewheel listener but its not triggering tho.

And my scrolledcomposite declaration:

final ScrolledComposite scrolledComposite = new ScrolledComposite(mainComposite, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
scrolledComposite.setExpandHorizontal(true);
scrolledComposite.setExpandVertical(true);
scrolledComposite.setBackground(SWTResourceManager.getColor(SWT.COLOR_MAGENTA));

final Composite listComposite = new Composite(scrolledComposite, SWT.NONE);
GridLayout layout = new GridLayout();

[Code] ...

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: How To Scroll Image

Sep 30, 2014

I have a java swing application.

1. The human user of my application asks it to fire up a scanner which scans a paper document. The document is a filled in form.
2. The application then displays the scanned image to the human user.The image is displayed in a JScrollPane since it may be larger than the scroll pane.
3. The human user needs to locate a certain item in the form, for example a social security number, and enter it into a field in a data entry screen.Note that the image and the field appear on the same screen.

Of-course the social security number always appears in the same location in the image. Also the image needs to be the appropriate magnification and resolution to allow the human user to easily read and understand the item he is searching for in the image.

What is the best way to present the scanned image to the user such that he immediately sees the item he requires and can enter it into the data entry field.

View Replies View Related

Swing/AWT/SWT :: Programmatically Scroll Up Or Down Jtable

Apr 17, 2014

I'm having serious issues right now with a JTable inside a JScrollPane.i have some methods that returns different indexes (rows) that i select programatically in a JTable and the problem is that sometimes it goes beyond of what i can see, like, the row gets selected but the scrollbar won't follow up.

i've searched up in google and saw several different methods but those were extremely complex and for stuff i don't need.the simplest solution i found is this:

tInfo.setRowSelectionInterval(searchIndexes.get(currentIndex), searchIndexes.get(currentIndex));
tInfo.scrollRectToVisible(tInfo.getCellRect(currentIndex, 1, true));

but it just doesn't do anything.My table (tInfo) has only two columns so no horizontal bars, just vertical. What can i do to align the scrollbar with the currently selected row in my table? :C

Found a solution using scrollPane.getVerticalScrollBar().setValue();in another thread, i didn't even notice there were like 3 more threads about the same, just different kind of code used in each.

View Replies View Related

Swing/AWT/SWT :: Scroll Pane Is Not Working

Sep 6, 2014

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
class Stock extends JFrame implements ActionListener

[code]....

well everything seems to be working fine only the scroll pane is not working.

View Replies View Related

Swing/AWT/SWT :: JFrame - Scroll Pane Is Not Working

Sep 5, 2014

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.sql.*;
class Stock extends JFrame implements ActionListener

[Code] ....

Everything is fine but the scroll pane is not working!

View Replies View Related

Array List Scrolled In Applet

Jan 6, 2015

I have to make an applet that uses an array to list 5 songs and the applet has to scroll the list of song titles, one at a time, each song title should start at the top of the applet and scroll to the middle then, scroll off the right hand side, each new song title should scroll in a different color, the applet should loop, when it gets to the end of the list, start over again at the beginning of the list. the code compiles fine put when I go to run the applet nothing shows up in it and a wall of text appears in the command prompt.

This is the code for the html

<html>
<body>
<applet code = "scroll.class" width=250 height=250>
</applet>
</body>
</html>
]

And this is the code for the program :

import java.awt.*;
import java.util.Random;
import java.awt.Color;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.Image;
public class scroll extends java.applet.Applet implements Runnable

[Code] ...

View Replies View Related

Swing/AWT/SWT :: Adjusting Size Of Box With Mouse

Oct 16, 2014

I'm running the code below which compiles ok using latest version of Java and on Sublime. The problem when it complies the output screen is blank and I can only see the text by adjusting the size of the box with my mouse - and then it colours in black. Code and screenshot below. Is there something wrong with the paint/graf part of the code?

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class BackArray extends JFrame {
int store[] = {2,6,4,8,34,67,19,99,10,12,89,68,45,37};
int xcoord = 100;
boolean firsttime=true;

[code]....

View Replies View Related

Swing/AWT/SWT :: Right Button Event Mouse In Jtable

Feb 18, 2014

I'm trying to can make right button event to show a popup of copy/paste in a jtable but I put these code and doesn't works:

public class UI implements ActionListener, DocumentListener, MouseListener{
private JFrame ventana;
private JTable table;
private JPanel panel;
private JScrollPane tableScrollPane;

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Paint Application - Mouse Events In Same Class

Apr 15, 2015

I have my paint application, i use the following mouse event to draw my shapes (mousePressed, mouseReleased, mouseDragged). Now after the user paint a circle for example, he must be able to drag the shape; to be able to do this. i think i must again implement the different mouse Events. I have done it and the drag is not working. How can i achieve this. can we implement multiple (mousePressed, mouseReleased, mouseDragged) in the same java class??

View Replies View Related

Swing/AWT/SWT :: Wait For Mouse Click Before Running While Loop

Oct 7, 2013

I've got the game working just fine, but I don't like the way it starts playing the second you hit the "Run Last Class" button in Eclipse, and would really like to have the game start, then wait for the user to click a button before running the core WHILE loop. Everything is implemented in a single class, and here is the playGame method that starts the ball moving:

private void playGame(){
while (!gameover){
moveBall();
checkForCollisions();
}

All I want to do is pause before the WHILE loop until the users clicks the mouse button, nothing fancier than that! I've done quite a bit of reading, and it looks like ActionEvent may be the way to go, but I'm not clear on how to use it correctly in this scenario.

View Replies View Related

Java Swing - Mouse Over To Highlight Desktop Icon

Jul 7, 2014

When we place the mouse cursor over an desktop icon it will get highlighted. How can I achieve this through java swings?

View Replies View Related

Swing/AWT/SWT :: Jscrollpane Not Shown Until Adjust Window Size With Mouse?

Nov 16, 2014

So for a test i have a small array set as a jlist which is the contents of my jscrollpane, and it appears as if nothing is there until i adjust the window size by dragging it out or in... whats going on?

Here is the full code

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;

[Code] ...

View Replies View Related

Swing/AWT/SWT :: Detecting Mouse Click Inside A Box Painted In Frame?

Feb 9, 2015

In the method mouseClicked(MouseEvent me) the co-ords of the click are obtained.

* if they are within the confines of the rectangle rect, console output System.out.println("inside box") is displayed
* in either case the click co-ords are displayed in the console

I'm getting the co-ords of the mouse clicks but no message when the click is inside the box

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
/*
Experiment 04 was successful. So now (Experiment 05) I must try and see if I can identify mouse clicks that occur within the rectangle.
*/

public class AFrame extends Frame implements MouseListener {
ARectangle rect;
public AFrame(ARectangle rect) {

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Continuous Flash When Moving Mouse Next To Text Of Button

Jan 27, 2015

Just run the following code and move the mouse next to the text of the button and you will see exactly what I am talking about. Any way to prevent this continuous flash?

import java.awt.Dimension;
import javax.swing.JButton;
public class GUI {
public static void main (String[] args) {
javax.swing.JFrame frame = new javax.swing.JFrame();
javax.swing.JPanel panel = new javax.swing.JPanel();

[Code] .....

View Replies View Related

Swing/AWT/SWT :: Making JButton That Switches Text From 2 JTextFields On Click With Mouse

Aug 6, 2014

I have made a window using JFrame and on my JPanel I have added 3 components: 2 JTextFields ("field1" and "field2") and inbetween them a JButton ("switch"). My goal is to switch the value of field1 to field2 and vice versa when the JButton is clicked. I thought this ActionListener which I have added to my JButton would achieve my goal:

public void actionPerformed(ActionEvent e) {
field2.setText(field1.getText());
field1.setText(field2.getText());
}

However, it changes the value of field2 into the value of field1 but not the other way around.

View Replies View Related

Swing/AWT/SWT :: Icons Should Drag Starting At Point Where Mouse Originally Clicked Down

Apr 23, 2014

I am working on a simple app that should emulate a desktop with some icons that you can drag around. I was instructed to use the MouseListener and MouseMotionListener. The icons should drag starting at the point where the mouse originally clicked down on it (ie not dragging from the top right corner).

I am drawing my icons to a jpanel, and I seem to be having two problems:The hitboxes are offThe icon is being dragged from the top right corner, despite having setup up a mouse offset at the beginning of the drag..Here are the relevant classes, the Desktop.draw() method is being called from my DrawPanel

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Desktop implements MouseListener, MouseMotionListener{
static DesktopIcon[] icons;

[code]...

View Replies View Related

Swing/AWT/SWT :: Doesn't Display Image

Mar 28, 2015

why this code, doesn't display the image?

import java.awt.Graphics;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

[code]...

View Replies View Related

Roulette Wheel Not Working Completely

May 7, 2014

package roulette;
import java.util.*;
public class Roulette {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);

[Code] ....

This is were its going wrong if i just do a straight "spin" it works but when i try and add additional bets into an array for future comparrison it simply kicks out to my "do" statements says you have quit and acts like i simply hit spin.

View Replies View Related

Swing/AWT/SWT :: Program Doesn't Close Through JDialog Box

Mar 30, 2014

I have a practice exercise here wherein I will add a JOptionPane to a program. When the close button is clicked, the JOptionPane will appear asking the user to exit the program. If the user clicks "Yes," it'll, of course, close the entire program and not just the JOptionPane, but if the user clicks "No," it will return to the program. Please refer to my code below:

try
{
output = new DataOutputStream(new FileOutputStream("ProjSixExe4.dat"));
}
catch(IOException ex) {
this.dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING))
}
final JOptionPane optionpane = new JOptionPane("Are you sure you want to quit
this program?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);

The exercise said it must be placed before the EXIT_ON_CLOSE portion.

View Replies View Related

Swing/AWT/SWT :: Child Window Doesn't Open

Mar 23, 2014

sale s = new sale();
jDesktopPane1.add(s);
s.show();

says not a suitable method?

View Replies View Related

Roulette Wheel Selection In Genetic Algorithm

Feb 7, 2014

I want java coding for roulette wheel selection in genetic algorithm with some explanation. I can't understand the algorithm clearly to implement in my project ...

View Replies View Related

Swing/AWT/SWT :: Replacing Regular Writing Cursor For System Mouse Pointer When Hovering JTextField?

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

Swing/AWT/SWT :: Window To Submit Data Freezing When Created Inside Mouse Clicked Event

Feb 18, 2014

I'm trying to right a GUI in swing, and as part of my program, I want to open a secondary window out of the main window when a mouse clicks on the main window. Then, once I click a button on the secondary window, I want that window to close and submit data to the main window (like an info form). I have almost figured out how to do this, except for one problem. By putting a variable inside my form window called "ready," and then in my main window running a loop that constantly checks if ready is true and doesn't proceed until its true, I can create the form window, modify the values in it (currently just one value called "difficulty" that's modified by a jSlider), and then when i click the "begin" button, ready is changed to true, the form window closes, and the main window can proceed. However, when I try to put the while loop checking the ready variable inside a mouseClicked method in the main window, the form window freezes when it opens, and you can't see any of its content or modify it in any way (you can't even close it).

Here is my code:

//form window class
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class formWindow extends JFrame {
private JTextField instructions1;

[Code]...

View Replies View Related

Swing/AWT/SWT :: Progress Bar Dialog Sometimes Doesn't Display Components

Mar 7, 2014

I wish to display a progress bar during a lengthy file translation process. When I created a ProgressBar class to do this and tested it with a short test program, it seemed to work fine. But when I add my ProgressBar class to a package containing various other classes, put that package in a jar file, and then execute the class using the progress bar from a menu in my main program, the frame of the progress bar shows up with the appropriate caption but the JLabel, JProgressBar, and JButton are not displayed. I have gone over my code numerous times and checked that the ProgressBar class constructor is getting the proper arguments.

// package gov.nasa.jpl.ephemeris;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
/**
* Progress bar with message text above the bar and a Cancel button below it
*/
public class ProgressBar extends JFrame {
private boolean _cancelled = false;
private JProgressBar _progressBar = null;

[Code] ....

I have also been wondering whether I need a separate instance of the border for each panel, or whether I can just create one instance and use it for all three panels.

View Replies View Related

Wheel Of Fortune - Guess Letters That Are Hidden In Characters

Jan 27, 2015

We have to make a wheel of fortune game. Once the above information has been taken, the game can commence. The board should look very similar to the example below if the above input was used. In order to get text to align correctly, use the System.out.format(…) method. It's 14 by 4, so would I use a 2D array? I think I can get the rest done by myself but it's the making of the board I'm having trouble with. Would I need to use a 2D array?

The board is supposed to look something like this to the viewer of the program, but they need to guess the letters that are hidden in the characters. :

* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *

These are the hidden values the viewer cannot see and must guess. Therefore, each turn they will guess a letter and the letter will the revealed if the one they said happens to be in the phrase. They will have to get STAR WARS EPISODE IV"

* S T A R * * * W A R S * *
* * E P I S O D E * I V * *
* * * * * * * * * * * * * *
* * * * * * * * * * * * * *

And the concealed letters; are Star Wars episode five a new hope. The # would mean where letters stand. So there first # would be S, the next would be T - and it would eventually spell out STAR WARS EPISODE IV.

So this is the board that's used to display the concealed letter, and there a list of the hidden letters below, like hangman.

import java.util.Scanner;
public class wheelof{
public static Scanner keyboard = new Scanner(System.in);
public static String puzzle1 = "";
public static String puzzle2 = "";
public static String puzzle3 = "";
public static String bonpuzzle = "";
public static String category1 = "";
public static String category2 = "";
 
[Code] ....

View Replies View Related

Swing/AWT/SWT :: Program Doesn't Close Though WindowClosing Event Called

Mar 25, 2014

I use the right term, release resources because after clicking the close button, the DOS prompts becomes unresponsive. So I have to close the DOS prompt, then reopen it, then type in the path again for the Java folders. Can you check where did I go wrong with my code? Is my placement of the WindowListener and WindowAdapter incorrect? Please refer to my code below:

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
public class Proj6exe1 extends JFrame implements ActionListener
{
DataOutputStream dataLabas;
JTextField rainFallField;
JButton submit;
String strRainFall;
JPanel proj6Panel;

[code]...

I have other programs where the placement of the WindowListener and WindowAdapter are as exactly like this (within the class constructor block) where they close correctly and some that behave like this, that renders the DOS prompt unresponsive.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved