JButton 3 « Button « Java Swing Q&A





1. problem with JButton    forums.oracle.com

you need to take a basic java class, or if not that, go through several good beginners java books. From code that you present here and in multiple other posts that I have just reviewed, you do not have a basic grasp of the Java language or oop concepts. Unless you can get this nailed first, you are doomed to be ...

2. creating JButtons on call    forums.oracle.com

Instead of removing and adding components after validating the frame, I would either: 1) Use a CardLayout that contains a different panel for each of the required buttons. You can add them dynamically if needed. (More flexible if you want to change more than just that button later) 2) Use the same button, but change the label and Action so it ...

3. Typcasting to a JButton    forums.oracle.com

I'm playing with buttons and action listener, and I need to take a captured object and cast it as a JButton so I can use its positioning methods (I want to click one button, then another, and have them switch positions) public void actionPerformed(ActionEvent e) { Object selected = e.getSource(); //JButton temp = selected; } Can Objects be typecast in Java? ...

4. JButton    forums.oracle.com

Assuming you are creating your socket and printwriter and showing the frame, it looks okay to me... The buttons should show and the action listener should fire... Of course, your action listener should probably check to make sure which was pressed... Quit will just do the same as the others the way it is.

5. OS X and JButtons    forums.oracle.com

Hello, I'm new to Java, but have been working on a project and have encountered a strange situation when working with JButtons. I'm writing and testing my program in OS X 10.4. Essentially, I have four large buttons that make up the GUI of my program. I'm trying to set them to four different colors so that they will stand out. ...

6. JButton    forums.oracle.com

What it is happening is that I click on the button and it continue clicked and nothing more happen(OK ALSO does not appear), and only when I click again, the button returns and all the functions that I did in the constructor works fin and OK ALSO appear It works fine ok also if I click on the button, and after ...

7. Help on JButtons 2    forums.oracle.com

8. Help about JButtons    forums.oracle.com

9. JButton.... can't see the whole name    forums.oracle.com





10. Making JButtons    forums.oracle.com

