2,962 questions
2
votes
1
answer
100
views
Have long text scroll to the right when using JTextField .setText()
I have a JTextField for displaying the path of a selected folder. It's intentionally disabled (as the folder is supposed to be chosen with a JFileChooser), and when the program starts, a default ...
2
votes
1
answer
61
views
JScrollPane auto scroll to bottom using JEditorPane but remains to top using JTextField
I have a simple JFrame with a JPanel inside a JScrollPane. The JPanel is used to show a vertical list of either JTextField or JEditorPane components:
public class Test {
void showFrame() {
...
0
votes
1
answer
70
views
Adding an exception for blank strings to NumberFormatter
I have a JFormattedTextField that I want to only receive integer inputs (it will refuse anything else).
NumberFormat test = NumberFormat.getIntegerInstance();
NumberFormatter test2 = new ...
-1
votes
1
answer
80
views
I'm making a Guess a Number Game in Java Swing and I'm having problems the JButton [duplicate]
The program technically works, but I keep getting the error:
"Cannot invoke "javax.swing.JButton.addActionListener(java.awt.event.ActionListener)" because "this.check" is null&...
-1
votes
1
answer
78
views
Why does my window in Java (JFrame) crash when i double click on a JTextField?
I wrote this little program for an specific utility, didn't optimize it yet but so far everything works as intended, but when I accidentaly double click on JTextField it crashes, and I have no idea ...
1
vote
2
answers
76
views
How to assign a class variable using the value obtained from JTextField in Java
import javax.swing.*;
import java.awt.event.*;
public class Test {
private String textFieldValue;
public Test() {
JFrame frame = new JFrame ();
JPanel panel = new ...
1
vote
1
answer
62
views
JTextField able to set invisible but can't be set visible
as you can tell I am fairly new to Swing and ran into a small issue when building. Basically I want the user to be able to click on a button and a text field will appear. The issue is when I do ...
0
votes
0
answers
55
views
JPanel fails to display properly after inputting text into a JTextField
I created a GUI using Java Swing and MigLayout that features a button ("Add new competitor") to add boxes containing JTextFields for user input. It initially starts with one such box, and ...
0
votes
0
answers
126
views
Inputting unicode characters into JTextField
In most situations I can enter Unicode characters by typing ctrl-shift-u followed by the hexadecimal character code. So for instance by typing ctrl-shift-u 2264 here in the browser I get "≤"....
0
votes
1
answer
30
views
how do i make my g.drawline draw ontop of my JTextFields in a JFrame
i am attempting to make a soduku solving java program. i want it to be graphical and graphical isnt an area ive really explored before.first ive created a graphics method to draw all my needed lines. ...
0
votes
0
answers
56
views
Textfield Sometimes Highlighted When getFocusInWindow() Called
I have a vertical BoxLayout with a few JTextfields. Whenever one of the fields is edited, I would like the field to come to the top: I do this by removing the field and re-adding it to the top. ...
0
votes
1
answer
58
views
Continue Detecting Input with KeyListener While Typing In a JTextField
I'm currently working on a small utility window for another application and I'm running into the issue that KeyListener input stops detecting input while a user is focused on a JTextField.
I've made a ...
1
vote
0
answers
83
views
How to set Bengla SutonnyMJ font in JTextArea in Java Swing?
"In my Java Swing project, I have a JTextArea which is jafAddress. In this JTextArea field, I set the font to SutonnyMJ Bangla font. However, when I write Bangla text into the JTextArea, Bangla ...
1
vote
1
answer
55
views
JTextfield.getText() not returning any value
I am relatively new to java, so i'm not the best at it. In my program, I have a board with an Array of JTextfields in which a player enters values and when they press the button, if it is a valid ...
1
vote
0
answers
44
views
Is it possible to move the cursor to the end of the TextField in the textfield_tags package?
I've been having this problem for several days. I implemented the package, but I want to adapt it to my requirements. Each of the tags should be seen on the screen, one below the other, vertically.
...
2
votes
1
answer
145
views
How to make half rounded border?
I have a RoundPanel class that extends JPanel and provides a rounded appearance.
JPanel user_icon = new RoundPanel(8);
user_icon.setBackground(Color.decode("#363b41"));
user_icon.setBorder(...
0
votes
3
answers
109
views
How to Edit JTextField Background in JFileChooser for File/Folder Name Editing
I'm working with a Java Swing application and facing a challenge with customizing the JFileChooser component. Specifically, I need to change the background color of the JTextField used for editing ...
0
votes
1
answer
65
views
I want to use What is being entered from the jtextfield as an array lists in another class
If i try and add the jtextfield to another class after hitting my submit button it wont work because the other class trys to take the array list before it is updated
import java.util.*;
import java.io....
0
votes
1
answer
65
views
JTextField is too small/ can't seem to format it
I am trying to format these JTextFields, and they were working fine. Whenever I add the 4th and 5th rows however, the JTextfields become like 1 character long (like in the screenshot). I don't see any ...
0
votes
1
answer
90
views
When i compare the getText function of a JTextField with an equal String, it doesn´t return true [duplicate]
So i have this calculator (on Java) and when i press a button i wanna check if in the JTextField(pantalla) is only "0" so i can replace it with the number instead of concatenate the button i ...
0
votes
0
answers
42
views
How to set limit of length inside JTextField? [duplicate]
I'm working on a Java Swing application that involves the use of JTextField for user input. I want to restrict the minimum and maximum length of text that users can enter into the JTextField component....
0
votes
2
answers
130
views
Trouble with String Builder: Filtering Characters in Java Swing JTextField
I'm fairly new to Java and stackoverflow.
Please alert me if I make a mistake or if I provide insufficient information.
I'm working on a Java Swing project and trying to use a custom DocumentFilter ...
0
votes
0
answers
138
views
Setting Formatter or FormatterFactory for JFormattedTextField still doesn't restrict the characters I type to the format I define
I have a Renderer class that extends JFormattedTextField
In its constructor I set up Formatter and FormatterFactory in order to pass the input format limitations, but still have ability to input ...
0
votes
0
answers
40
views
Solved: How to add a loop in a JTextField? What is the right method? [duplicate]
I would like to validate with each change the size of the text, perform an action! I put one while isolated, 2 ifs inside an ActionListener, created a separate method and it didn't work. The idea is: ...
0
votes
1
answer
95
views
JTextField and DocumentFilter: how to limit document length by having extra characters drop off the end of the string
I have been looking through a lot of DocumentFilter examples, and have realized that my needs are a bit unusual:
Three characters, maximum
Only digits, 0-9, nothing else
Automatically zero-filled to ...
1
vote
0
answers
34
views
how to place a JLabel in a Jframe that stays in the center even if you resize the jframe
when I open my program the buttons, fields and labels are statically positioned. when I expand the JFrame the buttons, fields etc. are positioned badly.
of course I tried to place them manually. but ...
-1
votes
1
answer
256
views
JTextField not giving output [duplicate]
When is try to get an input from the textfield it gives me an error message:
"Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException:
Cannot invoke "javax.swing....
-2
votes
1
answer
33
views
How to add mutiple JLabel's inside JFrame [duplicate]
I'm having trouble adding my other JLabels and JTextFields in the JFrame.
In my code I am trying to calculate the area of a triangle and want the user to add in the numbers for the sides. I have ...
0
votes
0
answers
56
views
Translucent panel Java swing
I tried to create a translucent panel in java swing covering and underlying panel, but I've a problem: If, for example, there is a jtextfield in the panel below and the text of this component is ...
-1
votes
1
answer
146
views
Text Field is not displaying text entering through keyboard in Java swing. I have set the text field editable
void addClick(JTextField field,String s) {
field.addMouseListener(new MouseInputAdapter() {
public void mouseClicked(MouseEvent e) {
//when user clicks on amount text field,
...
0
votes
1
answer
58
views
How to add local variable inside mouseclick event?
Here I want to call addComponents(i), but it says i is undefined inside the mouseClicked event function.
Exact error:
local variables referenced from an inner class must be final or effectively final
...
-1
votes
1
answer
105
views
KeyListener not responding after value modification in JTextField
I'm writing a program in java that opens a window and detects keystrokes.
However, there is one fatal problem. if i modify the value in TextField, KeyListener will not work again. Here is the code ...
0
votes
1
answer
87
views
How to rectify "over-sensitive" JTextField input issue
I've just come over to JAVA from BASIC, so please forgive me for any convention issues with my coding.
I have a mildly infuritating GUI-related issue. I have constructed a matrix-multiplication ...
0
votes
0
answers
50
views
How to display jtextfield content on jtextarea
this the GUI
I am trying to display the the inputs of my Jtextfield onto the text area but the contents are not displaying
this is my code
import javax.swing.*;
import java.awt.*;
import java.awt....
-1
votes
1
answer
44
views
Autocomplete does not load data correctly
I have a problem with the following code, if filtered data appears to me, but it only filters it when the jframe starts, but not when I add a new one, I have to close the jframe and reopen it so that ...
0
votes
1
answer
73
views
JTextField is not outputting all of the desired outputs
I am new in Java and currently studying and trying out GUI. I have this problem that converts multiple integer into separated with comma. example is: 12333 = 1,2,3,3,3. It works in System.out.print ...
0
votes
0
answers
47
views
Get JTextField input to System.in of different Java-program run by main program via console command?
I'm trying to code my own little Java IDE in Java. I'm pretty far for what I want, because I only want to be able to code simple command-line-programs in my IDE.
My current problem has to do with user ...
0
votes
1
answer
63
views
Comparison of texts of a jtextfield with an autocompletion
I would like to know if there is a way to have a text validator, not the equals exactly, because I know if I do one by one it would take me a lifetime, but to validate all the autocompletion that I ...
-2
votes
1
answer
54
views
JAVA about select. please Help me [closed]
First I want to make second select function in my java. first is SelectAll which show all data of my DB.
and second is select which show data that fits the conditions.
Second I want to make a Checkbox ...
-1
votes
1
answer
38
views
Java jTextField sum [closed]
We are working on a bookstore project. Looking at the code below, I need to add up all the DB values in the price column and then output the value to the jtextfield. How should I write the code...?
...
-1
votes
1
answer
114
views
How can I synchronize two JTextFields in Java swing?
I'm trying to synchronize two JTextFields. If I write in one JTextField, I want to write the same text in other JTextField simultaneously.
I'm not sure what event use for this requirement.
My example ...
0
votes
1
answer
357
views
jTextFIeld bottom line border only
I'm wanting to create a jTextField that only has a bottom black line for a border in the simplest way possible. createLineborder doesn't seem to have a parameter for only the bottom line. ...
0
votes
1
answer
36
views
How to add what is inputed in a JTextField to a variable?
package basics;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.text.Caret;
import java.awt.BorderLayout;
import javax.swing.JButton;
import ...
0
votes
1
answer
68
views
JFormattedTextField wrong caret position when i type the first number
I have modified NumberFormatter to have like a currency instance (with prefix).
When I write the first number, this application have add the prefix to the number
JFormattedTextField Empty
but when I ...
0
votes
1
answer
107
views
How can I access the parent's field in another class and change it?
)) I'm new to Java, And I have such task:
Create a text field component class. In the constructor, the default string must be set in the text field.
When clicking on the field, this record should be ...
-1
votes
1
answer
347
views
Storing JTextField input in a String variable
So I want to store a string value in a variable, the value is given through a JTextField and after a confirm button is clicked, I want it to store what's written in the text field in a string variable....
-1
votes
1
answer
48
views
How do I add something written on a JList to JTextfield by clicking on a JButton? [closed]
I'm making a program to insert users into a PostgreSQL database using NetBeans, and recently I've faced a problem that I'm asking myself if it's possible to fix? Basically, I wanted to select ...
0
votes
1
answer
73
views
Is it possible to limit in a JTextField the area where characters can be inserted?
I've a JTextField with a JButton positioned inside of it on the east side. At the moment, when characters inserted reach the button the part of the text overlapping is inserted below of it.
Here a ...
0
votes
1
answer
56
views
How to provide addKeyListener() to a multiple JTextFields without writing the same code over and over again
private JTextField f1TextField;
f1TextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
...
0
votes
1
answer
85
views
Set size of JTextField with BoyLayout Manager. Java
I have seen this question been answered. but not for BoxLayout.
I have created a schedule app in Java and because I want to display every hour under each other, I have chosen BoxLayout. When every ...