1. KeyListener Stops Working coderanch.compackage frames; import java.awt.Color;import java.awt.Dimension; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JFrame; public class Main extends JFrame implements KeyListener { public Main() { super(); Desktop desktop=new Desktop(); desktop.setPreferredSize(new Dimension(300,200)); desktop.setBackground(Color.BLUE); this.addKeyListener(this); this.setTitle("JFrame"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setResizable(false); this.getContentPane().add(desktop); this.pack(); this.setVisible(true); } public static void main(String[] args) { new Main(); } public void keyPressed(KeyEvent e) { System.out.println("KEY PRESSED !!!!!!!!"); } public void keyReleased(KeyEvent e) {} public ... |
2. Listener Problem on TableItem coderanch.comHi all, I have a table with tableItems and each tableItem registers two Listeners: ti.addListener(SWT.MouseHover, getTableListener()); ti.addListener(SWT.MouseMove, getTableListener()); Further I have a handleEvent(), like this: private Listener getTableListener() { if(this.userTableItemListener != null) { return userTableItemListener; } else { userTableItemListener = new Listener() { public void handleEvent(Event event) { Shell tip = null; Label label = null; switch(event.type){ case SWT.MouseMove: { if ... |
3. want to implement keylistener coderanch.com |
4. mouse adapter & mouse listener coderanch.com |
5. Item Listener Problem coderanch.com |
6. key listener not detected coderanch.comHi, I have one more query in this. I have got the required action implemented when "F1" is pressed with getInputMap()and get getActionMap() as suggested by you. But the problem is that, I am opening a Help screen when "F1" is pressed. This help screen cannot be accessed until I press OK/Cancel or close the MyDialog which detects the key bindings. ... |
7. Regarding KeyListener coderanch.com |
8. Regarding Listener coderanch.comReposting with proper code tags as the original poster is probably too busy for such trivia ftf = new JTextField(20); ftf1 = new JTextField(20); froll = new JLabel("Roll No"); fname = new JLabel("Name"); find = new JButton("Find"); //tb = new JTable(); //ta = new JTextArea(10,10); GroupLayout gl5 = new GroupLayout(jp5); jp5.setLayout(gl5); gl5.setAutoCreateGaps(true); gl5.setAutoCreateContainerGaps(true); >>>>>>>>>>>>>>>gl5.setHorizontalGroup(gl5.createSequentialGroup()<<<<<<<<<<< .addGroup(gl5.createParallelGroup(LEADING) .addComponent(froll) .addComponent(fname)) .addGroup(gl5.createParallelGroup(LEADING) .addComponent(ftf) .addComponent(ftf1) .addComponent(find, ... |
9. Regarding Listener coderanch.com |
10. Issue with Listener coderanch.comHello , i am new to Swing Programming. I am facing a problem in providing listener for my JPanel . My panel consists of nearly 30 TextFields and 4 ComboBox Components , I am having a requirement in such a way that what ever the change that is going to happen in the panel components it should be listened by one ... |
11. beginner / mouse listener, ears are plugged coderanch.comI've read alot of code on mouse listeners, and I'm still stuck I've created a rectangle, and when the mouse is inside, and I click, I should see a response in the rectangle, but I don't? thanks for your time heres some of the code import acm.graphics.*; import acm.program.*; import acm.util.*; import java.applet.*; import java.awt.*; import java.awt.event.*; public class Breakout extends ... |
12. swing: listener/oberver coderanch.comI have a standalone runnable class ("extends runnable") that does stuff. for this point on I'll refer to it as AClass I want to extend AClass so that users, using a SWING GUI, can interact with AClass during its execution. The major obstacle I am having is that AClass needs to send messages back to the UI so the user knows ... |
13. Mouse Listener problem coderanch.com |
14. KeyListener is not respond coderanch.com |
15. Swing:listeners coderanch.comHello all, i am new to java swing programming. i am making small aplication in swing. i am making listener classes for components mounted on frame. my query is that can i make seperate listener classes & put them in one package so that they are seperated from view classes (GUI Part) which are preent in other package or make this ... |
16. Keylistener trouble coderanch.comCurrently I enjoy playing many games, these games can be a pain and very boring to get gold/items etc.. so I've recently made an auto clicker of which will click in place but the problem is when the clicker is activated I've made the GUI set to 'setvisivle(false)' so the GUI doesn't get in the way, currently as the Java clicker ... |
17. Action Listener coderanch.com |
18. Why will this KeyListener not work? coderanch.com |
19. Multiple listeners coderanch.comFor input field I generally use one listener for each separate field. I could see using just one listener for all fields if the actions to be taken are either very simple (just a few lines of code), or if the actions are very similar to one another, so that otherwise there'd be code duplication. |
20. Registering Mouse Listeners on an Image coderanch.com |
21. Key Listeners coderanch.comI am trying to write a program that takes the key you type and changes it to something else. i cannot figure out what the key codes are for the letter keys. iny help will be great. here are the keys i need to change: a-z 0-9 thanks!!! edit: i found the way to do it for the upper case letters ... |
22. what kind of action listener will i apply to this coderanch.comimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class Main{ private static String word = "hehe"; static JLabel label; public static void main(String args[]){ JFrame frame = new JFrame(); JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); label = new JLabel(word); panel.add(label); JButton button = new JButton("Click"); c.gridx = 0; c.gridy = 1; button.addActionListener(new axon()); panel.add(button,c); frame.add(panel); frame.setVisible(true); frame.setSize(300,300); ... |
23. Multiple listeners coderanch.com |
24. need help with action listeners and events coderanch.comI am building a pizza ordering app for a homework assignment. The layout looks fantastic but as for the functionality, that is a different story. My objective is achieve an output similar to the one below. You pick your options, with radio and check boxes, then click process order. The receipt then gets displayed in the box below. I am trying ... |
25. Multiple sliders with a single listener - can it be done? coderanch.com |
26. Pausing the Mouse Listener coderanch.com |
27. KeyListener coderanch.com |
28. Key Listener help coderanch.comHi all. I have a simple application with a button and 2 textfields. I have used the card layout. My requirement is that when ever i press the enter key, the button must be pressed. I have tried the following and it worked. The problem is that if i have do much work, then that should be repeated in the key ... |
29. Help for Nebula Gallery widget selection listener? coderanch.comhi all, Could you help me about the selection listener in Gallery widget? I add a selection listener to the gallery just like below: Gallery gallery = new Gallery(info, SWT.BORDER | SWT.VIRTUAL | SWT.V_SCROLL); gallery.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1)); gallery.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { GalleryItem item = (GalleryItem)e.item; new ImagePreviewDialog(getShell(), item.getImage(), item.getText(), item.getDescription()).open(); } }); ... |
30. KeyListener problem coderanch.comHi, I'm actually able to get this ode to work but I just don't understand why one way works and the other doesn't - would appreciate it if someone could explain it to me... So I've got a class that represents a tab in a tabbed pane (MapTab), this tab contains an instance of the DrawingCanvas class for drawing shapes. First, ... |
31. MouseEvents/Listener coderanch.comWhat the hell am I doing wrong here? i really dont want to post my whole code here..but i suppose it's the only way haha // import java.awt.event.*; import java.awt.Color; import javax.swing.*; import java.awt.*; import java.util.*; // hotel class which extends jpanel and implements the actionlistener for tbe buttons class HotelGUI extends JPanel implements ActionListener, MouseListener { Vector |
32. how do i place a mouse over action listener on a rectangle? coderanch.com |
33. Correct Listener to use? coderanch.comThanks for the suggested links I will study the information in detail. To clarify I was looking for the best listener to use, so a panel could be resized dependent on how the screen size was changed by the user, either by changing the screen resolution, or moving the JFrame/window that had the focus to another monitor. John Merritt |
34. KeyListener coderanch.comI found some things when using a KeyListener that seems strange to me. 1. There is a InputEvent.ALT_GRAPH_DOWN_MASK that can be used to check if the Alt Graph is down, however whenever I press the Alt Graph key, the keyPressed method is called twice, first with Ctrl as the modifier and then with Ctrl+Alt as modifiers. Seems to me like it ... |
35. Action Listeners coderanch.com |
36. Still wrestling with action listeners coderanch.comHello, I would like to pass a variable set in an action listener back to the Main class. I have downloaded and experimented with a number of examples including DialogDemo.java and AL.java. I can get the value to display from within the action listener; but, the code in the Main class always executes, before the value is returned from the action ... |
37. Problem with KeyListener coderanch.comI posted this as RESOLVED but I don't know if that worked. I used requestFocusInwindow(). I have a swing dialog with a class that extends JPanel at the center and buttons at the bottom. I use the JPanel to display the image of a JPG file. I enter strings in the image by clicking with the mouse to select a location ... |
38. JSpinner and KeyListener: not working coderanch.comI've created a number-spinner class which should allow the user to press the + or - keys to increment or decrement the value. This is in addition to the normal up and down arrows on the control. (The idea is to have - another - keyboard control for changing the value.) I've tried several variations, but can't seem to get the ... |
39. global event listener coderanch.com |
40. how to perform mouse listener for an open street map coderanch.comHello...! i have a problem and i could not able to overcome it. I have two JPanels- one where some JLabels are placed and in another open street map is placed. Now i need to perform mouse listener for the JLables. If i clicked a JLabel then it must take me to that particular location of open street map. i am ... |
41. Questin on listeners coderanch.comEvery single book Ive read shows that keylisteners are added to a window or frame only in public static void main(). So I was wondering how do you add a keylistener to a class that does not have the main method, or is this even possible? What I want to do is to have a main method that displays a frame ... |
42. How to tidy up a swing listener program? coderanch.comI usually make one class for each form, which contains all the listeners as well. Here's how I would recommend you do it:import java.awt.*; import java.awt.event.*; import javax.swing.*; final class MyForm { private final JFrame frame; private final JPanel mainPanel, rightPanel; MyForm() { frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainPanel = new JPanel(); frame.add(mainPanel, BorderLayout.CENTER); rightPanel = new JPanel(); frame.add(rightPanel, BorderLayout.EAST); rightPanel.setBackground(Color.RED); ... |
43. Which is the best way to write action listeners? coderanch.comAs far as I know, there are two ways to handle events, for example: - using anonymous class action listener, all logic written in method actionPerformed() or by separate methods. - writing concrete action listener classes (public or inner classes) So which is the best practice, pros and cons of each, or is there something else? Please discuss. Thanks. |
44. Problems with Key Listeners coderanch.com |
45. keyListener isn't working for me java-forums.orgin an applet i made with a KeyListener and a MouseListener, my keyListener will not respond to keys pressed. the mouseListener works fine. the keyTyped, keyPressed, and keyReleased methods just won't get called. can someone please find my mistake? Java Code: public class Cursor extends JApplet implements MouseListener, KeyListener{ BooleanJLabel[][] grid = new BooleanJLabel[5][5]; Icon backgroundIcon = new ImageIcon(Cursor.class.getResource("images/background.gif")); Icon cursorIcon ... |
46. KeyListener problem java-forums.orghi guys , I am trying to make a game for my project....but I am encountering some problem......Any help would be appreciated. so , the game class is working when I run it individually ,the keylistener is working as well.... However when I run it using a Frame which would instatiate a welcome panel of my game , which have a ... |
47. Help with Listeners java-forums.orgI'm making a GUI with jButtons, jRadioButtons, and a jList. I've got the ActionListeners working for the jButtons and jRadioButtons, but can't seem to get the MouseListener working for the jList. I previously built this GUI in NetBeans form editor and it worked fine, although I didn't do much of the coding. I'm trying to learn Swing, so I started over ... |
48. Help with Listener and final java-forums.orgI have an array that I'm having trouble with. The array named newList has data I'm trying to access. Everything is fine when I use it within the method until I try to use it with a Listener. I get an error "local variable newList is accessed from within inner class; needs to be declared final." If I try to make ... |
49. How can i write listener on ArrowButtons in Basic ScrollBarUI. in 1.5 version java-forums.org |
50. Action Listener java-forums.orgSorry I am new to this forum so please tell me how to use code tags. Following are my code static JMenuItem c = new JMenuItem("Hye"); public static void one { c.addActionListener(null); } public void actionPerformed(ActionEvent e) { if(e.getSource() == m11) JOptionPane.showMessageDialog(null,"Hye"); } My problem is that it is not taking any action even i press any key. Some on told ... |
51. Creating a GUI events with action listeners java-forums.orgCreating a GUI events with action listeners I am new to the forums and relatively new to Java, and most certainly very new to GUI programming. I am a high school student who needs a ton of help with this type of programming so I apologize in advance if I frustrate someone because I am slow. I have been ... |
52. Question on Multiple Listeners implementation java-forums.orgI've been wondering about this. Lets say you have a GUI designed that has a whole bunch of GUI Fields, such as a whole bunch of Buttons or a GUI which listens for property changes on a bunch of different objects. Is it better to use anonymous inner classes to listen on each object or just have the GUI implement the ... |
53. keyListener not doing anything java-forums.orgimport java.awt.*; import java.awt.event.*; import javax.swing.*; public class testClass extends JFrame implements KeyListener { private boolean rectangle=false; public toren() { setTitle("test"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(500, 500); setLocation(0,0); getContentPane().setBackground(Color.white); ((Component) getContentPane()).addKeyListener(this); setVisible(true); } public void paint(Graphics g) { g.drawRect(50, 50, 50, 50); if(rectangle) { g.drawRect(50, 50, 100, 100); } } public void keyPressed(KeyEvent e) { } public void keyReleased(KeyEvent e) { } public void ... |
54. ActionListener+KeyListener java-forums.orgHello! I'm new to this forum so be gentle. I have to write a program that counts the number of times the button is pushed. That is, the button is pushed by mouse click or by pressing Alt+O. Now, the first part is easy, but i don't know the second part. How do i combine those two events together? The program ... |
55. Multi event listeners java-forums.orgHi everyone, I have a bit of a problem. I am trying to use the multi event listeners but keeping getting this error: cannot find symbol symbol: class EavesDropper location: class aloeandcycaddatabasegui.AloeAndCycadDatabaseLogin -- (Alt-Enter shows hints) The first action listener works 100% but I am battling with this one. Here is some of the code that I have: // Adding the ... |
56. Problem in action listener java-forums.orgHi, I am creating a backup application, in which after selecting files, when user clicks "Start Backup" button backup starts at back end, to check if the backup is completed i am created a file on completion of backup, so the application keeps checking every 2 sec if the file is created, and if its created it'll show a dialogue that ... |
57. How to draw a shape with listener ?? java-forums.orgthanks 4 your reply but you didn't understand what I want .. I know how to draw rectangles but the problem is I don't know for example if I have 4 rectangles I want when I click on one rectangle it shows me something and when I click on an other rectangle it shows me different thing ,, could anyone please ... |
58. Problem with Keylistener, some help pls java-forums.orgHeya, would apreciate some help if possible.. to start with, im sry that i didnt display my code the right way (couldnt find the option/ thread about it), anyway... my problem is this: My school work is to make the Bomberman game, and i have 3 classes extending JPanel (menu, singleplayer and high scores), each of them take as parameter the ... |
59. KeyListener not working java-forums.orgHow do I make KeyListener work? I know for sure the only bugs in my code have to do with KeyListener: Risk.java: Java Code: import java.awt.Toolkit; import javax.swing.*; import java.awt.*; import java.text.NumberFormat; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; import java.awt.event.*; public class Risk extends JPanel { public int leftNumber, rightNumber, setbad; public JButton Enter; public JFormattedTextField stupid, yummy; public JLabel smart, dumb, nook, ... |
60. Help with KeyListener in Java Swing java-forums.orgHello all. I'm pretty new to Java and I've been struggling trying to wrap my head around some of the aspects of Swing. I'm trying to solve the following problem for an online course I'm taking, any help/advice would be appreciated, thanks! :-) "Write a Swing component KeyEcho that listens to its key events with an inner KeyListener. Make it so ... |
61. Action listener is iterating multiple times when clicked java-forums.orgHi, Im new to these forums so please take it easy on me :) . Anyhow im currently writting an application for my university course that handles a fleet of vehicles and employees. This program was originally written to be used with just the console as input but Ive now adapted it to work with a GUI created with WindowBuilderPro. Ive ... |
62. JCalendarCombo listener java-forums.orgI downloaded a calendar combo box called JCalendar 4. Have it in my program ok, but can't seem to get a listener to work on it. In the program, I have two calendars, one for a start date, and one for an end date. When the user has selected both dates (I want these two dates to be stored in a ... |
63. Mouse listener does not work through application layers java-forums.orgI started my project using default NetBeans wizard, creating FrameView class. It handles events through ActionMap and works perfectly fine as a menu. However, inside the frame I embedded Applet which is supposed to execute the main game. I need it to handle MouseListener events. But it does not react to any mouse actions as long as it's running. Even Debugger ... |
64. Writing a MouseWheel listener problem java-forums.orgHi! Im trying to write a MouseWheel listener but it's not working at all. It's a program that displays RBG values with JLabels and a JPane that displays the color. You are supposed to be able to scroll in the panes to increase or decrease the values, but nothing happens!? I'm a Java noob so forgive me for any obvious errors ... |
65. How to handle multiple listeners on stateChanged java-forums.orgUntil now, I only had a slider activitating stateChanged and to change page clicked on the tab: that didn't need any code from me, it just happened (I assumed it is inherent to tab properties). Now I need to know, within the code, when the tab is clicked - and that's where I get confused. My stateChanged listener doesn't seem to ... |
66. Problem Using KeyListener in swing program. java-forums.orgHi guys I am creating a Swing application, but having a problem in using keyListener. I am building a JFrame containing a JDesktopPane. This JDesktopPane will show three JInternalFrame. This programe uses a Sqlite embedded database. The InternalFrames is used For 1. Displaying Data 2. Inserting Data 3. Updating Data In the Update Internal frame I have a JTextField "sno" on ... |
67. ActionListener conflicting Keylistener java-forums.orgHello. I am creating a pong app. the game itself works great, so I decided to introduce a title page into the application. to create this title page, I created an if statement in the paint() method to only paint the title screen when an integer called lvl was equal to 0. The main class has a key listener while the ... |
68. Need some help with mouse listener java-forums.orgSo I actually found a solution for my timer that doesn't start more than once. But now is not working smoothly. I think that from my code you will understand the problem. Java Code: public boolean timerbool = true; public void Pressed(java.awt.event.MouseEvent evt) { for (int x = 0; x < 11; x++) { for (int y = 0; y < ... |
69. Regarding Listener java-forums.orgIt sounds as if you want to set your button as the default button for that window. This can be easily done by calling the JRootPane method, setDefaultButton(...). For example: Java Code: import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextField; class DefaultButtonTest extends JPanel { private JButton buttonOK = new JButton("OK"); private JButton buttonCancel = ... |
70. Regarding Listener java-forums.orgYou can also add a keylistener to the button. You have to import java.awt.event.*; Set focus to button with JButton.requestFocus(); Code for keylistener normally in the constructor JButton.addKeyListener( new KeyAdaptor() { public void keyPressed(KeyEvent e) { int key = e.getKeyCode(); if (key == KeyEvent.VK_ENTER) { statements or call method } } } ); |
71. Simple Action/Listener Help GUI java-forums.orgSimple Action/Listener Help GUI Ok, I have been searching around for awhile now for examples on Action/Listeners for a JButton, and JtextField update. All of the examples I have found are too complex for me to follow. So, basically I am making a program that has THREE textfields. You enter in a number of votes, and then click the ... |
72. how to enable the web GUI of administration of virutal server, http listener? java.netMartin ______________________________________________ Verzicht und Vertraulichkeitanmerkung / Disclaimer and confidentiality note Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer ... |
73. Help: GUI Problem. What kinds of listener? forums.oracle.comI am designing a 2D GUI by using a matrix data. Eventually, I would like to be able to have a pop up or some sort of selector that would let you select the text for the nth item in the text list, then the software would generate a plot using the nth column of data. For ex. get a data ... |
74. Java Swing item listeners forums.oracle.comfor(int i=1; i<=31; i++){ String date = i + ""; JLabel date_entry = new JLabel(num,SwingConstants.CENTER); JButton date_click = new JButton(); date_click.addActionListener(this); // adds action when button is clicked. click.add(numbers); testpanel.add(click); } Also, my JMenuItem has an action listener attched to it too and when it is clicked, its supposed to open a new JFrame. JMenuItem menuitem1; .... menuBar = new JMenuBar(); ... |
75. Swing and KeyListener forums.oracle.comIf you don't see where I am going with this, I want to be able to take keyboard input through the swing window. please be aware that I am only taking a beginning course of java at my high school and I have only been in the class for 7 weeks. I am doing stuff kids wont do until java 2 ... |
76. Key Listener on non-gui program? forums.oracle.comHi, I have a program with an infinite loop. I want to constantly run the loop until I hit a button (esc or q or whatever). How would I go about doing this? I don't want to ask for input, since it will stop processing, but merely have some sort of KeyListener. However, I'm not using gui, so I can't really ... |
77. Key Listeners and GUI Help. forums.oracle.comkeyPressed() is almost never what you want. It only works when the component you have the listener on has focus...and focus changes all the time. So you'll either have to put in guarantees that your component has focus, or use a different method for listening for key presses. Unfortunately, I don't know much about Swing so I can't advise you on ... |
78. Swing and KeyListener dont work together. forums.oracle.com |
79. Java Swing Events/Listeners forums.oracle.comThere are two ways to implement Swing Events/Listeners: 1. Have everything in 1 file and have anonymous inner classes that implement the listeners. 2. Have a main GUI class that has separate classes of JPanels that implement the listeners. I have worked with case 1 where everything is in one file so that I can call functions within the one GUI ... |