swing

Auto adjust the height of rows in a JTable

In a JTable, how can I make some rows automatically increase height to show the complete multiline text inside? This is how it is displayed at the moment: I do not want to set the height for all rows, but only for the ones which have multiline text. ...

Java: Difference between the setPreferredSize() and setSize() methods in components

Ok, I read the Java Documentation and I just can't figure out what is the main difference between those two methods. Sometimes I used setSize(), sometimes setPreferredSize(), sometimes one does what I want, sometimes the other. So, what is the main difference between the two? Which one should I use for JFrames and JPanels? Thanks ...

How to show scrollbar in Swing's JOptionPane.showOptionDialog?

Hi, In our Swing application, we show error messages using JOptionPane.showOptionDialog. However, some of the messages are long and we would like to limit the height of the dialog and show a scrollbar. We thought of using HTML and CSS in the dialog text to limit the height and show scrollbar, but it seems Swing's HTML & CSS is quite limi...

address book next and previous buttons

I'm making an address book and I need to cycle through my contacts. The contacts are imported from file and are read into the JTextFields as so: name phone mobile address How do I go about doing this? I've tried, it runs but the buttons do nothing. edit: now using this: public void importContacts() { try ...

Drag&Drop with swing

I need some help. Is it possible to simulate a drag & drop without registering a component? E.g. I click the mousekey anywhere on the window and hold the mousekey down, at this moment, I want to create or simulate a DragSourceEvent programmatically with Java. Is this possible? ...

Remove Arrows from Swing Scrollbar in JScrollPane

I would like to remove the scrollbar arrow buttons from a scrollbar in a JScrollPane. How would I do this? ...

Java Music Player GUI

Hello. I am implementing a GUI using Swing for a Java Music Player. I'd like to know if it is possible to make a time bar like the bar in WinAmp for example that can be moved to jump to a certain position in a song and shows the current position. If possible, how would one go about this? Also, I'm using a JList to display Playlists and ...

How to remove the active title bar of a frame?

I have a JFrame which displays a title bar. Active title bar as it's called in Windows desktop properties. How to remove this bar? ...

rotating jlabel java swing

i'am using JTransformer class from swinghelper https://swinghelper.dev.java.net/ when i chose flowlayout there is no problem but if i use null layout i cant see my button on frame any help would be appreciated. import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.geom.AffineTransform; import java.util.ArrayList; imp...

why isn't my Jlabels or Jpanels showing??

i've added a title to my Jframe, and now its blocked everything else, what have I done?? public class addressbook { public JFrame frame; public JButton btnadd, btndelete, btnsave, btnprev, btnnext; public JPanel panel, pTitle; public JTextField txtname, txtaddress, txthomeno, txtmobno; public JLabel JlbName , JlbHtn, JlbMtn, JlbAddress,...

Render html in Swing application

I have a swing application that sends commands to server and receives result in XML format. I need to transform this into HTML via XSLT and then display result HTML on the panel. The problem is that the only Swing component which is able to display HTML - JEditorPane - takes either URL or javax.swing.text.StyledDocument as a source. Opt...

How do I customize a JComboBox so that the pop-up is a JTree (instead of a list)?

I am trying to create a combo box so that I can put whatever control I prefer within the pop-up, in my specific case a JTree. Having a look at how the JComboBox is implement, the pop-up is really created by the UI delegate. The problem in changing that is that it would need to be re-implemented for each look and feel, which is something ...

how to implement a search feature in java

I need to implement a search feature into my program. At present it reads from a file one line at a time, like so: public void importContacts() { try { BufferedReader infoReader = new BufferedReader(new FileReader("../files/Contacts.txt")); txtName.setText(readLine(infoReader)); txtPhone.set...

Java SwingWorker hanging

I'm debugging some code that was written using a SwingWorker to perform a mix of numerical calculation and GUI update. The SwingWorker hangs with the following stack trace : Full thread dump Java HotSpot(TM) Client VM (14.3-b01 mixed mode, sharing): "SwingWorker-pool-3-thread-4" prio=6 tid=0x07fd7c00 nid=0x143c waiting on condition [...

Which Swing component methods are thread safe?

According to Swing tutorial: Some Swing component methods are labelled "thread safe" in the API specification; these can be safely invoked from any thread. All other Swing component methods must be invoked from the event dispatch thread. Programs that ignore this rule may function correctly most of the time, but are subject to unpred...

Java Swing: How to bind a JLabel's text to a column in the selected row of a JTable?

I am using Netbeans and am trying to find a way for the IDE to auto-generate the code for me. I remember binding a JLabel's text to a column in the selected row of the JTable before, but in that case, the JTable's values were from an entity manager, and it was very easy. I was wondering if there is a way to do it even if the JTable is no...

Do any Java GUI builders exist that do not require external JAR's?

I am looking for a Java GUI building tool that generates the Java Swing code for me. I'm planning on using it to get all of the Frame/Panel code created quickly and then customize everything by hand after that. It would be nice to be able to choose between different layout managers, but it's not necessarily required. The most importan...

Mimicking Zoom bar from Office 2007 in Java (Modified JSlider)

Hi guys, I'm attempting to mimic (or find a preexisting component) that mimics the zoom slider from Word 2007: There are two main differences between this component and a standard Java JSlider: Does not snap to ticks except at 100%, and snaps while you're sliding the bar rather than when you release mouse Slider is not linear the ...

is there a way to embed flv files in java forms?

I want to play some flash videos in my desktop application are there any tools (library,jar file, class... etc) to embed flvs in any java forms? ...

rotate shape java2d without losing its origin

protected void paintComponent(Graphics g) { Graphics2D gr = (Graphics2D) g.create(); // draw Original image super.paintComponent(gr); // draw 45 degree rotated instance int aci=-45; gr.transform(AffineTransform.getRotateInstance(Math.toRadians(aci))); super.paintComponent(gr); //translate rotated instanc...