Hi, I am pretty new to java, just started studying it for half a year... I have the following problem: I want to write a methode which adds a new button to a window. the mothod is something like this: public void addButton(Person tempPerson){ //Person is an object which has different attributes, such as name...etc JButton (at this place i want ...

11. Problem with my JButton....    forums.oracle.com

12. Adding identifiers to JButtons    forums.oracle.com

One standard approach is to call setActionCommand(String) when you create the button, supplying a unique String for each button. You can then use getActionCommand() in your ActionListener to determine which button was pressed. In fact by default, if you don't call setActionCommand, then from memory, I believe getActionCommand() returns the text of the button, which makes it very simple to use. ...

13. setWidth on JButton    forums.oracle.com

Hi... Can anyone tell me why I can't set the width of a JButton? I saw in the API documentation that JButton is supposed to inherit method setWidth from the Component class, but for some reason that method does not come up as a valid selection. Any help would be greatly appreciated. Thanks, Christine

14. how to call a JButton    forums.oracle.com

What do you mean when you say 'call' a button? If it is accessing the variable that holds a reference to the button, then define the variable so that it can be accessed from other classes or provide accessor method. Just curious, if that's what you want to do, what are you trying to achieve by providing access to the button? ...

15. JButton NullPointerException problem    forums.oracle.com

16. JButton    forums.oracle.com





17. Urgent help, please - 'Renaming' a JButton    forums.oracle.com

Subject: Urgent help, please - 'Renaming' a JButton I was going to post a reply but when I read your post title again, I noticed the bit about it being urgent, and realized I was already too late. In the future, I strongly recommend hiring a consultant for urgent projects. And of course, pay them an hourly rate that reflects ...

18. Help; Missing JButtons    forums.oracle.com

// Calculates the monthly payment private double CalcPAY(double AMNT, double APR, double TERM) { double MAPR = (APR / 100) / 12; // Formula for J double MTERM = TERM * 12; // Formula for N double PAY = AMNT * (MAPR / (1 - Math.pow((1 + MAPR), -TERM))); return PAY; } private double validateNumber(String numericString, String fieldName) throws Exception { ...

19. Links instead of JButtons    forums.oracle.com

20. JButtons    forums.oracle.com

Hi, so i have a program that has a picture in a JLabel set as the background to my program, and i have 3 button with png files as the icons on top of the JLabel. The button have 3 different pictures, one for non-active, one for when you hover of it and another one when you click on it, but ...

21. access to jbutton    forums.oracle.com

Hi, I try to get an access to jbutton control in jpanel or jframe. I have only name of this button. How can I do this? I tryied to use .getComponents() methods which returns table of components and then found this button in returned table. Unfortunately I had an error that there is no possibility to cast java.awt.Component to javax.swing.JComponent; Help!!! ...

22. Problem with JButton and NVDA    forums.oracle.com

I am using the following code and would like to hear NVDA and JAWS announce my button when I roll over it. The JFrame name and title bar components are announced, but that is all. Can someone help? import javax.swing.JButton; import javax.swing.JPanel; import javax.swing.JFrame; //import javax.accessibility.*; public class JFrameExample extends JPanel { public JFrameExample() { JButton aButton = new JButton("Button"); aButton.getAccessibleContext().setAccessibleName("Button"); ...

23. Adding logic to JButton    forums.oracle.com

24. JButton question    forums.oracle.com

25. JButton    forums.oracle.com

27. access to jbutton    forums.oracle.com

Hi, I try to get an access to jbutton control in jpanel or jframe. I have only name of this button. How can I do this? I tryied to use .getComponents() methods which returns table of components and then found this button in returned table. Unfortunately I had an error that there is no possibility to cast java.awt.Component to javax.swing.JComponent; Help!!! ...

28. jbutton problem    forums.oracle.com

29. How to make a JButton disappear?    forums.oracle.com

30. JButton    forums.oracle.com

I'm not sure if this is going to be helpful but let me ramble for a moment and see if it makes any sense. You could approach it from a standpoint of dragging instead of clicking on a button. Say for example you have an area defined by a JPanel and your critter is at a point defined by x,y. You ...

31. how to move JButtons    forums.oracle.com

also, I don't understand how to use the set location command. Do I use it in my paint method? I am new to programming. for example, if its in my paint methd, would I make do this. ex. paintmethodvariableName.setLocation (buttonNane, 100, 100); ?? Edited by: thedude051 on Jan 12, 2008 8:55 AM

32. Help with jbutton!    forums.oracle.com

Hi! i have a problem with jbutton. I create a jbutton with an icon, and afterwards i want to hide this icon to show a number. Then the initial image (the initial icon)has to be shown again after a few seconds. I was looking for a method that hides the icon but i cant find it. I dont know if it ...

33. JButton Question    forums.oracle.com

I m trying to write a simple piano, so i will need some black keys on top of the white keys. So far, the black keys barely appear on top of white keys, but doesnt always stay on top. Like when my mouse go over the white key, the white key will go back on top of black key.

34. Using RepeatButton (JButton subclass)    forums.oracle.com

35. JButton problem    forums.oracle.com

36. jbutton and inputevent    forums.oracle.com

Hello, I'm trying to make a button which when clicked does one thing and if its clicked while the alt key is pressed, it will do another. I know how to do the first part with actionListener but I'm having trouble on the second part. i read about the inputEvent class which has a isAltDown() method but i dont know if ...

37. JButton in side JTabe    forums.oracle.com

Hi all, i created JTable & put JButton column inside it by using the cell editor & cell render, but the code of the actionPerformed method of the jbutton is not executed. the following is the code for cell editor public class ButtonEditor extends DefaultCellEditor { protected JButton button; String label; boolean isPushed; public ButtonEditor(JCheckBox checkBox) { super(checkBox); button = new ...

38. Problem using a JButton object(s)    forums.oracle.com

39. Quick question about JButton...    forums.oracle.com

All right, so I'm in my first year second semester of computer programming. On Monday of this week we had a test on this test we had this question: Which of the following methods does JButton not have? (A) setLabel() (B) setEnabled() (C) setText() (D) setVisible() Now.. I may only be a programming one student but I have taken it upon ...

40. help needed on jbuttons    forums.oracle.com

sorry... this is not what I want .... i have made two classes .... sad and smile in which i have generated 2 faces... i have to put 2 jbuttons amile and sad now. so when i click on smile smile face appears and when i click on sad the sad face appears thanks

41. Javax JButton Problem    forums.oracle.com

42. JButtons    forums.oracle.com

43. JButtons    forums.oracle.com

I'm confused by what you're trying to accomplish. Do you want to have both an applet and a frame displayed? They're meant for different purposes, frames for desktop apps, and applets for web apps. If you just mean where in the code do you create the objects, then a good design will almost always have them in the applet or frame ...

44. setAccelerator on JButton    forums.oracle.com

45. JButtons passing URLs    forums.oracle.com

Can anyone tell me if a JButton can pass a URL for a browser in Java? I've expended my knowledge on the subject. I thought an action listener communicating with a string would do the trick when it noticed the button was clicked...? Totally lost. Any help would be appreciated. I've been working on this for a week and am burnt ...

46. a problem about Jbutton    forums.oracle.com

47. referencing a JButton by name    forums.oracle.com

for(int i=0; i<24; i++){ if(i%4==0){ if(i!=0){ this.add(new JLabel(""),c); c.gridy++; row++; column= 1; } this.add(new JLabel("" +j++, JLabel.CENTER),c); } JButton b = new JButton(" "); b.setName(column + "_" + row); b.setMnemonic(KeyEvent.VK_E); b.setActionCommand(column + "_" + row); b.addActionListener(this); this.add(b,c); column++; } . . . public void actionPerformed(ActionEvent e) { String str = new String(e.getActionCommand()); tf.setText(str);

48. Adding JButton    forums.oracle.com

49. Question about two JButtons...    forums.oracle.com

50. Help with JButton    forums.oracle.com

51. JButton problem...........................    forums.oracle.com

52. JButton issues    forums.oracle.com

53. accessing a JButton in another class    forums.oracle.com

54. JButton user input problem!!    forums.oracle.com

} } the message box displayed this instead of the calculation: (days+airfare+fees+miles+parkfees+taxi+regfees+lodg)-(meal*days+park*days+charg*days+lodgcharg*days+carmile*miles) Here is my updated code: { package Travel_Expenses; import java.awt.*; import javax.swing.*; import java.awt.event.*; public class Expenses1 extends JFrame { private JTextField days; private JButton button1; private JButton button2; private JButton button3; private JButton button4; private JLabel messageLabel; private JLabel gmessageLabel; private JLabel cmessageLabel; private JLabel dmessageLabel; private JLabel ...