I am about to refactor a Swing application from using ActionListeners to Action classes because I realized that a lot of my menu items are going to be used in a toolbar as well.
Right now I have a class called ImportExport which deals with the state of the underlying model and then displays the appropriate user dialogs. ImportExport has...
Hey everyone, I'm working on a hex dump utility made in Java. I'm having some issues with the Scanner I'd be using before the hex/ascii logic.
Right now I have the logic and a few other things excluded for debugging reasons, but if anyone knows what's going on I'd like to know! Hints greatly appreciated.
package filedumputility;
impor...
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 to.
The only problem is, the code to be executed needs to reside within the main class.
How can i get the ActionPerformed() method to execute in the main class when a button is...
Hi!
I am a beginner with java and has got a problem that I just cant solve.
I am trying to add strings to my array, I have tested my array so that work. But my problem is that I have created an actionlistener and trying to get the text from another class and then add it to the array.
My Buttonlistener:
public class ButtonListener ex...
Hi, use this website a lot but first time posting.
My program creates a number of buttons depending on the number of records in a file.
E.g. 5 records, 5 buttons.
The buttons are being created but i'm having a problem with the action listener.
If add the action listener in the loop every button does the same thing; but if I add the act...
I just started to learn how to use action listeners. To my understanding it works in the following way:
There are some classes which contains "addActionListener" method by default (for example classes for buttons).
Using this method we add an action listener to an object. For example: listenedObject.addActionListener(listeningObject).
...
Suppose we have a JFrame named frame1 with a String attribute named credentials set inittially to null. I have a jButton named button1 attached to the frame and I want to change the frame1 String credentials attribute by pressing button1. I need some piece of advice regarding the ActionListener code especially.
...
I have a static variable partner in the class. And I want to set a value of these variable whenever a radio button is pressed. This is the code I tried to use:
for (String playerName: players) {
option = new JRadioButton(playerName, false);
option.addActionListener(new ActionListener(){
@Override
public void acti...
I have a big table containing a button in each cell. These buttons are very similar and do almost the same. If I add an action listener to every button in this way:
tmp.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent evt) {
proposition = proposition + action;
SwingUtilities.inv...
I have following code in jsf page, backed by jsf managed bean
<h:dataTable value="#{poolBean.pools}" var="item">
<h:column>
<f:facet name="header">
<h:outputLabel value="Id"/>
</f:facet>
<h:outputText value="#{item.id}"/>
</h:column>
<h:column>
<f:facet name="header">
...
Hello everyone,
I have the following code adding an ActionListener to a JTextField:
chatInput.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
chatInputMouseClicked(evt);
}
});
Now how do I remove this MouseListener using chatInput.removeMouseListener(), sin...
Hello,
I'm new to java and I have to get a school project done by Sunday and got a problem.
Here's the code:
private abstract class GamePanel {
JPanel panel = null;
}
private class PutPanel extends GamePanel {
JButton putShip1 = new JButton("");
JButton putShip2 = new JButton("");
JButton putShip3 = new JButton("");...
I have a class that contains a JButton. This can't be changed.
The problem is this: The actionListener calls getSource() and gets the JButton, not the container class.
Can I change what getSource retrieves, before the actionListener is added?
OR can JButtons have a variable reference to its container?
I can't make a class extend a JBu...
I have an application that fires 2 threads, the 1st launches another class to do some processing which in turn launches a 3rd class to do yet more processing. The 2nd thread in the main class should wait until some event in the 3rd class completes before it performs its job. How can this be achieved?
I had tried implementing a wait/not...
I have created in my Java Swing application a main window with a JButton. I have added to this button an event listener class (implementing the ActionListener interface) which, every time the button is clicked, launches a "pop-up" window.
The method works fine when the button is clicked, except when the button is clicked for the first t...
I'm making a custom button in Java that has two states, mousePressed, and mouseReleased. At the same time, if I wanted to reuse this button, so that other event listeners can register with it, are these the appropriate steps I should do (This is a hw assignment so although a JButton could be used, I think we are trying to show that we c...
This really puzzles me.
I have a JTextComponent for which I've added a right-click cut\copy\paste menu using a JPopupMenu and DefaultEditorKit.Cut\Copy\PasteAction().
JMenuItem cutItem = new JMenuItem(new DefaultEditorKit.CutAction());
JMenuItem copyItem = new JMenuItem(new DefaultEditorKit.CopyAction());
JMenuItem pasteItem = new JM...
Ok so I'm working on an Eclipse plugin based on the JGraph example. The problem is I can't really get the "save" method to work, here's how the program works in short:
- I have a DiagramEditor class with an init() method, where I create a GraphEditor object and call the createFrame() methord of that object.
- GraphEditor extends the Basi...
Hello everyone,
I try to show a ( Logged in ) message when a user is succefully connected but nothing happen when a do a repaint(). you can take a look to the code :
public class MainFrame extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private static final int FRAME_HEIGHT = 400;
...
JFrameWithPanel is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class JFrameWithPanel extends JFrame implements ActionListener
I Don't get this code. Book and Java site tells me this is the syntax for the method, but again this error shows up const...