Event 1 « Event « Java Swing Q&A





1. ActionListener problem    stackoverflow.com

I have a problem with my actionListener. It seems that the actionListener runs automatically before I click the button? The "This should not appear in the console before button click" appear in the ...

2. What Java Swing event can be used to know when application has finished starting?    stackoverflow.com

I'm looking for a place to hook some code to programmatically create, size and position a JPanel after the application has finished loading. I'm just starting with Java. I'm using NetBeans 6.5.1 ...

3. Tomcat update event    stackoverflow.com

I am working on an application which uses tomcat as a web server and java swing app. as only client to communicate to the web server via webservices. I am stuck ...

4. The super class of all event classes    stackoverflow.com

I can not get that that super class is AWTEvent class or EventObject?

5. Java Music Player GUI    stackoverflow.com

I am implementing a GUI using Swing for a Java Music Player. I'd like to know if it is possible to make a time bar like the bar in WinAmp for ...

6. Java Swing event    stackoverflow.com

I wonder how one should implement an event which will do some Action when a button is pressed, and stop do that action when button is released I tried to add MouseListerner ...

7. Unable to receive grab event by using GRAB_EVENT_MASK?    stackoverflow.com

I added an AWTEventListener to process grab event. So this listener just use sun.awt.SunToolkit.GRAB_EVENT_MASK mark. But This listener can not capture UngrabEvent. The tricky thing is, when a JComboBox popuped its menulist, it ...

8. Java Simple ActionListener Questions    stackoverflow.com

I have a main class in a program that launches another class that handles all the GUI stuff. In the GUI, i have a button that i need to attach an ActionListener ...

9. OnExit Event For a Swing Application?    stackoverflow.com

I'm developing a simple application to manage the operational part of a business using Swing, but I need that when the application exits, it performs this:

updateZonas();
db.close();
But how can I do this? ...





10. actionlistener not responding in java calculator    stackoverflow.com

please see calculator interface code below, from my beginners point of view the "1" should display when it's pressed but evidently i'm doing something wrong. any suggestiosn please?

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

11. Swing: does DefaultBoundedRangeModel coalesce multiple events?    stackoverflow.com

I have a JProgressBar displaying a BoundedRangeModel which is extremely fine grained and I was concerned that updating it too often would slow down my computer. So I wrote a quick ...

12. asynchronous UI in java    stackoverflow.com

I'm working on a Java program, and it's been over a year since the last time I used Java, so I'm a little rusty. This program uses Runtime.exec() to call ...

13. Netbeans 6.8: Actionlistener confusion    stackoverflow.com

I have 2 modules: BrowserLibrary and BrowserViewer. Browser contains gui like any browser should. so inside BrowserLibrary module I have a class like so:

public class BrowserController implements ActionListener{

    public ...

14. Java Swing properties (addPropertyChangeListener)    stackoverflow.com

Is there a published list of property names for Swing components? From looking at the source code for javax.swing.table.TableColumn, I can find calls to firePropertyChange with property names like "modelIndex", "identifier", "headerValue", ...

15. Java event propagation stopped    stackoverflow.com

I have a main window:

public class MainPanel extends JFrame implements MouseListener {

