I have a Panel in JFrame which consists of a TextField. I want this text field to be initially focused when GUI starts so that i should not have to first click in it before writing something.
I have 1 textfield and 1 button on a JFrame and having 10 such frames stored in ArrayList al and getting the JFrame instance from traversing the ArrayList at execution time ,So is there a way to access textfield using JFrame instance or i have to name the textfield diffrently 10 times for each frame .
Okay so I have the codes all written but I didn't really look at that I had to color the center of the frame. I have base code for it but it just doesn't want t ocolor the cnter frame for me for some reason. I have been looking around and still am having problem with it only coloring the center of the frame.
Java Code:
import java.awt.event.*; import javax.swing.*; import java.awt.*; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; public class MenuColors {
I want to switch panel on click of a button and code for switching panels is written in update method (Which gets called from notify observer of another class as part of Observer pattern.
playGame in Panel 1 of class 1 calls another class (class 2)and data comes in update method of class 1(Observer interface).
Now for switching panels code is in gameControllerDataProcessing . I am not able to switch the panels when this functionality runs.
However if i dont call the unoGameController.playGame(playerFirst.getText(), playerSecond.getText() and directly call the update method or directly write the switching panel code . then it works fine.
When i click on the button from bottom panel, top panel need to be redrawn. But redrawing is not happening. It happens only when resizing the applet.
public class Graphics_Chart(){ public init(){ JScrollPane topPane = new JScrollPane(new ImagePanel2()); topPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); topPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_NEVER);
String sql = "SELECT * FROM user WHERE username =? and password =?" ; pst = conn.prepareStatement(sql); pst.setString(1, username.getText()); pst.setString(2, password.getText()); rs = pst.executeQuery(); if(rs.next()){ do somethig; {
I have 2 textfield that take username and password, on the database thete is a user table
id username password name surname
1 test test test test
people put username and password to the textfield like test test and they logon,but when they write username = TESt and password = teST they can logon too,there is no TESt user on the database or teST password, is the textfield making lowercase all text. or pst.setString(1, username.getText()); is this code changing the text?
When in panel2 i type something in the search bar and then i move mouse cursor to panel1 and try to edit a JTextField input for example as in the picture 0.0 nothing happens but the mouse cursor is correctly show up in the JTextField.. What seems to solve the problem is to click anywhere outside of the application window.. but of course this is not a solution !
I am working on a keypad for a phone app for school. I cannot get the numbers from the keys to show up in the textField. I have made multiple tweaks, but think maybe my case statement is the problem?We did a calculator application in the class, so I have based my code off of that. Although the telephone keypad seemed much simpler to code, I can't seem to get the numbers to show up.
public void actionPerformed(ActionEvent e) { //test for button clicks foundKey = false; //search for clicked key for (int i=0; i<keys.length && !foundKey; i++)
Trying to make a swing box where you can type in string data to the text field and a button. I want the string data to be added to a list everytime you press the addbutton.
How to use validation on a label or textfield in java.
I have a textfield and i want that only username with @ sign will be taken by the program or gives an error.or a textfield that can only take numeric values or whatever the developer wants to take from user..
How to use the textformater class together with a TextField. I need to filter and format a currency value in a TextField an try it with the text formater, but I'm not really successful at the moment.
package name;swing library found in javax called to use the graphical contents.
import javax.swing.*; //creating the contents for the calculator public class calc { JButton btn1= new JButton("1 "); JButton btn2= new JButton("2"); JButton btn3= new JButton("3");
[code]....
I have tried different sizes for the 'TextField' but when I change the size, the position changes instead of the size itself.
How can I make the numbers to stay at the textfield of my calculator instead of disappear like when I type 1 then hit the + sign the number 1 disappears from the textfield I would like to have this (1+1) showing in the text field and also if try to press only + , * , - , / to show error.
What would be the simplest way of creating a Dialog that can add TextField dynamically based on whether a radio button option from the dialog box is selected. I thought of JOptionPane.showMessageDialog and adding a JComponent though I would not be able to add a TextField on the fly and I would not be able to add ActionListeners. The dialog would initially contain some radio buttons, labels and textfields.
I'm trying to make a stock program that stops the user from entering in textfield and displays a message when stock is low. There's just 2 problem the entered value by the user is only decremented twice then the total stock resets for example with SofaTotal and the if statement doesn't work: