Java Tips Weblog

  • Blog Stats

    • 1,104,377 hits
  • Categories

  • Archives

Archive for the ‘Swing’ Category

Table Row Rendering

Posted by Rob Camick on January 24, 2010

There are times when you might want to do some custom rendering for an entire row of a table. Based on answers I see in the forums, for most people the first thought is to create a custom renderer. This can be a simple solution in some cases, but are there other alternatives to consider as well?
Read the rest of this entry »

Posted in Swing, Tips | 22 Comments »

Mouse Wheel Controller

Posted by Rob Camick on January 10, 2010

The mouse wheel can be used to scroll the viewport in a scroll pane. Have you ever wondered how the scroll amount is determined? Better yet, have you ever wanted to control the scroll amount?
Read the rest of this entry »

Posted in Classes, Swing | 4 Comments »

Scrollable Panel

Posted by Rob Camick on December 20, 2009

When using a JScrollPane the general rule is that the scrollbars will appear when the “preferred size” of the component added to the JViewport of the scroll pane is greater than the “size” of the viewport. There may be times when you wish to prevent a scrollbar from appearing even though the preferred size is greater than the size.
Read the rest of this entry »

Posted in Classes, Swing | 25 Comments »

Text Prompt

Posted by Rob Camick on November 29, 2009

Generally text fields are paired with a label when added to a GUI. The label describes the contents of the text field. In some applications you may have noticed that a text prompt appears inside an empty text field. This might be done when space is at a premium or you need to provide addition formatting information for the text.
Read the rest of this entry »

Posted in Classes, Swing | 13 Comments »

ToolTips and ScrollPanes

Posted by Rob Camick on November 8, 2009

Tooltips are generated by mouse movement over different Swing components. In a complex component, like a JTable, the tooltip is continually updated as the mouse moves from cell to cell. But what happens when the table is in a scrollpane and the viewport is moved? In this case the mouse may now be hovering over a different cell, but the tooltip is not updated. This may, or may not, be a problem depending on your requirements.
Read the rest of this entry »

Posted in Classes, Swing | Leave a Comment »

Text Field Auto Tab

Posted by Rob Camick on October 25, 2009

Anybody who has ever written a DocumentFilter has probably seen the DocumentSizeFilter example from the Swing tutorial on “Implementing a DocumentFilter”. It is simple, straight forward and works well. However, wouldn’t it be nice to have some additional functionality, namely the ability for auto tabbing when the Document is full?
Read the rest of this entry »

Posted in Classes, Swing | 5 Comments »

Chaining Document Filters

Posted by Rob Camick on October 18, 2009

A previous entry on Text Validation briefly mentions why you should consider using DocumentFilters. A limitation of a DocumentFilter is that you can only add a single filter to the Document. There may be times when you need to filter on multiple conditions. Of course you can always create a new filter and combine the code for multiple filter conditions. However, an easier approach would be to reuse existing filters. That is, it would be nice to be able to chain multiple filters together to act as a single filter.
Read the rest of this entry »

Posted in Classes, Swing | 4 Comments »

Component Border

Posted by Rob Camick on September 27, 2009

There are many times when you want a JTextField and a JButton to work together. That is you provide the user with a text field for entering data and you provide a button to display a popup component to make it easier to enter the data. An example might be a date field. Some users might choose to type the date directly into the text field, while others might choose the point and click approach. There are a couple of common appoaches for achieving this and one not so common approach that I will suggest.
Read the rest of this entry »

Posted in Classes, Swing | 12 Comments »

Resizing Components

Posted by Rob Camick on September 13, 2009

A recent entry on Moving Windows discussed how you might add functionality to move a component or a non decorated window. Today we will look at adding resizing functionality to these same components.
Read the rest of this entry »

Posted in Awt, Classes, Swing | 17 Comments »

Global Event Dispatching

Posted by Rob Camick on September 6, 2009

As a user interacts with a GUI, by using the mouse or keyboard, Swing handles the interaction by dispatching events to the appropriate component for processing. In turn the component will notify any listeners that the event has been received and processed. There may be times when you want to intercept or alter the event before it is dispatched to the component. Swing provides a few different approaches that will allow you to control the dispatching of events.
Read the rest of this entry »

Posted in Awt, Swing, Tips | 1 Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 88 other followers