swing

get input Text from JTextField (string to char) to show up in JButton

(new rewritten code).. I just know that "b" will always the last box that i created.So i can't use b as the equals in actionPerformed. How to include all the buttons? Anyone can help me with this? import java.awt.; import javax.swing.; import java.awt.event.*; public class Lat1 extends JFrame implements ActionListener { ...

Cannot move JMenu to JMenuBar

I'm trying to move the menu structure from a JMenu into a JMenuBar. The above code shows different menus depending on TEST. For TEST==1 i expect aa bb in the menu bar, but only aa is shown ? The code shows the problem, it is not my real code .... public class Test { public static void main(String[] args) { int TEST = 1; /...

Setting font color on DefaultStyledDocument

I know that I can set the font size on a javax.swing.text.DefaultStyledDocument like this: public void apply(DefaultStyledDocument document) { final MutableAttributeSet attributeSet = new SimpleAttributeSet(); StyleConstants.setFontSize(attributeSet, 12); document.setCharacterAttributes(0, 80, attributeSet, false); } How d...

Running a Jar file alone

Hai I have an application which is designed in netbeans6.0.1 where i need to display an image as an logo.My coding is as below mLogo = new JLabel(); URL lUrlLogo = getclass().getResource("/com/images/image.gif"); Image lLogoimage = Toolkit.getDefaultToolkit().getImage(lUrlLogo); ImageIcon licon = new ImageIcon(lLogoimage); mLogo.setIco...

Java gridlayout with empty cells

I want to show the status of some files in a Java GUI. Each file has a label and a button, the colour of the button represents the status of the file and clicking performs various operations. All this is working, the problem is that they are not showing correctly. I want it to appear as [Label 1] [File 1] [File 2] [Label 2] [Label 3] [F...

java - adjusting jslider looks on windows laf

Hi all, been trying this for a while now and can't seem to get it to work. I wrote a little GUI app that uses the OS's default Look And Feel. While I wrote it on linux, it is mainly intended to be used on Windows. The JSliders under linux are fine by me, but on windows the thumbs(sliders? I don't know the right word) become very narrow,...

Swing: Floating panel next to the selected item in a JComboBox

I've created an app with a small window (the size of a combo box). I need to create a floating panel that sits outside the window, next to the selected item in a JComboBox. (See attached image). I've been reading about the JComboBox.setRenderer(customRenderer) etc. But was just wondering before I go down this path, whether it is at...

java - why does graphics.drawString() not redraw?

Hi all, this is beyond me (be forgiving, it's late). I'm subclassing a WindowsSliderUI, because I want it to draw a bigger thumb (is that the right word?)(that's working) and also display the value of the slider just above it (like, for example, gtk look and feel does)(that's broken). I'm overriding the paint() method, and at the moment...

database in desktop application using swing

I am making a desktop application in java and using MSAccess in data base. I want that if i run the setup of the application the database should be created on client machine because there can be different client using the application and how can i create the setup? is there any tools available for this free of cost? please explain me in ...

JTextPane prevents scrolling in the parent JScrollPane

I have the following "tree" of objects: JPanel JScrollPane JPanel JPanel JScrollPane JTextPane When using the mouse wheel to scroll over the outer JScrollPane I encounter one annoying problem. As soon as the mouse cursor touches the inner JScrollPane, it seems that the scroll...

ActionListener on JLabel or JTable cell

I have a JTable with JLabel[][] as data. Now I want to detect a double click on either the JLabel or a table cell (but only in one of the columns). How can I add an Action/MouseListener on JLabel respectively table cell? ...

Using the NetBeans GUI editor, how can I create a JTextField or JFormattedText field that must be validated against a regular expression?

I have a regular expression (\d{4}\w{3}(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]){2}) that I need to validate the input of a text field against when the user clicks the OK button or moves the cursor to another field. That I know how to do, writing the code. However, I'm interested in if it's possible to have the NetBeans GUI ...

Android convertPointFromScreen

Is there an equivalent of the convertPointFromScreen method from the SwingUtilities class in the Anrdoid SDK ? ...

JTable + TableModel cache fetch event for lazy instantiation?

Scenario: you are using a JTable with a custom TableModel to view the contents of some collection located in a database or on the network or whatever. The brute force way to make this work is to load the whole collection at once. Let's say that isn't practical because of the resources needed. The simple way around that problem is to ...

Wizard creation and Launching

Hi everyone, How can I launch a wizard on a textPane that serves as my composition panel, whenever I drag and drop a component(file) into the contentPane? I have tried to develop a component whose properties will be diplayed on the composition panel(represented by a JTextPane), in any wizard of my choice. Thanks ...

action listening for a JFrame

I am trying to listen tab-in tab-out action for my swing gui that is made by JFrame. I have a JTextField added to the JFrame that will be getting the user clipboard whenever the window is selected so the user may tab between programs, copy some url so when back to my program, this JTextField will be populated by the copied url string. E...

Scrollable JPanel

How to make a JPanel scrollable? I implemented the scrollable interface yet when adding it to the containing panel with tabbedPane.add("Editor", new JScrollPane(storeyEditor = new MNScrollablePanel())); nothing works Code: public class MNScrollablePanel extends JPanel implements Scrollable { public Dimension getPreferredScroll...

Displaying XHTML in Swing (JEditorPane)

I'm writing a Java application with GUI using Swing. One of the GUI components is a JEditorPane that renders HTML. All the rendering is fine except that it shows in the first line the XML header: ?xml version="1.0" encoding="UTF-8" standalone="no"?> I've googled a little bit and I've found the same question here and there, but never any ...

Autoupdate feature in a Java Swing desktop App

I've developed a desktop Swing app and I'm thinking about the best way to provide the autoupdate feature. I know that JavaWebStart provides this but I think that It doesn't suit my needs because I need to read local files so I would need to sign the jar. Besides, JWS requires extra work to deploy in the server while now I only need to u...

Java GUI alternatives

I write applications in Java, and I'm looking for ways to speedup GUI programming. Binding frameworks help, but the particular application I'm working on now wouldn't benefit too much from that (it doesn't display a lot of data, just a lot of ways to manipulate the data). I feel like I spend way too much time writing boiler-plate GUI cod...