I am currently making a program for my school project, it is a fast food order calculator, my problem is that I have to be able to display the table inside the JFrame in Main, if I add “frame.add(table);” inside Main, nothing happens. Any help would be appreciated, thank you! } Answer Add frame.add(JScrollPane(table)); Change frame.add(label); to frame.add(label, BorderLayout.NORTH); Move
Tag: swing
Cannot enable grayed-out (.setEnabled(false)) JtextField or JTextArea
Unfortunately, I cannot turn on .setEnable() for a JTextField, or a JTextField (tried both). It keeps remaining gray, so users cannot type. Please help me out. Details: taTwo can be either a JTextField or JTextArea but any I try cannot be enabled. It should be disabled for A but should be enabled for B, so if user choose A he/she
JFrame ending in some time
Whenever I run my code it ends in a few seconds. Why? This is the Main file: This is the GameWin file: When I try to run this code it shows running and then the code ends with exit code 1 which is good, but it just ends without showing the window. Is there something wrong with my JRE or
How to update values of a JFrame main after using a JDialog of Java Swing?
I have a main window called MainFrame which is a jForm to which I update the data depending on a timer, but the problem is that I cannot update the data in the same MainFrame after using the jdialog, since I end up creating another duplicate window, but with the data changed, one with the original timer and the other
2D grid is not fitting in JFrame for pathing visualizer
I am trying to create a 2D grid with node sizes depending on the size of the height/width of the frame but whenever I run the program, the bottom row and right columns are somewhat cut off. Here is my execution code: Here is the Grid class: And here is the GridFrame class: I have also been messing around with
Buttons not visible until mouseover
I created a frame and panel (for Graphics) and add buttons to the panel. However, when I run my program buttons are not visible until I hover over them. Maybe it is something wrong with graphics methods. How the problem can be solved? Answer Your painting code is mostly wrong. For example: If you need to override paint() then the
How can I rotate multiple graphics shapes together in java without changing their position on the frame or their position relative to eachother?
I have used several java.awt.Rectangle, java.awt.Polygon, and java.awt.geom.Ellipse2D shapes together and I want to rotate them with eachother and I also want to have them keep their location on the JFrame. When I use g2D.rotate(Math.toRadians(rotation)), the shapes move on the JFrame and they are no longer close together. How can I make it so that all of the shapes keep
Is it possible to add the same ActionListener for 100 buttons?
I have created an array of buttons (JButton[] jb = new JButton[100]) and I want to add the same action listener for all the buttons in the jb array instead of adding them one by one. Just imagine every time I click one of the buttons displayed on the screen and it will print out the index of that button
JFrame.addMouseListener doesn’t register clicks
I am currently writing an application in java that needs to take in input from the user. I have tried many ways to implement the input but none of them work. I am rendering objects with the graphics interface if that helps. I have tried a couple of methods to implement mouse interaction: And However when I run the application
GridBagLayout Adding Space between buttons/stagger/varied columns?
I am trying to create a layout with GridBagLayout but am having trouble getting the spaces in between the JButton controls to be equal. In the first row, there are 5 buttons that have no space in between. The second and third row should have 4 buttons which are smaller which spaces in between. The workaround I tried was to