I am trying to implement a GUI for a maze-based game I created that meets the following specific conditions: The GUI itself has a set size and is not resizable (line 41) . The master panel (line 57) that contains all the maze images is scrollable. All maze image components are flush with each other. If maze is small enough,
Tag: swing
How to open .txt using windows explorer context menu in java swing?
I am making a text editor for .html, .CSS, .js, .txt etc. First I made my software in java swing and then I changed it to jar file then I changed it to exe file using launch4j and then I made it setup using innosetup but if I install this software and I right click on a file in windows
How can I add a scroll bar to a text area?
Please, anyone, tell me how to add the scrollbar to a JTextArea. I tried out many things. but still not able to get it. I copied some codes related to the text area. Answer Oracle has a helpful tutorial, Creating a GUI With Swing. Skip the Netbeans section. As Andrew said, you have to place the JTextArea inside of a
Have keyevent listener method constantly checking input
I wrote this method: It is the method of a class extending JTextArea (yes, I know extending is suboptimal but I won’t need anything else for the intended application, at least not to my knowledge). It is supposed to check every character being entered into the JTextArea and send the message (the settext part) if the key being pressed is
Swing: can’t paint rectangle
I have this simple code: the JFrame adds custom Jpanel MyPanel which overrides paintComponent method to draw the rectangle. However nothing shows up on the window: Answer By default, an empty JPanel has a size of 0x0, so when you add it to your UI, the layout manager (in this case) honours it’s request and makes it 0x0 Start by
Is there a way to hide all elements in JFrame
I’m currently working on Java application and I’m using JFrame and inside of JFrame i have some buttons, labels and textfields. I’m in need of hiding all the elements that are in JFrame. I don’t need to hide JFrame itself, only the elements in it so I can display some others. Is there a way to hide them all without
How to display data to a JtextArea in java with exact text alignment same from the txt file
When I append the data to the JTextArea in Java it does not copy the alignment. Answer There could be 2 problems at hand. If your original textfile is using Tabs instead of spaces to align its columns the way it does, you need to set the same tab size on your JTextArea component. See JavaDoc for setTabSize(int) Secondly, alignment
Cant add to arraylist inside actionevent Buttonclicked
Im kind of new to programming in java but here im trying to figure out how to add the value of a button clicked in ActionEvent. I even changed the actionlistener to MouseListener etc but still not working. It only displays the current button clicked but i would like to add every button clicked into an arraylist. Problem: I cant
“Exception in thread “AWT-EventQueue-0″ java.lang.NullPointerException” occurs while adding images using ImageIcon
Firstly i applied panel on whole background & then created a label to set an image here. JFrame picture I saw that there’s so many questions & answers related to null pointer exception but no one worked for me. the ImageIcon is not being able to fetch the image. I even tried by creating a folder & gave the path
Java Swing – Show multiple panels
I’m using the Java Swing UI Designer in IntelliJ 🙁 I designed something in the designer using multiple panels and spacers with 1 parent panel. When I add the main panel, the first one inside it shows, but the others don’t. Frame structure: Panel1 GradientPanel Panel Spacers What I designed What I get Answer First you need to know that