swing

Write gui programatically, or using an advanced gui editor (Java Swing) ?

I am planning to write a Swing-based application (using Netbeans 6.8). It seems that Netbeans has a very advanced GUI Editor... Still I have my doubts regarding the code generated by it. Additionally I don't like the fact the part of the code is locked (still I understand the need). Has anybody used Netbeans GUI Editor with success ? ...

Swing: set JFrame content area size

I'm trying to make a JFrame with a usable content area of exactly 500x500. If I do this... public MyFrame() { super("Hello, world!"); setSize(500,500); } ... I get a window whose full size is 500x500, including the title bar, etc., where I really need a window whose size is something like 504x520 to account for the window bord...

Evaluating creation of GUI via file vs coding

I'm working on a utility that will be used to test the project I'm currently working on. What the utility will do is allow user to provide various inputs and it will sends out requests and provide the response as output. However, at this point the exact format (which input is required and what is optional) has yet to be fleshed out. In ...

setOpaque(true/false); Java

In Java2D when you use setOpaque I am a little confused on what the true and false does. For example I know that in Swing Opaque means that when painting Swing wont paint what is behind the component. Or is this backwards? Which one is it? Thanks ...

JAVA Reporting Tool iReport

Can we get a reporting page which is like .Net's Crystal report using iReport? That is i need to get report inside the frame. Please help me. ...

Crosshairs in Java

I am making a game that needs a crosshair. I have been playing with the java.awt.cursor class and that is easy enough, but the problem is that I do not want the crosshairs to be able to leave the window I create for my game, so I tried this instead: private void drawCrossHair(Graphics g){ Ellipse2D ellipse = new Ellipse2D.Float()...

is it possible to add background image to jdesktop pane

I am trying to create virtual desktop. I complete successfully.But i am not able to set background image for jdesktoppane. I want to set background image and After adding image also the desktop pane work normally.Is anyone know means just tell me Thanks ...

How To Keep Size Of JTextArea constant?

Hi! I'm using an object of JTextArea in my application which deals with sending sms. I've used a DocumentFilter so as to allow only 160 characters to be typed in the textarea but now, I want the size of the textarea to be constant. it goes on increasing if I keep writing on the same line without pressing 'enter' key or even when I keep...

What is the best way, if possible, to send information from a Java PrintStream to a JTextPane?

In Java, I have a package that translates XML metadata from one standard to another. This package is ultimately accessed through a single function and sends all of its output through a PrintStream object. The output sent is just a status of each file and whether or not it was translated. This is pretty fine and dandy if I'm just print...

Really slow obtaining font metrics.

So the problem I have is that I start my application by displaying a simple menu. To size and align the text correctly I need to obtain font metrics and I cannot find a way to do it quickly. I tested my program and it looks like whatever method I use to obtain font metrics the first call takes over 500 milliseconds!? Because of it the ti...

Partial match in MaskFormatter for jFormattedTextField

How do I set up the MaskFormatter and the JFormattedTextField in order to allow partial matches? For example: I want the user to be able to enter numbers with this mask "## ###### ####", so if the user enters '123456789123' the formatter changes it to '12 345678 9123' (it adds spaces after the 2nd and 8th characters). However, I also ...

How to make a JMenu have Button behaviour in a JMenuBar

Hi I was trying to make a JMenu behave like a JButton but I'm having some problems and hopefully someone here can help! I've added a MenuListener to the JMenu item with this but I cant get the popup menu/focus to leave to enable me to properly click the JMenu repeated times to trigger this function and i was hoping someone could tell m...

Internet audio player from java swing client ?

Im trying to implement and realtime audio streaming swing desktop app . trying to get bytes of audio using java.net classes and then feeding it to play . Just trying blind punches undersea water thinking the water tank will crack :(( help or any suggestion ? ...

Playing a .wav sound file in JPanel/JFrame using Java (Swing)

I need some code example on how I would use a filepath from a harddrive location to then play a .wav sound file when opened in swing GUI. I don't need it to show a play button, or pause or stop. I just want it to play when I select the 'Sound' option from my 'Files' in my window (I know how to do that already, no need to explain that). ...

Mouse wheel not scrolling in JDialog but working in JFrame

Hello, I'm facing a frustrating issue. I have an application where the scroll wheel doesn't work in a JDialog window (but works in a JFrame). Here's the code: import javax.swing.*; import java.awt.event.*; public class Failtest extends JFrame { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() {...

JPanel Layout Image Cutoff

I am adding images to a JPanel but the images are getting cut off. I was originally trying BorderLayout but that only worked for one image and adding others added image cut-off. So I switched to other layouts and the best and closest I could get was BoxLayout however that adds a very large cut-off which is not acceptable either. So basi...

Weird swing heavyweight & lightweight mixing problem

Hello, We have a problem in our swing based application since we've upgraded our java version from 6u5 to 6u18 (The application runs over WinXP). Our application contains a Canvas object which resides in a JFrame. The application draws things on the canvas. Every time we drag a lightweight swing object (popup or another frame) over the...

How to retrieve data from textarea or text field and store in a text file with the same data format, java

Hi I have created a text field in java and i am able to get the data from text field and store in a .txt file. But My problem is that let the my data in textfield is in bold and italic format and the font colour is red. Now I want to store the data exactly in the same format in .txt file. I donot know how to write code for that. Anyone ...

Changing JButton background colour temporarily?

Hi, I'm super new to Java, and in need of some help. I'm making a little java desktop application where I basically have a grid of 4 JButtons ( 2 x 2 grid), and I need the background colour of individual JButtons to change, and after one second, change back to the original colour (the game I'm trying to make is like Simon, where you hav...

java/swing: converting a text string to a Shape

I want to convert some arbitrary text to a Shape (java.awt.Shape) and then stroke/fill the Shape to draw it. How can I do this? ...