Questions tagged [swing]

30832 questions
1

votes
0

answer
270

Views

Adding Google recaptcha to Java Swing

I'm doing a swing client to connect on a site, but it have a recaptcha. So I'd like to grab this recaptcha and put on my application, maybe on a webview, so the user can make it. To manage that, I make a GET request to the site where the captcha are and get the data-sitekey, send this key to my serv...
Felpsaps
1

votes
0

answer
68

Views

How to add JPanel to Graphics?

How can i add JPanel with JButtons to Graphics? I only want to add JButtons, becouse i want to make pause menu. Window Code: public JFrame frame; private BufferedImage image; private Canvas canvas; private BufferStrategy bs; private Graphics g; public Window(GameContainer gc) { image = new BufferedI...
Norbert
1

votes
0

answer
93

Views

How to use Google login API in java desktop application

how to login with Google API in java desktop application.I have generated API code and secrete key but i don't have any idea how to use it in java desktop application?
ritu
1

votes
0

answer
30

Views

JButtons keep resizing in the gridBagLayout after adding a border triggered by a mouseEvent

I have a JPanel split into 3 Cells. Flure is on on the leftPanel of each cell in each of the 16 Particles. Flyr is on the rightPanel of each cell in a 4 by 4 grid. I'm having trouble trying to get my buttons (Flure and Flyr) to not resize whenever I set the border. The border is set whenever the but...
Pvo
0

votes
2

answer
21

Views

How to load exact number of rows to jTable from MySQL and paginate the remaining?

I am trying to load data from MySQL into my Application, where I have a jTable. I want to load only 100 rows using a query, and I can do that successfully as of now. furthermore, I want to paginate that data, in such a way that if I have the next button, and I click on that, the table should be upda...
Hefaz
0

votes
0

answer
6

Views

How to print multiple JTables to a single page when space is available

I have a java application with 2 JTable. The first table is made up of 2 columns and 5 rows always. The second JTable is made up of 4 columns and many columns. I want to print JTable 1 above JTable 2, then continue to print the rest of JTable. How would I do this? From a printable page perspective...
IamAUser12
1

votes
0

answer
21

Views

Force dock name on Fedora with Java Swing

I have a Java Swing application running on several OS. On Fedora, when I start the application the Java main class is displayed with dashes as a menu next to the Applications and Places menu. How can I force this name to be my application name and not the Java class with the full package before? On...
Daniel
1

votes
0

answer
39

Views

how I could getext from menu item when click in groovy

I'm trying to get text with this code but appears error No such property: menuItem for class: Testgroovy How i could correct this error import groovy.swing.* import javax.swing.event.* new SwingBuilder().edt { def fillMenu = { -> scripts.removeAll() String megah='' new File('main/groovy').listFiles(...
user8862613
1

votes
1

answer
289

Views

Calling IntelliJ Swing Forms from another class

I'm just starting out with Java and I've run into this concept that I don't understand. I want to know how I can open a form developed with IntelliJ's Swing Form editor from another class. See below this code works fine in one class. import javax.swing.*; import java.awt.event.ActionEvent; import ja...
Ben Yazolli
1

votes
1

answer
36

Views

JTextArea Output

Good Evening, What can I do to have the output from jTExtArea like in the console? You can see the image how it is, I use .append to show the output in jTextArea Image Code: public void actionPerformed(ActionEvent e) { if (e.getSource() == b1) { for (int i = 0; i < a.pattern_cnt; i++) { for (int j =...
John Coffey
1

votes
1

answer
55

Views

Java - Set JFrame Opacity from JMenuItem

I'am trying right now to set the opacity of a JFrame to 50 % from a JMenuItem. My Last try was this: op50.addActionListener((ActionEvent y) -> { setUndecorated(true); AWTUtilities.setWindowOpacity(this, 0.5F); }); But no matter what I'm doing, I run into an java.awt.IllegalComponentStateException E...
xcynthos
1

votes
1

answer
42

Views

Java-FX MenuBar in JFrame/JFXPanel : First click not recognized

I want to place a JavaFX MenuBar over a JFrame (Netbeans RCP). So I have placed a JFXPanel on the JFrame and have kept the FX Menubar over that. But whenever I click the Menu (when it's not focussed), the first click doesn't work. Only the after I click twice, the Menu is shown. [Answer / a work-ar...
Arun Pratap
1

votes
0

answer
63

Views

JSplitPane in JLayeredPane

I want the right content of an JSplitPane to fill the entire available space and the left content (panel) to be on top of the other panel. I was thinking about using a JLayeredPane to solve that problem but I couldn't get it to work. My class currently looks like this: public class LayeredPane exte...
Ubuntix
1

votes
2

answer
48

Views

Dynamic changing of layouts in swing

I am almost certain this question was asked before here: Java Swing: How to change GUI dynamically , but I seem to just have some fundamental misunderstanding in how it works. import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class JTest extends J...
goinginsane
1

votes
0

answer
66

Views

Scala Swing scrollbar for TextArea

I'm trying to add a scrollbar to a text area component. I could use FlowPanel, but I need to use GridBagPanel for my other components and when I tried to add a flowpanel inside the gridbagpanel it was empty and like 2x2 pixels. Is there a way to add two panels to a MainFrame or add the scrollbar so...
Alqio
1

votes
0

answer
34

Views

ActionListener from controller doesn't trigger

I have an MVC with swing project with two views, a model and a controller. The controller has as fields a list of models, and a list of views. I tried to add a listener on a button from one of my views: private void initializeNewOrderListeners() { NewOrderView view = (NewOrderView) views.get(0); JBu...
user30771
1

votes
0

answer
72

Views

JTable column sorter shows two arrows

I am using JTable and for the column I am allowing multiple row selection and allowing the table to be sorted. The table has a column which is Boolean(check-box). When this check-box is unselected for all the rows and I sort the table by any of the columns then I can select the rows correctly. But w...
1

votes
0

answer
50

Views

Clear text when you press the JTextField

I'm trying to get the text of the JTextField erased every time I click on it. I made a addFocusListeneBut no word comes out. I do not understand why nick = new JTextField('nick', 5); add(nick); nick.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { nick.setText(''); } pu...
zzxbx
1

votes
1

answer
243

Views

Java How to add menuBar to JFrame without destroying my layout

I need some help with adding a menuBar to my JFrame. I have my Gui class: public class Gui extends JFrame implements KeyListener { private PanelMiniMap map; private CardLayout cardLayout = new CardLayout(); private JPanel cards; public Gui() { this.setSize(1000, 800); this.setDefaultCloseOperation(E...
user3793935
1

votes
0

answer
45

Views

Empty JFrame when adding JLabel & JTextField to it [duplicate]

This question already has an answer here: How to align JLabel-JTextField pairs vertically 7 answers Arrange the Label with its respective field Swing 6 answers Setting JLabels in rows and placing the equivalent JTextField right next to it 2 answers So I am supposed to make a very simple fillout f...
Some Student
1

votes
0

answer
168

Views

Message console on JFrame does not work by double click on jar

So I created a message console. And used append to display messages and it works perfectly by running java -jar JavaProgram, however when I double click on it the application runs and I see the JFrame but nothing is displayed. The text that I did append is not present. By the way, double clicking it...
HashTables
1

votes
0

answer
37

Views

Access frame attribute from component in multi frame environment

Problem I have a multi frame environment. Each JFrame has several JComponents, nested in each other. I need to access a global variable of the frame from within some of the embedded components. I can't use static because the static would of course apply to all frames. I can't hand over the frame or...
Roland
1

votes
0

answer
36

Views

Java GridLayout: new row

I have a JPane GridLayout filled with Buttons (about 30). I want to go to a new row at specific Points. How can I break to the next line? I tried to use the LayoutManager, but I didn't get it to work.
writzlpfrimpft
1

votes
1

answer
95

Views

Java setText not updating after button click

I am making a count up timer using buttons to start and stop. I need help solving this... when I press the 'Start' Button it works (tested using System.out.print) but the setText doesn't update for me. However If put the t.start(); after frame.setVisible(true); instead of after start = 1; the setTex...
Jelly
1

votes
0

answer
44

Views

Removing AbstractAction actionListener from JTextField from another class

I'm having an issue with a personal project I am working on in Java. I am creating a Console that accepts commands and does specific things as a result. In order to accept commands, I am using an AbstractAction Listener for a JTextField and JButton to detect when to move on. Here is that code: //Act...
Matthew W.
1

votes
0

answer
53

Views

Clickable Buttons on JTree panels?

I need to rewrite some legacy JTree code to make implementation of coming features easier. This code creates three icons for each node (see screenshot, in red boxes) which perform some action when clicked. Those icons are contained in a JPanel which is created by a custom TreeRenderer. Screenshot th...
rfuegen
1

votes
0

answer
280

Views

Use Javafx with lwjgl by swingNode and Canvas

For my project in lwjgl I need javafx component. For controller and I need to use lwjgl and javafx. I try to put lwjgl inside Pane javafx by SwingNode and (canvas in Java I swing). But I do not get the correct results. Can anyone help me? I tried to apply this after reading previous publications on...
CoderMohammad
1

votes
0

answer
213

Views

Java Modal dialog freezes whole application when using jdk 8

Very rarely, when showing a modal dialog in a Java Swing application using JDK1.8.0_144, the whole application gets frozen. I couldn't find a relevant bug in the JDK bug database. The only one that would seem remotely related is this one but our application was never minimized whenever it got froze...
Vlad Topala
1

votes
0

answer
87

Views

Loop becomes Infinite when System.out.println() is added

I am working on a Swing Ti-Tac-Toe variation game. In the AI class I have a function that takes the board and a piece morpionType. It loops through all the available spots intersections on the board and returns the number of intersections which yield game over. It was behaving oddly so I decided to...
Vladimir Louis
1

votes
0

answer
125

Views

How could I create a date picker in groovy?

I see this code for create input field in groovy. I'm trying to find a example for create a date picker in groovy, but I don't see anything. How could I create a date picker in groovy? import groovy.swing.SwingBuilder import groovy.beans.Bindable import static javax.swing.JFrame.EXIT_ON_CLOSE im...
mightguy
1

votes
0

answer
52

Views

Enter not selecting item from JComboBox in JTable

I have a table with one column of JComboBoxes used for selecting from 3000 IDs from a database. I have implemented an autocomplete function into the ComboBox. When I edit a value from the combobox, and select another value with the arrow keys and press the enter key, it does not set the selected ite...
Muzgar15
1

votes
0

answer
45

Views

JButton not changing color (Java) [duplicate]

This question already has an answer here: Changing the background of JButton 3 answers How to fill the surface of the JButton completely with an ImageIcon? 2 answers I am trying to make a button that is entirely black (with grey words). However, my button.setBackground(color.black) just gives the...
hnor4
1

votes
0

answer
47

Views

How to layer two JPanels and have them fill the entire JFrame in BorderLayout

I'm making a board game in Java, and I am trying to render the board itself in JPanel. The way I'm trying to do this is by inserting a image of the board (which is represented by a JLabel) and a grid (which is also represented by a JPanel). The idea is for each grid square to correspond to the squar...
JKing
1

votes
0

answer
262

Views

How to implement a Jtable in Intellij using UI Designer

So, I am using Intellij IDEA 2017 Community. I am working with java Swing components. I have been trying to get a simple JTable to show up on my GUI, but have had no success. The program starts fine, there are no errors, but the table does not get created correctly. I see tons of questions about JTa...
Cody Ferguson
1

votes
1

answer
276

Views

How to make a JFrame not movable?

The problem I would like to know whether it is possible to make a JFrame not movable/draggable - just out of curiosity and not for a real use case. The problem is that the window manager of the operating system is responsible for the appearance of the windows, but the program itself has only a few p...
Anonymous
1

votes
1

answer
99

Views

Java Swing setIconImage(new ImageIcon(byte[])) doesn't work

I have my Java Swing interface of my app and want to set my personal icon in left up corner. My code: File fimg = new File('D:\\logo.png'); BufferedImage img = ImageIO.read(fimg); WritableRaster raster = img.getRaster(); DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); ImageIcon icon...
KunLun
1

votes
2

answer
29

Views

Java Swing Dialog issue

When pressed the 'Inregistrare' button a dialog pops, requesting the user to enter a password (set to 'qwerty'). I want it keep displaying dialogs until the password is correct. The method is the following: private void ItemInregistrareActionPerformed(java.awt.event.ActionEvent evt) {...
Beach Williams
1

votes
1

answer
57

Views

problems in selecting the JComboBox items(in JMenu) Java Swing

Im having trouble in selecting the JCombox items here is a gif: Gif that shows exactly what is the problem here is code that you can test your own as asked by @UNKNOWN i delete everything that no needed so you can test , i have no error in console; the code works perfectly but the combo slection er...
Singh
1

votes
0

answer
41

Views

.setLocation in thread not calling repaint in seperate object (java)

--WORKING ON A SHORTER VERSION OF THE QUESTION-- So, this is someting I can't really find that much information on online. I am making a game together with my friend and we came accross a problem when we wanted to move some objects in a thread. We have one object, GroundBlocks, which is working fine...
Herman Eriksson
9

votes
7

answer
30.9k

Views

How to align JLabel-JTextField pairs vertically

What I mean by a JLabel-JTextField pair is a JLabel component followed by a JTextField one, for example, 'Parameter 1: -----' where '-----' denotes a blank JTextField. The problem is, the width of JLabels varies due to the varying lengths of parameter names, so that the starts of JTextFields are not...
skyork

View additional questions