How To Get Which Button Clicked In Through GetActionCommand When Button Have No Label
Sep 16, 2014
I have a JButton with a .PNG icon on it. I want to get that button click in actionPerformed Method but Jbutton have no Label... How i will know that which button clicked?
View Replies
ADVERTISEMENT
Oct 16, 2014
The gist of it is to create a very basic memory game. There are 12 buttons, each associated with an icon. Every button that you click will display the icon and will stay there until clicked again. I got the bulk of it taken care of, but my issue lies with switching the icons back and forth. I can get them to display one at a time, but when I click on a new button, all the icons except the button I just clicked don't display. Essentially, only one shows up at a time.
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.SwingConstants;
[code]....
View Replies
View Related
Mar 20, 2014
im trying to play a sound when button is clicked. here is the following code
InputStream in;
try {
in = new FileInputStream(new File("failure1.wav"));
AudioStream audios = new AudioStream(in);
AudioPlayer.player.start(audios);
} catch (Exception e) {
}
just wondering why it does load;
i do get the warning
warning: AudioStream is internal proprietary API and may be removed in a future release
AudioStream audios = new AudioStream(in);
warning: AudioStream is internal proprietary API and may be removed in a future release
AudioStream audios = new AudioStream(in);
warning: AudioPlayer is internal proprietary API and may be removed in a future release
AudioPlayer.player.start(audios);
View Replies
View Related
Jan 27, 2014
What are a couple of examples to code a button that if it's clicked the panel's visibility is set to false?
View Replies
View Related
Jan 13, 2014
How to add a new JButton in JFrame every time a button is clicked.
In simple words when a button is pressed in JFrame an other button with some specific location is created automatically.
View Replies
View Related
Sep 29, 2014
Okay i have done some research and have found that when using the JOptionPane, when the cancel or x button is clicked, the value is returned as null for the particular JOptionPane. It does not seem to work when I try to code it though, I have tried the following:
Java Code:
public static int getBoardType()
{
int boardType = 0;
String boardInput;
boardInput = JOptionPane.showInputDialog(null,
"Enter 1 (LongBoard), 2 (Shortboard), or 3 (BoogieBoard)." ,
"Dwelling Type",
JOptionPane.QUESTION_MESSAGE);
[Code] ....
If the "X" button or the Cancel button does in fact return a null value, why is the way I have this set up not working?
View Replies
View Related
Jan 29, 2014
How can i code this differently so that when i click one of the button it changes the image to the red.jpg or green.jpg?
Java Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class GUI{
public static void main(String[] args){
JFrame window = new JFrame("Test");
[Code]...
View Replies
View Related
Jan 9, 2015
I have a button whose text is being cutoff. How can I tell javafx that the button should be as big as the text in it and so no cutting off text happens?
View Replies
View Related
Mar 11, 2014
I have created a gui which accepts username in the text field and once clicking on submit button it fetches user details and throws it on gui via JTable.
But when i click submit for the second time using different username the background process goes well and good the vector that i pass to jtable changes with new data but the values in gui still contain the old data.
View Replies
View Related
Jun 2, 2014
why this code doesnt work? Its suppose to be a simple frame with a button that puts text to the frame when u click it. The problem is actionPerformed method, when it tries to call the stuff inside the constructor it all goes wrong. I switched the method body with a system.out.println() and it all works fine.
import java.java.awt.Label;
import java.awt.Button
import java.awt.BorderLayout;
import java.event.*;
public class TheClass implements ActionListener {
public TheConstructor() {
[code]....
View Replies
View Related
Mar 10, 2014
How can i add a background image for this code without disappearing the button and label? I want a frame that has a background and still shows the buttons and label that I place. and how can I insert Buffered Reader in this code, this is a file organizer, but it only shows first line of a text file. I want to show the whole text file. And is it possible to also show path of the file?
import javax.swing.JFrame;
import javax.swing.JButton;
import javax.swing.JTextField;
import java.awt.Color;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Scanner;
[code]....
View Replies
View Related
May 25, 2014
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class DisplayFinal_Panel extends JPanel {
private JLabel label1, label2, label3;
private JTextField box;
[code]....
I only want Listener 1 to work right now. Also, user input is in TextField.
View Replies
View Related
Feb 24, 2015
I am using JS, how we can make focus to a button during onload, the button need to get focus which is in tabbedPane tab Name : (Search Critera1) using javascript.
View Replies
View Related
Jan 17, 2015
I'm working on an applet for my class. I decided to use AWT even though it's really old.
I'm having trouble with the labels on my program. They don't show up until I click another tab in the browser and then go back to it each time after I click on a button. I tried to use repaint() but it doesn't seem to work. What can I do?
import java.awt.*;
import java.applet.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.awt.color.*;
public class FinalTwo extends Applet implements ActionListener{
Button b1;
Button b2;
[Code]...
View Replies
View Related
Nov 29, 2014
I am creating a mad libs type program. This section of code is for the user to be able to make their own mad lib template (that people will be able to fill out later). The normal blanks in a mad lib are for verb, noun, adjective, adverb, etc. I cam up with 13 or so of these buttons, but it would be nice that if the user wants to add a button that they think we missed, such as 'Person in the Room' or 'Silly Location'...that the user would be able to do this. I sort of pictured there being a button that says 'add button' or something like that. Is there a ways to do this with the way I've set things up?
public class MadLibs {
public static void main(String[] args) throws IOException {
////////////////////
//TEXT PANE WINDOW//
////////////////////
//Set up a JTextPane object : The JTextPane is a specialized form of the JEditorPane
//designed especially for the editing (and display) of styled text.
final JTextPane pane = new JTextPane();
[Code] ....
View Replies
View Related
Apr 22, 2014
i want value of button on button click..and value should be display on next page?? how to do that???
View Replies
View Related
Nov 6, 2014
I'm doing a software Java GUI - JFrame form like this:
1. The user wants to click on a button that opens a bunch of images that will be displayed as thumbnail in the bottom of the JFrame .
2. Then the user wants to select/click one of the thumbnail and make appear the corresponding image in it's original size on above(center) of the JFrame.
For doing this I used 3 JPanel.
One contains a JButton that opens the jfilechoser dialog window,
the second "panelPreview" is for putting the thumbnails created,
and the third "panelGrande" is for the image in it's original size.
The firs part "1." is ok.
But in the second part : I got one error when I want to put the ImageIcon in to the JLabel with the further intent of displaying it.
lblBig(imgIcoVett[i]);
In this project I'm dealing with arrays of ImageIcons and JLabels, so it's a bit advanced level for me, so I'm not sure that I wrote right the part of the MouseListener too.
The error displayed by netbeans says "cannot find symbol symbol: method lbl (ImageIcon) local variables referenced from an inner class must be final or effectively final"
Here I attach the project I did with netbeans"AAAD Unlayout 2.zip", but if you just need the highlight of the code, here it is too:
private javax.swing.JButton btnOpenfile;
private javax.swing.JFileChooser jFileChooser1;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblBig;
private javax.swing.JPanel panelGrande;
private javax.swing.JPanel panelPreview;
[Code] ....
View Replies
View Related
Sep 22, 2014
I dont know why this does not work. A string called naam is empty in the beginning. Thats why its NULL on the button. But if I give it the value "karel", it still states null on the button, how can I update this?
Java Code: import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Probeer {
private JFrame frame;
private JMenuBar hetMenu;
private JButton knop;
[code]....
View Replies
View Related
May 29, 2014
Im trying to use num as the text on the button..... (Im trying to make it count when i press the button.)I need to make a listener for the button, and an event that adds 1. (num++)
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.*;
import javax.swing.*;
public class ClickIt {
public static void Practice()
[code]....
View Replies
View Related
Mar 19, 2014
public void actionPerformed(ActionEvent ae){
float A=0;
int a = Integer.parseInt(tf1.getText());
if(ae.getSource()==b2) {
A=(((30*a*14) / 100)+(30*a));
[Code] .....
View Replies
View Related
Dec 14, 2014
I have gotten the code up and running, now I am trying to add a previous button. The next button I have now works fine but I can't seem to get the previous button to work.
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.PrintStream;
import java.util.Arrays;
[Code] .....
View Replies
View Related
Feb 26, 2015
The class gets complied but when I run the program the submit button doesn't work, how do i get that to work?
/**
* Orchestration class for Account
*/
import java.awt.*; //Importing the java.awt.* class
[Code].....
View Replies
View Related
Jun 10, 2014
end the loop with the ESC button.
import java.util.Scanner;
class Sum {
public static void main(String[] args) {
int sum = 0;
System.out.println("Please write a number, end with ESC button");
Scanner in = new Scanner(System.in);
[Code] ....
View Replies
View Related
Apr 8, 2014
I'd like open a second GUI when I press a button that's on the first GUI, like a link in a website.
What I want to do is:
1- Open GUI_1;
2- Press a button on GUI_1; this button close GUI_1 and open another GUI (GUI_2).
How can I do it?
View Replies
View Related
Nov 16, 2014
I am trying to check to see if the button has anything on it.
Line 81 says incompatible types: JButton cannot be converted to String ')' expected ';' expected
package PA7;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.*;
import javax.swing.*;
import java.awt.event.ActionListener;
[code]...
View Replies
View Related
Dec 8, 2014
I have created a program that allows a pizza shop to enter a customers orders (via 3 seperate panels of options), and calculate a total. Everything works just fine, and now we have to take it a step further and record the sale data in a .txt file (which will include the Crust Type, Toppings, and Extras).
I need to make it so that when a user clicks the calculate button, it also writes to a file (in this case, SalesRecords.txt). I have it all set up, but for some reason I can not get it to work. The error I get is:
"error: unreported exception FileNotFoundException; must be caught or declared to be thrown
PrintWriter outputFile = new PrintWriter(filename);
Here's my code: (the calculate button that I am working with is indicated by a comment)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.text.DecimalFormat;
import java.io.*;
import java.io.BufferedWriter;
[I looked up the exception I got, and just so everyone knows I made sure that the file "SalesRecords.txt" DOES EXIST. It is in the same folder as my java and class files for this program. I even tried defining the absolute file path for SalesRecords.txt and that changed nothing.
View Replies
View Related