Все вопросы: [swing]

1 174 вопросов

0
голосов
2ответов
200 просмотров

Winforms for a java swing guy [Applying MVC]

I am developing a GUI application in C# using the design mode in VS2008. Now that I am finished with the looks of the application I am ready to add some functionality to it. What really confuses me though, is that VS2008 designer only uses the empty constructor. When developing applications in J...

0
голосов
1ответов
660 просмотров

Java ComboBox What controls where list will display?

Possibly an odd question but how can I change how my Java Swing combo box displays its list of items? The default behavior is for the list to be displayed below the combo box. There are times, when the combo box is low on the screen, that the list is displayed above the combo box. Is there a w...

0
голосов
2ответов
3047 просмотров

Removing rows from a DefaultTableModel with a RowSorter attached doesn't remove last row

I'm somewhat new to Java, and especially new to tables, and I'm having a bit of trouble with one particular task. I have a JTable that uses a custom table model that extends DefaultTableModel, and I've attached a TableRowSorter to the table. The sample application below has two buttons--one wil...

0
голосов
2ответов
131 просмотров

Is this possible to do with images in java?

Is there any way I can print/show images on top of each other. The picture on top will always be positioned a little lower so that the one under will show partially. How can I decide which image is on top of what image? What layout lets me do this kind of positioning? Is there any way that I can...

9
голосов
3ответов
6227 просмотров

Is JOptionPane.showMessageDialog thread safe?

JOptionPane.showMessageDialog is supposed to be a useful utility for getting user feedback as it blocks your current thread while you wait. I would expect therefore that it would be thread-safe and that you wouldn't need to wrap the call in an invokeLater or an invokeAndWait. Is this the case?

0
голосов
3ответов
3374 просмотров

Waiting for mouse input in Java Swing

I'm working on a Java Swing application. I have a button whose action runs a query on a database and then plots the results. These commands are performed from the listener on the Run button. As I understand it, this means that the thread running at this point is from the EventQueue. Given c...

3
голосов
4ответов
11215 просмотров

Unwanted border around JPanel

I'm creating a form with a JPanel inside it for some graphics and some buttons for controlling the thing. For some reason I have to specify the JPanel to be 10 px less wide and 30 px less high than the actual graphics I want to put inside it. What causes this problem? This is the code: public c...

3
голосов
2ответов
5421 просмотров

How to expand JTree nodes (in advance), but keep them invisible

I seems to me that when i call JTree.expandPath( path ) That by default all its parents are expanded as well. But what i actually want to do is, set up specific invisible children to be expanded in advance. So that when a node is expanded that its complete sub-tree pops-out. I've found th...

5
голосов
4ответов
4720 просмотров

Java 6 and SwingUtilities2

There is component within the application that uses com.sun.java.swing.SwingUtilities2 Now I understand that this class shouldn't be used, but it's a component within the system that uses it. Therefore since it's no longer available in Java 6 I get a NoClassDefFoundError. How can I get around t...

2
голосов
1ответов
810 просмотров

In Groovy SwingBuilder, how do I attatch a closure to a JTable that fires when a cell is selected?

I have a JTable being constructed via Groovy's SwingBuilder. I'd like to attach a closure to the table that fires when a cell is selected, but I can't seem to find the right hook. How do I do that?

0
голосов
3ответов
1974 просмотров

Listening to all JInternalFrame events - Java

I'm trying to internationalise a Java applet and with that, support scripts which are written from right to left. I want to set up component orientations for all java components added to the view automatically. My solution so far has to listen to all AWTEvent's using the windows mask: c.getTool...

1
голосов
2ответов
625 просмотров

reassigning JList & JComboBox data

I've been looking through the Java API, but have had no luck in working this out. After you initiate a JList, is there any way to replace, or reload the 'data' string? I've also been looking to do the same thing with a JComboBox. String[] data = {"one", "two", "three", "four"}; JList dataList = ...

1
голосов
2ответов
2238 просмотров

Change button text without changing button size

I'm using a borderLayout to arrange my components in a JFrame and a Box(BoxLayout.X_AXIS) to put buttons next to each other. But it creates two problems: I want the buttons to have the same size, but it automatically resizes them to fit the text within them (especially annoying when I change th...

2
голосов
1ответов
3144 просмотров

Wrong packing of JFrame using JPanel in borderlayout

