swing

Scala Popup Menu

How do I cause a popup to get shown in Scala? I have a "backdoor" but it seems pretty ugly to me: val item = new MenuIterm(new Action("Say Hello") { def apply = println("Hello World"); }) //SO FAR SO GOOD, NOW FOR THE UGLY BIT! val popup = new javax.swing.JPopupMenu popup.add(item.peer) popup.setVisible(true) ...

Increasing the font size of a JTextPane that displays HTML text

Lets say that I have a JTextPane that is showing a HTML document. I want that, on the press of a button, the font size of the document is increased. Unfortunately this is not as easy as it seems... I found a way to change the font size of the whole document, but that means that all the text is set to the font size that I specify. What...

What is the use of AccessibleContext in Java Swing?

Hello! I've seen a lot of examples which use getAccessibleContext().setAccessibleDescription(...) to set some "magic" description. What is the use of this description? Where can it be seen and how should it support accessibility? Why setDescription(...) is not used? Additionally, what is your opinion / experience with Java accessibil...

How to prevent swing GUI locking up during a background task

Hi, I have a swing application which stores a list of objects. When the users clicks a button, I want to perform two operations on each object in the list, and then once that is complete, graph the results in a JPanel. I've been trying SwingWorker, Callable & Runnable to do the processing, but no matter what I do, while processing the l...

Remove "X" button in Swing JDialog

Is there a way to remove the close button ("X") from the JDialog title bar? ...

Is there a way to hide the tab bar of JTabbedPane if only one tab exists?

I want a behavior similar to e.g. Firefox where the list of available tabs does only show up if at least two tabs exist. I wasn't able to find anything like that, yet. The best idea I had was changing the layout manually: in case of one component, just add that to the surrounding panel if a component is added, remove the component fr...

How can I customise the appearance of a JComboBox?

I'd like to make a drop-down list that looks like this: JComboBox provides the functionality I need, so I shouldn't need to write a custom component. But I can't find a way to customise the entire appearance of a JComboBox to achieve this. Any suggestions? Update: I don't want all JComboBoxes to look like this. I only want to create ...

Java: Altering UI fonts (Nimbus) doesn't work!

Hello! I'm referring to this Nimbus reference. I tried to set global Font to be slightly larger: UIManager.put("defaultFont", new Font(Font.SANS_SERIF, 0, 16)); ...works only for the menu but nothing else (buttons, labels). I tried to change labels and buttons fonts with UIManager.put("Button.font", new Font(Font.SANS_SERIF, 0, ...

Word-wrap radio button text in Java?

I have some radio buttons whose text may be very long. Is there an easy way to word-wrap them? Yes, wrapping them in <html> tags and inserting <br> tags would work, but is there a more automatic way to accomplish this? I don't really want to roll my own typesetter. ...

JTable selects wrong cell on click

I am working inside of a quite complex eclipse based application, and having a problem with a JTable based custom component inside of a JSplitPane. The part of the application that I actually have access to is a panel, within a tab, within a panel, within the actual application, so there are a lot of things that can go wrong. The speci...

Create a rounded JFrame / ContentPane

I'm creating a login window with rounded corners in java. Everything is OK, see pic, but i'm having challenges making the JFrame / ContentPane transparent. There are white areas at each corner (shown by the arrows) that i seem not to be able to remove since i can't set opague to false for the JFrame or ContentPane. Any ideas of how i ca...

How can I change the width of a JComboBox dropdown list?

I have an editable JComboBox which contains a list of single letter values. Because of that the combobox is very small. Every letter has a special meaning which sometimes isn't clear to the user in case of rarely used letters. Because of that I've created a custom ListCellRenderer which shows the meaning of each letter in the dropdown ...

Swing bind a dialog box to a Jbutton

i am trying to bind a new customer menu dialog box to a newCustomer button in my application , any ideas? thanks ...

Copying selected text to a Swing Java app?

My goal is assign a global hotkey (JIntellitype, JXGrabKey) that would pass an arbitrary selected text to a java app. The initial plan is to utilize the java.awt.Robot to emulate Ctrl-C keypress and then get the value from clipboard. Probably there's a more elegant solution? EXAMPLE: Open Notepad, type in some text, select that text. ...

Eclipse Java project error: cannot resolve declaration in swing

I get the following error in Eclipse: DISPOSE_ON_CLOSE cannot be resolved something.java javadir/src/ line xxxx Java Problem DISPOSE_ON_CLOSE is in javax.swing but even when I add import javax.swing.*; it doesn't work. ANy ideas? ...

Does anybody have any information on Nimbus Look and Feel customization?

Simply looking for some documentation. ...

How to wrap lines in a jtable cell?

Hello, I'm trying to implement a custom TableRenderer as described in this tutorial. I'd like to have the renderer line-wrap each text that is to long for the given cell. The idea is, to use a TextArea as renderer, as it supports line wrapping. However, the following code does not behave as expected: public class LineWrapCellRendere...

How can I get the text from a component in a JList?

I have a JList and I am wanting to get the text of an entry of that list at a specific index. Could someone inform me how to do this or should I restructure my code to getValues instead of getIndices? ...

Display Hibernate Query in JTable

I'm seeking an efficient way to display an SQL table queried via Hibernate in a JTable. Query q = em.createNamedQuery("Files.findAll"); List rl = q.getResultList(); It would probably be preferable to use the List returned by that (In this case, that would make a list of Files objects (where Files is an internal class, not java...

Java Swing design pattern for complex class interaction

I'm developing a java swing application that will have several subsystems. For all intents and purposes, let's assume that I am making an internet chat program with a random additional piece of functionality. That functionality will be... a scheduler where you can set a time and get a reminder at that time, as well as notify everyone on ...