swing

Problem reading File using UTF-8 encoding in java

when i read the entire XML file in JEditorPane all works fine except the BOM charatcer. I get a BOM charatcer (a dot) at start of file. If i remove the dot and save file it is saved as ANSI.In notepad++ it shows (ANSI as UTF-8) encoding for the same file. If i dont remove the dot XML parser fails to parse the document. Can u help me with...

Send keystrokes to Java applicaiton in Windows

Hi, I'm running a java application from within a C# application. My goal is to fill a couple of input boxes inside the java app automatically using the C# code. I assume the java application uses Swing for its UI. I've tried using SendMessage and WM_KEYDOWN but nothing happens. Since it's a swing app, the input doesn't have a handle, s...

Should I implement File Dialog as Singleton ?

I'm developing a swing based application where I'm using many FileDialogs? So I say why not to make just one FileDialog object instead all of these instances and use it in the whole project? Is this a good assumption? does this have any performance improvement? Thanks ...

How to convert HTML of a website to an image?

Does anyone know how to do this? I've tried with JEditorPane but it does not work? Any other idea? Thanks in advance. This is the code I'm using: import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; import javax.swing.JEditorPane; import javax.s...

JList with custom cell renderer vs Jtable

My current application uses a JList and everything is well (the only customization I did was to set the italic font on some of the rows). Now I want to "upgrade" the user interface and instead of just labels in the List, I want a checkbox and a text field to be able to update the entry. I started changing the code and adding a custom c...

Java Swing JPanel Stay on top of JTable

I have a Jpanel that is used for displaying messages. When mouse enters a JLabel it expands to normal size and when mourse leaves it disappear. There are overlaps between JTable and JPanel when the JPanel expands to normal size. As JTable's height cannot be changed during runtime only way I can think of is let JPanel stay on top of JTab...

JPanel within JScrollPane within JPanel ignoring horizontal wrap

I have a JPanel that holds a JScrollPane that holds a JPanel as such: masterPanel.add(buttonPanel, BorderLayout.NORTH); inner.setLayout(new BorderLayout()); inner.add(infoPanel, BorderLayout.NORTH); inner.add(writingPanel, BorderLayout.CENTER); beholder = new JScrollPane(inner); masterPanel.add(beholder, BorderLayout.CENTER); I want ...

Why does a JTextField shrink in size to 0 when passed a large column's number?

Apparently if the columns size is more than 70 the field get's displayed with a size where you cannot even type a single character? I'm talking about: new JTextField(70); ...

How to figure out when I should make a function call within GUI thread

How can I know, whether I should make a function call within GUI thread. if (SwingUtilities.isEventDispatchThread()) { // ... } else { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { // ... } }); } For example // Should I call this within GUI thread? jTable.g...

How to display a JFreeChart in a NetBeans project

This is similar to a question I asked yesterday but more specific to the problem. What is the correct method to add a JFreeChart to a NetBeans project which already contains various widgets? My updateChart() hides the entire JFrame. I'd like to add the JFreeChart to the JFrame. public class MyClass extends javax.swing.JFrame implements ...

TimerTasks in Swing

Hi, I'm trying to write a message acknowledgement application where I need to: a) Add every new message on a message queue. Just using an Arraylist for creating a message queue. b) Notify a timertask to expect an acknowledge in 50 sec for the message so make it to either sleep for 50sec or wake up when an acknowledgement is received. W...

How to have JComboBox drop down list which is wider than the JComboBox itself

By referring to the answer at Multi Columns Combo Box for Swing, I manage to implement a 3 multi columns JComboBox as follow. However, this is not perfect. My intention is to have something without the horizontal scroll bar, as follow. My question is, how can I have a JComboBox drop down list, which is wider than the JComboBox itsel...

How is the clipping rectangle for a JComponent calculated?

I'm creating a slider bar, which will be a subclass of JSlider, as part of a logging gui. What I'd like to do is be able to draw some items above the slider bar (e.g. a "volume" display, indicating how much logging info will be spit out by a particular setting). I have overridden the paintComponent() method, but I'm getting a bit confu...

Java / Swing : JTextArea in a JScrollPane, how to prevent auto-scroll?

Hi all, here's a runnable piece of code that shows what my "problem" is. I've got a JTextArea wrapped in a JScrollPane. When I change the text of the JTextArea, the JScrollPane scrolls automatically to the end of the text and I don't want that. Here are my requirements: the application should not scroll vertically automatically but...

java launching multiple swingworkers from the same UI

Brief description of UI and setup 1)Plain vanilla frame, with button1 and button2 and textarea1 and textarea2 2)Button1 launches a continuous running task using a swingworker myswingworker1 and the swingworker's process method continually updates textarea1 3)Button2 launches a continuous running task using a swingworker myswingworker2...

Adding text to a JTextPane without having it editable by the user?

So I've created my own text pane class (extending JTextPane) and I'm using the method below to add text to it. However, the pane needs to be editable for it to add the text, but this allows a user to edit what is in the pane as well. Can anyone tell me how to add text to the pane without letting the user manipulate what is there? publi...

How do I display the contents of a String array in Java Swing

I am new to swing and am trying to write a simple program that displays the permutations of a user-defined string by having a jtextfield that the user enters the string into, then click the jbutton, then all permutations of the string are displayed in the panel as a list. I set it up and got it working with factorials by displaying the c...

JPanel: how to add buttons above table ?

JPanel panel = new JPanel(); bigbutton = new JButton("Big Button"); clearbutton = new JButton("Clear Page"); resetbutton = new JButton("Start Over"); finishbutton = new JButton("Finish"); panel.add(sometable); return panel; right now what happens is they sprawl horizontally. I want the four buttons horizo...

jComboBox set selected item not working properly

Hi Everyone, I'm trying to populate my jComboBox with the following items: public class DropDownItem { private String text; private int id; public void setText(String text) { this.text = text; } public void setId(int id) { this.id = id; } public String toString() { return text; } public int getId() { return id; } ...

What are the UIManager keys for JFileChooser and FileDialog?

I want to use the UIManager.get method in order to get and save the system look and feel for JFileChooser and FileDialog and then I want to change the look and feel. The problem is that I don't know what are the keys for Swing components that UIManager.get method uses. Is there any reference or any convention for that? Thanks ...