I am writing a simple application in Java that does some particle simulation on a bunch of sheep (don't ask). For this I want a window with a JPanel for graphics (which will be resizable with a simple combobox that contains some standard resolutions) and some other elements like buttons to start ...

4
голосов
3ответов
3163 просмотров

java swing app with a custom titlebar?

Is there a way to write a Java Swing application with a custom chrome? Please take a look* at the frame for Microsoft's Zune 4.0 software. I realize that colors, the shape of scroll bars, etc. are controlled by skins or looks and feels. Right now I'm trying to tackle the native window which ho...

0
голосов
2ответов
3168 просмотров

how to stop cell editing in JTextPane ,cell editor of JTable

I created JTable with JTextPane as cell editor.I want to stop cell editing and want to do some processing if I pressed enter key in JTextPane .And I also want to use single line in JTextPane. So, I add keylistener in JTextPane and call stopCellediting method. But it does not work, focus is in JTe...

0
голосов
4ответов
2383 просмотров

Can I set a window in Java so it has uniform resizing (ie. a square)?

I've seen several applications window's only allow the user to resize it in the diagonal direction, so it must maintain its square shape. Is it possible to specify this constrain using swing/java?

15
голосов
6ответов
8145 просмотров

Easiest way to unit test SWT and Swing apps in a headless environment?

I'm looking to unit test some SWT and Swing code for a project I'm working on and the tests run fine as long as I'm running them from eclipse. As soon as I run them in my hudson environment it fails since hudson runs the tests in headless mode. What's the best way of doing this? Open source so...

0
голосов
1ответов
750 просмотров

How to add scrollable JTextArea to jDesktopPane

I was try several opinion but neither of them it seams to work. This method returns JTextArea private static JTextArea getJArea() { if (jArea == null) { jArea = new JTextArea(); jArea.setBounds(new Rectangle(16, 153, 468, 139)); jArea.setVisible(true); jA...

5
голосов
1ответов
6458 просмотров

How to force a component to grow in MigLayout in Java

I have a component that is made up of various components such as a checkbox a slider and some buttons. i want to add this to a scrollpane and have the slider grow to fill all the remaining space. This is no problem as this code demonstrates : public static void main(String[] args) { JFrame ...

8
голосов
4ответов
15982 просмотров

How to change background color of the selected item in JList dynamically

How can I change the background color of the item which is selected in JList dynamically?

2
голосов
2ответов
374 просмотров

What is the difference between the ways a Swing window can be initialized?

I am curious as to the differences between the following approaches to creating a Swing window: Using java.awt.EventQueue.invokeLater() in main(); Using SwingUtilities.invokeLater() in main(); not bothering with threads at all, simply instantiating the JFrame subclass and calling setVisible(tru...

0
голосов
2ответов
388 просмотров

What is the correct way of manipulating Swing components at program startup?

I'm creating an application in Swing using NetBeans. I would like to be able to manipulate some components during its startup (just once), after the window's made visible, for example update a progress bar. To this end, I have the app's main class, called MainWindow: public class MainWindow exte...

2
голосов
2ответов
1218 просмотров

Java7 swing application framework support

The future of the Swing application framework on the Java 7 platform is undefined. http://weblogs.java.net/blog/archive/2009/08/19/saf-and-jdk7 Is it safely to use it now?

25
голосов
4ответов
16679 просмотров

Scala and Swing GUI applications

From reading parts of the Programming in Scala book, I realize that Scala can work with the Java Swing components to create GUI applications. My question is if there are any projects or released applications (that are more than just simple examples) that use Scala and Swing?

0
голосов
1ответов
994 просмотров

How to debug a swing UI in Eclipse?

I am trying to figure out where in some Swing code a UI window is created. It is ~1 million lines of code (no joke), and I have done a reasonable amount of searching and debugging. I am looking for a tool where I can click on a window in the UI and it will show me something about its Java code ...

4
голосов
2ответов
2460 просмотров

Finding the restore bounds of a JFrame when it is in a maximized state

When a JFrame is in a maximized state, the getBounds method returns bounds that match its current state. What I need is the "restore bounds" (that is, the size/location of what the window would be set to if a user clicked on "Restore Down" on a Windows platform) without actually setting it to a n...

12
голосов
3ответов
32966 просмотров

How to change icon of a JLabel?

I have a jlabel to show a generated image. But it only works the first time. After that, imageicon of the jlabel does not change. What could be the problem?

3
голосов
2ответов
7134 просмотров

Showing TIFF images in Java

Someone can tell me how to load a multipage TIFF image in Java and show it in a JScrollPane? Which class can I use?

2
голосов
5ответов
2054 просмотров

Server-client Java distributed application

I have to design a distributed application composed by one server (developed in Java) and one or more remote GUI clients (Swing application with windows). As stated before the clients are Swing GUI application that can connect to the server in order to receive and send data. The communication is...