actionevent

checking if a jbutton is clicked in another java file

六月ゝ 毕业季﹏ 提交于 2019-12-23 06:11:05
问题 good day everyone. I have many java files in a project in netbeans. One file is named mainFile while some are addSale, addAttendance. In my mainFile.java, I created an actionPerformed method to check if a button is clicked. But the buttons that I want to checked if clicked is on the other java files. I've added this code in my mainFile.java AddSales addSaleButton; Login logButton; public void actionPerformed(ActionEvent ae){ if (ae.getSource() == addSaleButton.getButton()){ System.out.print(

Java Hangman GUI not properly displaying [closed]

一世执手 提交于 2019-12-13 09:49:17
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 6 years ago . I'm having a couple of different problems with my code, most of them are GUI based problems but i do have one actionevent problem. I will post my code in sections first then I will point out what the issue is specifically with each section. *note all of my code will be in order of

Calling an ActionEvent

杀马特。学长 韩版系。学妹 提交于 2019-12-13 07:51:17
问题 I am in the process of learning and creating a custom JButton/Component. I have the most of what I need, except I do not know how to call actionPerformed on my ActionListners. Code: package myProjects; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Shape; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.geom.*; import java.util.ArrayList; import javax.swing.JButton; import javax

Assigning an action to each button, in an array of buttons in JavaFX

百般思念 提交于 2019-12-13 07:11:37
问题 I've created an array of ComboBoxes and an array of buttons in JavaFX. I'd like to assign each button of the array, to do something to the ComboBox of the corresponding index: for(int i = 0; i < 6; i++) { colorBox[i] = new ComboBox(); colorBox[i].getItems().addAll("Blue", "Orange", "Green", "Yellow", "White", "Red"); randomColorBtn[i] = new Button("Random color"); randomColorBtn[i].setOnAction((ActionEvent event) -> { colorBox[i].setValue(getRandomPlayerIconColor()); }); } So that whenever

ActionEvent of a component on a table cell doesn't take place

十年热恋 提交于 2019-12-11 23:23:35
问题 My code belongs to LWUIT apps but problem about something common between LWUIT and java swing. I have a table there is a Button set on the last cell of it as a component My question simply why is there no action takes place when I press that button. I tried checkbox also but I even couldn't do check. Button b,b2; Object [][] elhind; b2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { elhind = new String[1][9]; String elhind [][] = {{"Netherlands","Germany"

Getting the name of a JButton on click

前提是你 提交于 2019-12-10 11:15:21
问题 @Override public void actionPerformed(ActionEvent e) { if (e.getSource() == thirdBtn) { //System.out.println("Third Button Click"); System.out.println(e.getSource()+" Click"); } } In the code above, I was wondering if instead of doing this: //System.out.println("Third Button Click"); if I could do something like this: System.out.println(e.getSource()+" Click"); However the code outputs: BlackJack.OverBoard$BlackJackButton[,440,395,100x25,alignmentX=0.0,alignmentY=0.5, border=javax.swing.plaf

GUI not updating visually before running ActionEvent

旧城冷巷雨未停 提交于 2019-12-07 07:22:40
问题 To expound a little more, I have a GUI that looks like: Then I have an action listener on the OK button that starts like: //OK Button Action Listener private void okButtonActionPerformed(ActionEvent e) { //Enable/Disable Buttons okButton.setEnabled(false); cancelButton.setEnabled(true); updateCheckbox.setEnabled(false); //Move on to a series of other methods here... Which should, in theory, make this happen: However, instead, I get the following until ALL methods and other things connected to

Getting the name of a JButton on click

我只是一个虾纸丫 提交于 2019-12-06 05:46:22
@Override public void actionPerformed(ActionEvent e) { if (e.getSource() == thirdBtn) { //System.out.println("Third Button Click"); System.out.println(e.getSource()+" Click"); } } In the code above, I was wondering if instead of doing this: //System.out.println("Third Button Click"); if I could do something like this: System.out.println(e.getSource()+" Click"); However the code outputs: BlackJack.OverBoard$BlackJackButton[,440,395,100x25,alignmentX=0.0,alignmentY=0.5, border=javax.swing.plaf.BorderUIResource$CompoundBorderUIResource@7a3d8738, flags=16777504,maximumSize=,minimumSize=

GUI not updating visually before running ActionEvent

橙三吉。 提交于 2019-12-05 08:44:31
To expound a little more, I have a GUI that looks like: Then I have an action listener on the OK button that starts like: //OK Button Action Listener private void okButtonActionPerformed(ActionEvent e) { //Enable/Disable Buttons okButton.setEnabled(false); cancelButton.setEnabled(true); updateCheckbox.setEnabled(false); //Move on to a series of other methods here... Which should, in theory, make this happen: However, instead, I get the following until ALL methods and other things connected to the OK button are completed: This obviously can't happen, because the idea is to make the cancel

Android: OnTouch, MotionEvent.ACTION_MOVE is not recognized?

十年热恋 提交于 2019-11-30 04:35:28
Here is my code, I want to detect when my finger goes down the screen so when I touch the screen I detect the ACTION_DOWN but when I go down the screen with my finger, ACTION_MOVE is not recognized, neither ACTION_UP Do you know why? float x=0; protected void onCreate(Bundle savedInstanceState) { do things ImageView image2 = (ImageView) findViewById(R.id.imageView3); image2.setOnTouchListener(new OnTouchListener(){ @Override public boolean onTouch(View arg0, MotionEvent arg1) { if (arg1.getAction()==MotionEvent.ACTION_DOWN) { x=arg1.getX(); } else { if (arg1.getAction()==MotionEvent.ACTION