Firstly, I’m reading the product name and number of products from user using jTextFields. For that product I read the product id and price from database using sql query. But in the below code I display the product price in a jtextField but while running tha file I get query executed successfully but I&#…
Tag: swing
Delete highlighting in JComboBox
When a JComboBox is just made and added and all the background of the selected item is just normal and white: (ignore the enormous spacing after the text) When I then open the list and hover my cursor over an item, that item get’s highlighted, all normal, nothing wrong with it. But the problem now is th…
How to add multiple JComponents to a JPanel?
I’m trying to add multiple components to a JPanel, but only the most recently added component is displaying. It seems like the problem is that the layout can only handle 1 component at a time, but I’m at a loss as to how to actually fix it. I’ve tried adding the components to a separate pane…
Java fade in and out of images
I am trying to learn how to fade in and out images into another image or from another image. So, if I have 2 images, and 1 is being displayed at the moment, I want to display another image in the background and fade the first image out into the 2nd image. OR, I want to set the focus on
Security Framework for Java Swing Applications
Is there a security Framework available for Java Desktop Applications? When I searched on google I saw persons talking about Spring Security, however it seems to be chiefly web-based. I have been using ordinary java code(Login forms, jdbc) to implement User Level security but I am not comfortable programming …
Alternating between even and odd elements in Array with GUI
I’m trying to work with more GUI stuff but I’m having problem with something. I have an array of JLabels. Each of them contain 1 number from 0 to 7. I’m making the numbers “light up” by changing …
How to initialize and draw a Rectangle variable in a paintComponent method? [closed]
I’ve been trying to add collision to my game, it seemed like a piece of cake, I already know how to draw a rectangle. But I need that rectangle to be represented by something, a variable. But it seems …
Set row height depend on JTextArea height
I have a problem and really don’t know how to solve it. I used some solutions from this forum but they don’t work. This is the piece of code: This is little bit long but rather simple: my table uses custom cell renderer which contains JTextArea. I use JTA because I need Strings wrapping. After put…
java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit
I’m working on XUbuntu 13.04 and developing swing applications. As I just wanted to try that application I ran into java.lang.NoClassDefFoundError: Could not initialize class java.awt.Toolkit on startup. I’ve found several questions about server/client vms and noticed that I have a server VM and t…
Java JEditorPane – Trying to edit an html tag value and getting Exception
I have a JEditorPane and I’m trying to edit one fo the html element attributes, basically changing the the src x value in to a custom value The code I have is: I get the following exception in the before last line when I try to remove the existing attribute (because you can’t replace): I read a fe…