How To Make KeyListerner Trigger When Not Focused
Apr 11, 2015I want the KeyListenerof my JFrame to trigger even when the windows is not focused.
View RepliesI want the KeyListenerof my JFrame to trigger even when the windows is not focused.
View RepliesCoding to show pop when focused on any button or text field...i want to show inf pop when we take mouse cursor on any button or field..want coding to be written in action performed in netbeans....
View Replies View RelatedI would like set a callback which is invoked when a MenuItem is focussed. Is there a way to do so?
View Replies View RelatedI am trying to style the TableCell that has focus in a TableView to simulate how Excel does it. Excel uses a white background with a 3px black border which seems to be centered on the nominal cell edges. That is (and this is issue I am having), the border extends outside of the nominal cell boundaries.
My first naive attempt was to to override the CSS for .table-cell as follows:
.table-cell:selected:focused
{
-fx-background-color: white;
-fx-text-fill: -fx-text-base-color;
[Code]....
Doing this fixed problem (1) from the first attempt since this approach tweaks the background colors without affecting overall TableCell size. However, it still puts the black border completely inside the cell. My attempt to set -fx-background-position to a negative value in an attempt to offset the background seems to be ignored.
Having done this before using a Flex AdvancedDataGrid, my solution was to add a layer on top of the grid which renders the focus rectangle. I wonder if I would have to do a similar thing here.
In this method, I tried to select the currently selected panel, then select the index 0 JPanel and re-select the current one to simulate the ChangeListener event, However, when the user comes back from a JDialog, I don't have this opportunity to do so, How do I trigger the ChangeListener of the tabbedPane (JTabbedPane) conveniently?
public void refreshPanels() throws SQLException, IOException {
parent.clearSelection();
centerPanel.removeAll();
// change data set first, if the JDialog
// is displayed however, since no more JPanels
[Code] .....
I have created a swing application which has a TrayIcon, this has one button that has the following code:
displayItem.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e) {
trayIcon.displayMessage("Hello Title","Hello World", TrayIcon.MessageType.WARNING);
}
});
[/highlight]
I have another class which I run via the following:
Thread counter = new Thread(new regCheck());
counter.start();
And within this "start" method I want to be able to wait 10 seconds and then trigger the popup that appeared within the original class. I think that the right method of achieving this is to create a function within my original class causes the popup.
public void display(String a, String b) {
trayIcon.displayMessage(a,b, TrayIcon.MessageType.WARNING);
}
However I have two issues here:
-firstly I dont know how to get the original trayIcon image from the method it was initialized into this new method.
-secondly I dont know how to trigger this event from the other class. Here is the method that I tried (but doesnt work)
window w = new window();
w.display("a","b");
This doesn't work because window's main begins to run and endlessly creates multiple windows and TrayIcons. What is the correct way to implement this sort of behaviour?
I have two classes. One constructs my a rectangle using Graphics2D (the class is called Rectangles). The second takes a user input for the triangle, which I am passing back to the first class. I am trying to trigger a repaint of class one from the action listener I have on a button in the second class. how to trigger this event?
View Replies View RelatedConsider this simplistic scenario,
tabbedPane.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
How do I trigger this listener, say when I return from a JDialog, I can't make this listener to swing into action even I tabbedPane.revalidate();
I've constructed 4 different levels and allow the user to select the level they want to play from a central JPanel in a Card Layout system. My problem is that once a level is completed, I can't switch the JPanel which is displayed to start the next level, since I don't know how to access the original JPanel which acts as a driver for the other panels.
MainFrame.java
Java Code: import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
[code]....
I want to read the contents of a log file present on the server, and trigger email along with the log file attached using JSP.
View Replies View RelatedWe are making a tic tac toe game for my CS120 class and I am having trouble figuring out how to make our X's and O's. Is there a way to make shapes besides making two lines for an X and an oval with a white smaller oval inside to make an O? We have only learned the basics so far in class (i.e. events, inheritance, client-supplier, etc.)
These are our instructions:
Write a controller that controls the game. There is one human player (the X player) and the computer player (the O player). The name of the class must be TicTacToeController. In a sense, the controller is the game since the controller will 1) create a TicTacToeModel 2) create a TicTacToeView and 3) create a TicTacToeButton (you must write this class following the design pattern covered in class lectures), a label, and text field such that when the button is pushed, the player moves into the cell selected by the text field. After every player move, the computer moves into a randomly selected empty cell. When the game is over, a text message must be displayed somewhere on the screen the gives the status of the game. While you are free to change the appearance of the controller, the basic elements must be provided (a view of the game, a button, and a text field to enter the cell). A sample screenshot is displayed below.And this is the code i have thus far:
[import java.awt.*;
import javax.swing.JFrame;
public class TicTacToeView extends Rectangle
public TicTacToeView(int x, int y, int w, int h) {
super(50,60,w,h);
this.setBackground(Color.red);
JFrame win = new JFrame("Tic Tac Toe");
win.setBounds(10,10,w+100, h+100);
win.setLayout(null);
win.setVisible(true);
win.setBackground(Color.gray);
[code]....
I want to ask how to make Palindrome in Java with 2 methods //Output is Like this
Input a word
Hey
Not a Palindrome
Reverse
yeH
I am stuck. I was trying to make my own Color to use with awt.
I used the statement :
public static final Color purple = new Color(255,0,255);
When I try to use Color.purple it says it cannot reference purple.
I first learned how to program with BYOB. In BYOB there were variables and lists. Variables worked the same as Java and lists were groups of variables. To create a list, I would give it a name. I could then add variables to this list as items throughout the program. Here's an example of what a list would look like:
[[List]]
item 1: Hello
item 2: world
I could then call upon item 1 or item 2 and delete them if needed. In Java, I want to have 3 lists of variables into which I put user input as variables. The code would look something like the following: (stuff with "//" at the end is detailing what I want to do, not actual working code)
import java.util.*;
public class Archives {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
[code]....
I do not know how to make the loop end. I think there is an issue with my second and thrid algorithms..Also its a commission calculator
--- Update ---
//Start Program
package commission;
import java.util.Scanner;
public class Commission
{
private static boolean saleTargetrange;
[code]....
Do I want to make something like this:
*****
*.....*
*.....*
*.....*
*****
I am stuck, I have made a code that creates this and don't know how to complete it.
*****
* *
* *
* *
*****
Code:
class Main {
public static void main( String args[] ) {
System.out.print("#Enter number of stars :");
int stars = BIO.getInt();
[Code] ....
I am currently in the progress of making a GUI for a project. I am trying to make a maze and I need it displayed in a GUI. So, I thought I would be able to do that with a text file that I created. The code I have for it so far runs and compiles but it is not displaying my text file as a GUI, even though it reads the file. All I get are a bunch of green rectangles. I am using Netbeans to code this
package rectangles;
import java.awt.Color;
import java.awt.Graphics;//this will draw the maze
import java.awt.Graphics2D;//
import java.io.BufferedReader;
import java.io.FileNotFoundException;//handles file
[code]....
public static final String NAME="JAVATAR";
"final" makes sure the constant has the same value and prevents it from being changed. So why add "static" to make it a constant. I figured the reason a few weeks back but don't remember it now.
I've been learning Java in school for lika a year now. Our teacher wanted us to make a game called "Game of Life" .Now it's not very optimized because the only type of GUI we know how to make it with JButtons so if I want a 100x100 grid that means the program has to load 10000 buttons and change text and color on them which I can imagen cause lags and so on but if we ignore that lagg our teacher wanted us to make it loop-able and well I kinda succeeded but the only problem is that I can't get it to wait between every loop so if I tell the program to loop 100 times, the program processes that and that takes forever and then updates the board and sometimes it takes forever and sometimes you cant even see the "cells" moving. Is it possible to get my program to loop and if so how? Here is the code:
//------------------------------------------------------------------------------------------------------------------------
// Hamta standardpaket
//------------------------------------------------------------------------------------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
[code]....
I needed to make a switch with a string ,but eclipse told met there was an error and that the fix was to switch to 1.7 compliant. I did so and now when i run my program errors come back.
Here are the errors :
Exception in thread "main" java.lang.UnsupportedClassVersionerror: start : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(ClassLoader.java:637)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
at java.net.URLClassLoader.access$000(URLClassLoader.java:58)
[code]....
I want to know how can I make a JPanel slide to to another JPanel (Slowly move to the next). I've made multiple JPanels so when I click on next it will take me to the next panel. Now I just need to add a nice transition to make my program look nicer. Is there an easy way to do it? or any way is fine I just want to add a transition ....
View Replies View RelatedI am having trouble making my image move to a certain position in a certain amount of time which is set inside a text file. I was wondering what I'm doing wrong and what I'm missing.
import java.io.*;
import java.util.*;
import java.io.FileReader;
public class Animator {
EZImage HP;
[code]....
First, I have a figure that moves around the screen. It uses keylisteners and just subtracts or adds pixels. However, I notice the movement is not smooth at all. It is very rigid and laggy movement. How can I make it smoother movement?
Second, you get three lives in the game. The lives are subtracting correctly, but I want the game to say "GAME OVER" on a dialog box. How would I get this to happen? My JFrame and my life int are in separate classes. I know I should use an if statement, saying if lives are at or less than zero, open the box, but how do I open the box?
Third, I want to display the time on the screen. I have a swing timer, but how do I put it on the screen? DrawString is not working for me.
Fourth, I want to set an icon for the game, the code is running, but not doing anything.
Java Code: frame.setIconImage(Toolkit.getDefaultToolkit().getImage("/Users/MW/Downloads/petericon.jpg")); mh_sh_highlight_all('java');
I was thinking to make a game where a button is appearing in random spots and you have to click it, and once you click it you're score goes up. But I don't know how to make the score appear in the JFrame, and I want the score to update everytime the Button is Clicked.
Here is the code:
Java Code:
package clickmegame;
import java.awt.Dimension;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
public class ClickMeGame {
public static void main(String[] args) {
[Code]...
I have an image that moves with arrow keys, and I want to make it appear to be moving. So, I made that image, and then another with the legs moved, to give the illusion of motion. I added it to an event
Java Code:
if (k == KeyEvent.VK_RIGHT) {
image1 = image6;
peterx = peterx + 10;
resetIt();
repaint();
} mh_sh_highlight_all('java');
But it only serves to change it once. How would I make it revert to the original frame once it is converted to the second frame (image 6)? I tried a gif but to no avail?
I got to make a java code for my class. I must make a calculator using stacks. I have a code but i got some mistakes. Here is the code
Java Code:
package stackscalc;
import java.util.Scanner;
import java.util.Stack;
import java.util.EmptyStackException;
class Arithmetic {
int length;
Stack stk;
String exp,
[Code] .....