   public MainPanel() {
      setLayout(new FlowLayout());
      setDefaultCloseOperation(EXIT_ON_CLOSE);
  ...

16. Java ActionListener history    stackoverflow.com

I made a java program with graphical user interface which simply reads txt files. I have some fetures such as show table of contents, go to a specific page of the ...





17. java gui help actionlistener    stackoverflow.com

I'm trying to set a combobox in my GUI to print the the information about a student in a JLabel.

private void studentComboBoxMouseClicked(java.awt.event.MouseEvent evt) {

    if combobox1="student1"{
  ...

18. pause for the Event Dispatcher    stackoverflow.com

I've got a (primarily) single threaded application which updates a swing chart component (jfreechart) as it goes. since all updates to the chart are done on the event dispatching thread, the que ...

19. ontextchanged event in java    stackoverflow.com

i am looking al events in java http://java.sun.com/docs/books/tutorial/uiswing/events/handling.html i want ontextchanged event like in C# that when text changed event is executed. Which event is the right one in java?

20. Cannot open a Socket in Event Handeler    stackoverflow.com

I am trying to build a simple desktop application where the user enters the url in a text field and clicks on the submit button to send the GET request for ...

21. ActionListener problem    stackoverflow.com

i am trying to make an actionListener on a button in another button which has also an actionlistener and i just couldn't figure it out for some way. I am trying ...

22. Cannot initialise class within ActionListener... please help!    stackoverflow.com

I have a Breadth-First algorithm that scans a graph of nodes. I am new to UI and Swing. I want the algorithm to run when the OK button is pushed etc. using ...

23. Can I use BufferedReader and create an array inside actionListener class?    stackoverflow.com

I've created an actionListener class. in the actionPerformed method, i would like run a code. This code involves importing data from multiple text files, and store them in a 2D array. ...

24. Java implements ActionListener Problem    stackoverflow.com

In relation to my previous problem, I now have a new problem. In order to avoid the inner class, my class now implements an actionListener. My code is as follows:

public ...

25. How does an ActionListener work?    stackoverflow.com

I have an idea of how to use action listeners and implementing them but I was wondering if anyone could tell me how do they listen to the events? Is there ...

26. Java Altering a GUI from a different class    stackoverflow.com

So my program has multiple classes and after one of them has run, it'd like it so it appends the text area in the main class GUI with a 'finished' message

ta.append("Search ...

27. Doesn’t work ActionListener for Tray Icon in the jar    stackoverflow.com

There is easy Swing application. I added possibility to hide/show the application in the system tray (by using SystemTray functionality in Java SE 6). My trayIcon has ActionListener and ...

28. jFreeChart reload dataset issue    stackoverflow.com

I use JFreeChart to display some simple data in a column chart. I have no problem in loading the dataset into the chart and display the data, but my issue come ...

29. Java Swing; Two classes, where to put if statements and new actionlisteners?    stackoverflow.com

Pure beginner question here. I'm modifying a code and am now stuck on the following questions; My timer is called in the upper class. But my int count is being called in the ...

30. java swing events    stackoverflow.com

I want when I enter a button, text to appear in the console. How can I combine the methods there is my comfusing, can someone explain and give example.

31. Do i need to extend Adapter Class 'here'?    stackoverflow.com

This is my snippet :

tf.addKeyListener(new KeyListener() {
     public void keyTyped(KeyEvent ke) {
            getEnter(ke);
    ...

32. Problem with SwingUtilities.getLocationOnScreen();    stackoverflow.com

I have the following code inside an ActionListener on the JButton "support". the cl.across.text is an other JTextArea inside my GUI. The problem is with the results given for point pt1. ...

33. Eclipse & Java: Is there an event monitoring feature?    stackoverflow.com

When developing java guis (e.g. swing) in eclipse, is there a built-in feature (or plugin) that allows one to monitor all the events that are fired?

34. A litle help with swing please    stackoverflow.com

JFrame myframe = new JFrame("My Sample Frame");
  JButton mybutton = new JButton("Okay");
Can someone explain to me these part.
 mybutton.addActionListener(new ActionListener(){

  public void actionPerformed(ActionEvent evt){

  //Assuming that the content ...

35. Using Multiple ActionListeners in Java Swing    stackoverflow.com

as this is my first post here, please bear with me if I make any etiquette mistakes. :) What my problem is, is that at the moment I am making ...

36. Java synchronization question    stackoverflow.com

Just seeking some confirmation on something: I have a server object with Swing GUI, containing a method handle(), which is accessed by external threads, and another method doThis(), which is run from ...

37. Minesweeper Action Events    stackoverflow.com

Is there a way to make certain event actions specific to left and right mouse clicks? I'm creating a minesweeper gui, so when a square is left-clicked it will be uncovered, ...

38. converting javafx events to awt events    stackoverflow.com

Is there a mechanism to convert fx events to awt events? Something like processMouseEvents ...

I am mixing swing and fx in such a way that:
A java panel is active at the ...

39. what is the difference between write actionperformed in run() or outside of main    stackoverflow.com

I write action performed code like outside of main

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
    jTextField1.setText("do something");
}
and it can be written in run() like ...

40. Java making confirming exit    stackoverflow.com

I have an application. I need to make this, when user click the close button, a confirmation will come ( just like javascript confirm dialog ) , 'Are you sure'? I'm ...

41. Java ActionListener Not Working As Hoped    stackoverflow.com

This game is supposed to switch commands between players 1 and 2 by using a boolean variable in the ActionListener, but it's not working right now. We can click all 3 ...

42. java Gui actionListener help    bytes.com

ooneguy I'm trying to write a java gui program that contains 3 different tabbed pane, 1 tabbed pane consists JComboBox. When i choice using JComboBox, the result will be shown because ...

43. Synchronized GUI event    forums.netbeans.org

Using the GUI design features of NetBeans one can add a ComboBox and create an actionPerformed event to handle its selection. The actionPerformed method is generated and one can enter custom ...

45. AWT Swing events    forums.netbeans.org

I think Gregg is talking about the fact that Netbeans does a lot of time-consuming, non-UI work on the EDT - which is a fundamental Swing/AWT "no-no" because it interferes with UI-related events being processed. That's the reason things like SwingWorker exist. tom On Mar 25, 2011, at 2:05 PM, software visualization wrote:

46. ActionListeners    coderanch.com

47. Too many events    coderanch.com

48. Calc with Events - Help !!    coderanch.com

Most calculators that I know expect the user to enforce the order of execution by providing temporary memory areas that the user can store an intermediate result to. If they do NOT choose to use that option, then the calculator executes the operations in the order that they are entered, and displays the intermediate results along the way.

49. Jatbbed pane event    coderanch.com

50. Image Click Event    coderanch.com

Hi Angela, It's called MouseClicked. I assume you have drawn your image into the applet or into a panel. Add a mouse listener to your applet or panel. In the method (mouseClicked) you can get the x and y locations which where clicked. Compare that to the image location + image width and heights to figure out if the clicked happened ...

51. Event IDs    coderanch.com

Is there any way to get the ID of an event in Swing? I know that in the old event-handling way of doing things you could get the ID of an event (gotFocus, lostFocus, etc) but in the new way I can't find any. I can get the source, but that's not what I want. Am I looking too hard, or ...

52. ItemListenner Events ??    coderanch.com

53. Swings + Event handeling    coderanch.com

Hi Remi, Firstly is it a Jtooltip or a JToolBar, I hope it is a JToolBar. Now, for the cut copy paste operation, make a String variable(buffer) in your main class. It maybe a static if you don't have a reference of the main class in your respective dialogs. Initially keep this buffer=null. If a call to paste is made simply ...

54. Event handeling    coderanch.com

55. Event    coderanch.com

56. events    coderanch.com

57. ActionListener not recognized under Solaris    coderanch.com

The problem is that under Win2K you can actually perform either a mouse click on say the Submit button or hit the enter key to perform the same event. However, I moved the jar file over to the Solaris 8 system and ran the program and the application would not recognize the enter key (when pressed) as an action event. The ...

58. problem with ActionListener    coderanch.com

How exactly did you declare the actionPerformed() method? You must use the same signature with the same access rights, that means it must be declared as public. What I am wondering is why do you implement the method in your abstract class Game when you code it in the inherited class Maths? Good luck Tom

59. dispating events in ver 1.3    coderanch.com

I trying to dispatch a mouse event to the list by pressing the button but I fails.the list doesnt get any event. Im using 1.3 and how can i get() the specific event(that occure) details? : public class listo extends JFrame{ JList list = new JList(); JButton bt = new JButton("Buttin"); Container c; public listo(){ c = (Container) this.getContentPane(); c.setLayout(new GridLayout(1,1)); ...

60. posting an action event    coderanch.com

Here I am trying to perform a fake click on the Fake button by pressing the Original button and I fail. Can you tell me please whets the different between use doClick() and sending an event to the source? And of curse why this code dosnt work out for me? import javax.swing.*; import javax.swing.event.*; import javax.swing.text.*; import java.awt.*; import java.awt.event.*; import ...

61. How to propogate an event?    coderanch.com

Hi ... can anyone point me to an example or explain how an event can be passed up to it's container. I'm using a JLayeredPane to hold some JPanels. The JPanels in turn contain a JEditPane and may contain other components. The user needs to be able to click on any one panel and have it move to the front. Problem ...

62. Event Problem?    coderanch.com

I'm having some difficulty with an application that i'm writing. It's a tool to query a database. When the application is started everything appears to run fine. But the application only lets the user run one query. i.e. after the first query the GUI stops working and doesn't let me click any buttons. Can anyone help me? Here's some of the ...

63. TreeSelectionListener event.    coderanch.com

64. Cancelling events    coderanch.com

Hi all, I was wondering if it is possible to cancel the events that exist on the event dispatching thread. On my GUI i have a JTree and on adding a new node to the tree i want to validate some data before the user leaves this new node. So what i have done is add some checks in the TreeListener ...

65. action events    coderanch.com

66. Application Event Framwork    coderanch.com

I've done something like this. I set up a listener interface for my objects that have to be aware of changes made somewhere else. Then in the aware object(the one that causes/knows about the changes) I kept an array/vector of the objects that were registered as listeners then had to run through a for loop and hit each one whenever there ...

67. Event Handleing Help ...    coderanch.com

Maybe I can be more clear as to what I am attempting. I have a Class that extends JPanel with a Close button on it, I use this class in a second Class that extends JFrame. I want to handle the close action event in both classes, first the panel, second the frame. i.e. When the user click on the close ...

68. event mouseMoved    coderanch.com

69. Memory Leaks and Removing ActionListeners    coderanch.com

Hi, I have a button declared at the class level i instantiate the button in the constructor and add an actionListener object to the same. while moving to the next screen if i set the button to null would the button be eligible for garbage collection or do i explicitly need to remove the actionListener object as well? Thank You, Phani. ...

70. Style for ActionListener    coderanch.com

71. events in non-GUI environment    coderanch.com

Guys, I've a peculiar problem to take care. Our application has a configuration file. We need to change the configuration settings, externally (from unix shell) and application should be aware of the settings changes dynamically without bouncing the app server. Is it possible to accomplish this using events/action listeners. A piece of code snippet - greatly appreciated. Thanks, Maalti iyer.

72. Event when image is fully loaded?    coderanch.com

I feel a bit silly asking this, but I've been trying to find an answer for over an hour now. I want to load an in a seperate thread. When it's done loadnig, I want to call repaint(). There has to be a simple way to do this, but I've tried what I thought would work (ImageObservers and Toolkit.prepateImage()), but it ...

73. getScaledInstance() and resize event    coderanch.com

I'm having a problem displaying a icon and I appreciate any help I could get. I have a app with three panes; top, middle and bottom, each using GridBagLayout. The top panel (JPanel) displays a JLabel on which I put a icon (.gif). The original .gif has a width of 200 and height of 450. I use getScaledInstance() on the image ...

74. Track all occurring events    coderanch.com

Once upon a time, in Java 1.0, unhandled events propogated up the containment hierarchy until they were dealt with. That would be _perfect_ for what you are trying to do. Unfortunately it was tedious for doing anything else (i.e. to catch a button's event you either had to subclass it or find its event in one of its containers), so Java ...

75. Graphic Events    coderanch.com

I know how to make graphics with Graphics G and the paint method. If I wanted to make some functionallity in which a user could drag a circle and it some where else on the canvas, how would I go about that. (I.E - like moving a checker peace in yahoo checkers). Any help is apreciated. Thanks.

76. treeNodesChanged event    coderanch.com

Well I havent read all the code, but what do you mean by editing? You mean editing in the table cells? My guess is that you're not listening for the right kind of event. Listening to the TreeTableModel wont do it in your case because of course you'll get all the events that happen to the model, and that includes expand/collapse ...

77. ActionListener problems    coderanch.com

Hi, I have serveral classes, one of which lays out some buttons on the creen. I want these buttons to open new windows from other classes but I am hvaing trouble. The actionListener is working but how do I get a window containing a new class to open when the button is clicked? The class with the buttons is import java.awt.*; ...

78. Problem with ActionPerformed    coderanch.com

Hi I have this wierd problem in my program (I'm a nube so it must be a basic stuff). It is a GUI problem where are 3 classes +main class - buttonPanel, infoPanel and Stats. This buttonPanel has buttons and ActionPerformed method. Infopanel has a basic constructor and methods that should show stuff on infoPanel. And this Stats class has just ...

81. java dynamic event    coderanch.com

82. ActionListener and text problem    coderanch.com

Swing invokes event handlers in the same thread used for screen painting. Therefore while an event handler is running, the screen can't be updated at all. If you want to do some long-running task in response to a user event (and if you've got an "executing..." message, I'm assuming you do) then the right way to do it is to spawn ...

83. events.. best practices...    coderanch.com

If I have a JFrame created in the main() method and want to catch events, outside of the JFrame object, what are the best ways to do that. Example being, I have a login screen that pops up and then the user either exits or continues on to run the application. I'd like to begin loading the application from within the ...

84. Event Manager Compile Problem    coderanch.com

In the following code I have a simple GUI with several buttons. Without the event listeners it works fine, but when I add the listeners and compile I get the error message illegal start of expression--public void actionPerformed(ActionEvent evt); Here is the code that has been causeing the problems /* *Main Menu *Created By: Atrus *Date Origionally Created May 3, 2004 ...

85. Understanding Events    coderanch.com

I'm trying to get a handle on the event mechanisms used in Java Beans and Swing. I know that all event sources pass an event object to the event listener when they call the event listener method. I am wondering what the purpose of this object is. The online documentation from Sun said that this event object provides a useful method, ...

86. Question about ActionListener    coderanch.com

Hi: everyone I got a problem about ActionListener. I want to use a button to control a JTextField in another class. but I am not sure how to do it. I do not know what's problem about my code, but I can not implement what I want to do. import javax.swing.*; import java.awt.event.*; import java.awt.*; public class Test4 extends JFrame{ JTextField ...

87. Java's gui event system.    coderanch.com

88. ActionListeners HELP    coderanch.com

89. What is the common structure for your ActionListeners?    coderanch.com

class A extends JPanel{ JButton jButton1; JButton jButton2; ... ... jButton1.setText("jButton1"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); jButton2.setText("jButton2"); jButton2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); ... ... private void jButton1_actionPerformed(ActionEvent e) { // TODO: Add any handling code here } private void jButton2_actionPerformed(ActionEvent e) { // TODO: Add any handling code here ...

90. clipboard events?    coderanch.com

hi all, does anyone know how to monitor if there is something in the clipboard. i would like to enable or disable the 'paste' menu item depending on whether or not there is someting in the clipboard. on a similar note i would also like to know how to monitor if a selection has been made in a textfield or area ...

91. ComponentMoved Event ??    coderanch.com

Here is the situation, I have a grid of textfields within a panel. This panel is contained within a scrollpane. The focused textfield in this grid has a floating window attached to it, something similar to a tooltip, but with a lot more functionality. When I need it, I pop up this special tooltip-window relative to the textfield that it is ...

92. text event    coderanch.com

hi, i am writing a program whereby i'll have twoo text fields and once i enter a text in one text field, i want it to display in the other textfield without me clicking on any buttons, the only button there will be the exit button.in the textvaluechanged method of the textfield, how do i get it to return true if ...

93. java.awt.Event & java.awt.AWTEvent    coderanch.com

94. Event overflow    coderanch.com

Another question I had is what strategies have you found useful in handling lots of events. I'm working on a fairly complicated swing application and we continue to add new events to the system. This ends up to the point where the user clicks one button and so many events start flying that it is hard to debug and begins to ...

95. swing actionListeners    coderanch.com

am a student working on a simple project, or so I thought. I have to design a calculator using Swing. I have the application set up, but I need help understanding actionEvents. My GUI looks good, all buttons have actionEvents attached to them, my LCD display works fine, but I have one major problem. I am trying to set up my ...

96. ActionListener advice    coderanch.com

I have a form (actually a JPanel) that will in some cases get called to stand alone and other times be part of a larger form. It has two buttons that I want to behave differently when it is part of a larger form. My instinct is to loop through the array of actionListeners for each of these buttons and remove ...

97. Event Que    coderanch.com

Hi All Just a quick question, Is it correct to say that when a thread is passed as an argument in invokeLater(), it is placedd in the event que? then when it reaches the head of the que it is invoked in the event despatch thread?, also, is the event que a strict FIFO? eg, can you get programmitacally fired events ...

98. Swing ActionListeners best practice?    coderanch.com

Joe, thanks for the link. I've seen that interface used before(though not very often). I think I like it better as it seems a bit more flexible however I saw this on the link: Note that Action implementations tend to be more expensive in terms of storage than a typical ActionListener, which does not offer the benefits of centralized control of ...

99. Timed events    coderanch.com

Originally posted by Ed Ewing: Just a guess, but maybe you are changing the Y-coordinate by a fixed number of pixels, and the screen resolution on your laptop is lower than on your other computer. If this is the case, then the icon would appear to move faster on the laptop, even though it is updating the same number of times ...

100. ActionListener    coderanch.com

A listener for the first button would have to record the fact that the button was pressed, by setting a flag, for example. Then a separate listener for the second button would need to check the flag to see if the first button had already been pressed. Presumably you'd want other buttons and things to clear that flag if other UI ...