method « Event « Java Swing Q&A





1. GUI - actionListener method    stackoverflow.com

I'm trying to create a simple GUI with a menu bar at the top of the jwindow using java. I'm able to get the menu bar to show and I'm able ...

2. problem with fireStateChanged() method for JSpinner    stackoverflow.com

I have a problem invoking the fireStateChanged() method for a JSpinner. I create a JSpinner and when I try to invoke fireStateChanged() method for that spinner someSpinner.fireStateChanged();, eclipse shows me this ...

3. Calling a method from a class outside my GUI form in netbeans    stackoverflow.com

I'm a little bit of a netbeans GUI noob so please bear with me. I have written a program with multiple classes containing methods which I want to 'link' to buttons in ...

4. Is it possible to call Swing Listener's methods remotely via RMI or with other networking technology?    stackoverflow.com

These methods belongs to ActionListener and PropertyChangeListener. i need to realize these two cases and similar with other swing classes. the server should call this method for each client, when ever some ...

5. Oval from fillOval method isn't showing up in my GUI    stackoverflow.com

my connect four game has an issue. I figured out the method that when a user clicks on a box a red or blue oval should appear but when I run ...

6. java @action method parameters in netbeans    stackoverflow.com

I have @Action for example:

@Action
public void example(String name){
//sth to do
}
and I would like to add this method to button generated in netbeans. When I click to Customize Code and write:
myButton.setAction(example(myButton.getName()));
I'm getting ...

7. How to remove actionPerformed methods in NetBeans    stackoverflow.com

When a JButton is added to a content pane, we can set an action by double clicking the button or Right click->Event->Action->actionPerformed.Let say, we set somthing to happen. Then we need ...

8. Action Performed Method    coderanch.com

having trouble doing the action performed. Tryin to call object for play and reset button. import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Assmt4 extends JApplet { int select; int lottoNum[] = new int [6]; public void init() { Container container = getContentPane(); container.setLayout(new FlowLayout()); JLabel numberLabel = new JLabel("Enter 6 numbers between >1 and 53<"); container.add(numberLabel); JTextField[] numberField = new ...

9. help with mouse methods in paint    coderanch.com

im trying to create a program what when the mouse enters the left side of my window the background should change to red; if the mouse moves into the right side i need to change it to green. once i find the size of my window by saying d = yourFrame.getSize(); where do i calculate to find which side my mouse ...





11. help with actionPerformed method.    coderanch.com

Consider posting less code, a lot less code, and using code tags to allow your posted code to be readable. I always find that in a situation like this, it helps to create a small sample program that has maybe 1 or 2 buttons in the small GUI class, and almost trivial model and controller classes just to allow me (or ...

12. Explicitly throwing events & calling listener methods?    coderanch.com

import java.awt.*; import java.awt.event.*; import javax.swing.*; /* */ public class AppletDemo1 extends JApplet implements ActionListener { JTextField text=null; Container pane=getContentPane(); public void init() { text=new JTextField(25); //pane.setLayout(new FlowLayout()); pane.setLayout(null); JRadioButton buttonone=new JRadioButton("AnnotationEnabled"); buttonone.setBounds(50,50,200,30); //x,y,width,height pane.add(buttonone); buttonone.addActionListener(this); JRadioButton buttontwo=new JRadioButton("AnnotationDisabled"); buttontwo.setBounds(260,50,200,30); pane.add(buttontwo); buttontwo.addActionListener(this); //add textbox to the container panel pane.add(text); text.setBounds(50,90,100,30); ButtonGroup buttongroup=new ButtonGroup(); buttongroup.add(buttonone); buttongroup.add(buttontwo); } ...

13. mouseEntered method    coderanch.com

import java.awt.*; import java.awt.event.*; public class TestII extends Frame { public TestII() { super("buton example"); Button b1,b2,b3; Panel p; Label l; System.out.println("testing"); b1=new Button("A"); b2=new Button("B"); b3=new Button("C"); p=new Panel(new FlowLayout()); p.add(b1); p.add(b2); p.add(b3); this.add(p,BorderLayout.NORTH); l=new Label("some label"); msHandler h=new msHandler(l); b1.addMouseListener(h); b2.addMouseListener(h); b3.addMouseListener(h); this.add(l,BorderLayout.SOUTH); } public static void main(String args[]) throws Exception { TestII t; t=new TestII(); t.setSize(300,200); t.setVisible(true); t.addWindowListener( ...

14. How to use method in ActionListener    java-forums.org

I have a calculator.java file and calculatorGUI.java file. In the calculator file, I've got Java Code: import java.util.Scanner; import java.lang.Math; public class Calculator { Double total = 0.0; Scanner scan = new Scanner(System.in); public void add(double numberToAdd) { total += numberToAdd; } public void minus(double numberToMinus) { total -= numberToMinus; } public void divide(double numberToDivide) { total /= numberToDivide; } etc.... ...

15. action performed method for    java-forums.org

my code consists of two frames which consists of 3 textfields and 1 button. when the button is clicked i want to extract the values in the textfields and store the values in 3 different variables. now there is only one action performed method in my code but i want two action performed methods for two different frames. when i try ...

16. getClickCount() problem within mouseClicked method    java-forums.org

Hi guys..... I have little but strange problem, which I can't solved. Java Code: public void mouseClicked(MouseEvent e) { JTabbedPane pane = (JTabbedPane)e.getSource(); //line 1 //String tabTitle = pane.getTitleAt(pane.getSelectedIndex()); fi.jpmsgTxtPane.setText(pane.getTitleAt(pane.getSelectedIndex())); if(pane.getTitleAt(pane.getSelectedIndex()).equals("DRAW")||pane.getTitleAt(pane.getSelectedIndex()).equals("DRAG")||pane.getTitleAt(pane.getSelectedIndex()).equals("MEASURE")){ fi.sdmFlag = pane.getSelectedIndex(); } else{ fi.sdiFlag = pane.getSelectedIndex(); } // line 12 fi.mouseGetX = e.getX(); fi.mouseGetY = e.getY(); final int clickDelay=100; //delay in msec before processing events if (e.getClickCount() == ...





17. ActionListener to call a method from a different class?    java-forums.org

Java Code: import javax.swing.*; import java.awt.*; import java.awt.event.*; public class LoginGui { public JFrame frame; public JPanel jp; public JTextField username; public JPasswordField password; public JButton login; public LoginGui(){ frame = new JFrame("Login"); jp = new JPanel(); frame.setContentPane(jp); username = new JTextField("username"); password = new JPasswordField("password"); login = new JButton("Login"); login.addActionListener(new MyActionListener() ); frame.getContentPane().add(username); frame.getContentPane().add(password); frame.getContentPane().add(login); frame.setSize(400,400); frame.setVisible(true); } private class ...