swing

Insets for custom Synth look and feel

I'm implementing a custom Look & Feel using Synth for my application - basically providing custom versions of SynthStyle, SynthPainter and SynthStyleFactory. I am not using any XML, i.e. everything is done through the Java API. In general this is working just fine. The best way to set appropriate insets is however proving a little tric...

SWT or Swing for Plugin Project

I'm creating a plugin project that will have a menu and toolbar item, that when clicked, will open a dialog for user interaction (input, searching, etc.). Should I create the dialog using SWT or Swing? ...

Why is addSeparator() not working with my JToolBar?

Hey all, I am having trouble getting a JSeparator to show up inside of a JToolBar. My toolbar is created as follows : public class ToolBar extends JToolBar { super(); FlowLayout layout = new FlowLayout(FlowLayout.LEFT, 10, 5); setLayout(layout); add(new JButton("Button 1")); addSeparator(); add(new JButton("B...

Workaround for setToolTipText consuming mouse events?

This seems to be a verified problem with SWING http://forums.sun.com/thread.jspa?threadID=385730 I'm currently trying to set the tooltip text of a tab in a JTabbedPane but when I do I can't actually select the tab anymore because the tooltip added a mouse listener that is consuming the events. Does anyone know of a workaround that al...

Does Swing have a similar component like HTML <select> tag?

Hi everyone, I want to display some information in a JMenuItem. The data format is like this: 1-1|Menu Name1 1-2|Menu Name2 My problem is that when I create the JMenuItem it displays the whole key-value pair. I'm wondering if there is a similar behavior in Swing like the HTML's <SELECT> <OPTION value="1-1">Menu Name1</OPTION> ...

Java Swing: How to access variables in a 2nd frame from the first frame?

I'm programming a desktop application in JAVA usin NetBeans. My question is this: 1st: I have a Jframe that is the principal frame of the application. 2nd: In some moment I want to create a new object of some kind, so I press addButton y create a new JFrame (I create a new class window that extends Jframe) with some text fields in it...

java swing update problem

I have a Frame class (extends JInternalFrame). Inside the class I am instantiating a JPanel and initializing setVisisble(false). After the user clicks a buttom in the frame and does some processing, I call a method inside of the JPanel to update one of its labels. I then do setVisible(true) on the JPanel. However, the JPanel is not "r...

Design for TreeCellRenderer

I have been looking into JTree and TreeCellRenderer. It seems in general, the application (with one JTree) has only one instance of TreeCellRenderer. The application makes multiple calls to TreeCellRenderer's getTreeCellRendererComponent method to decide how each TreeCell is drawn, and such call are made in many occasions (when a cell ...

How to make a scrollable JList to add details got from a JOptionPane

Hi there, I want to repeatedly take input from the user(probably using a button) via a JOptionPane(already done) and store the details in something(how about a dynamic object array) and display this information as a list in a scrollable JList. MY CODE import java.awt.GridLayout; import javax.swing.*; class Flight { public stati...

Change the size of a scrollbar in JComboBox

Does anybody know how to change the scrollbar size in jComboBox manually? I've tried a whole bunch of stuff and nothing works. ...

Controlling layout of a checkbox in a custom Synth Look & Feel

I'm trying to implement a custom "Steampunk" themed look and feel using Synth - basically providing custom versions of SynthStyle, SynthPainter and SynthStyleFactory. I am not using any XML, i.e. everything is done through the Java API. In general this is working just fine and actually starting to look pretty decent. However I am havin...

Centering Text in a JTextArea or JTextPane - Horizontal Text Alignment

Is there a way to create horizontally centered text for a JTextArea like with a JTextField? setHorizontalAlignment(JTextField.CENTER); Is there a way I can accomplish the same thing with a multi-line text area? I can't find a method for it with JTextArea, so is there another option? JTextPane? If so, how? ...

Jpopup not working for the ESc key

in general the Esc key is used to hide the menu.. but in my case i have to show a menu on click of an Esc key. I have a combo I am doing the following public class MyFrame extends JFrame implements KeyListener{ JPopupMenu menu = new JPopupMenu(); JTextField txt = new JTextField("TestField1"); JTextField txt1 = new JTextField("TestFiel...

Swing's component events

How can I find what event a JComponent can send? From JDK documentation is not so clear to find all the event an object sands. For example a JButton send an ActionEvent but this is not listed into the API of the JButton ...

How to have multiple JTable headers synchronize their column widths, sorting, etc?

I have an interface that has multiple small JTables stacked on top of each other. I would like their column sizes, sorting, filtering, etc to stay in sync. Is there a straightforward way to do this? For the column widths, I tried having them share a common TableHeaderModel but this seemed to pose unexpected problems such as only bei...

java swing addTaskListener

I am new to java and have a swing task question. Can I add a listener to a currently running task? For instance if something happens in doInBackGround I want to add a listener for finished and display a dialog. I have tried but the compiler doesnt like me. :) Something like. private class MyTask extends Task<Void, Void>{ @Override...

How does Swing fit in with MVC?

There are many examples on the web when it comes to the MVC pattern with Swing. However, there doesn't seem to be a straightforward way of doing things. Here's some questions: Can the notion of View be directly associated with Swing components such as JFrames? Likewise, can the existing model classes that Swing uses be used as the Mod...

JTextPane how to show caret when extends jPanel ?

I want to show the caret on the jTextPane when i extends it to jPanel instead or JFrame. My problem now is when I extends my class to jPane the caret wont show on the jTextPane. ...

How to listen componentShown/componentHidden events better than ComponentListener?

I want to be informed if componentShown/componentHidden event occured. I use ComponentListener, but it doesn't work as good as I need. I have found this information in official Swing tutorial: The component-hidden and component-shown events occur only as the result of calls to a Component 's setVisible method. For example, a ...

Abstract table model

Hello everybody, I face a problem in using AbstractTableModel, i use linked list as a container for data , and i fetch records from table from db then i put it in linked list in table model then i male jable.setModel(model). THE PROBLEM i face that the last record i fetch from table from db is repeated n times since n is the number of re...