<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>Java Programming Forum - Learn Java Programming - Blogs - Java Swing</title>
		<link>http://www.java-forums.org/blogs/java-swing/</link>
		<description>Java Programming Forum - Learning Java easily</description>
		<language>en</language>
		<lastBuildDate>Wed, 22 May 2013 03:48:14 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.java-forums.org/images/misc/rss.jpg</url>
			<title>Java Programming Forum - Learn Java Programming - Blogs - Java Swing</title>
			<link>http://www.java-forums.org/blogs/java-swing/</link>
		</image>
		<item>
			<title>Internal Frames Performance tip</title>
			<link>http://www.java-forums.org/blogs/java-swing/1350-internal-frames-performance-tip.html</link>
			<pubDate>Thu, 26 Apr 2012 18:55:28 GMT</pubDate>
			<description>When various internal frames are present in a desktop, it might be noticed by the user that they move slowly. This problem could be avoided by using...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">When various internal frames are present in a desktop, it might be noticed by the user that they move slowly. This problem could be avoided by using outline dragging. With help of outline dragging, just internal frame’s outline is painted at the current position of mouse while internal frame dragging. Innards of internal frames couldn’t be repainted, at new positions, unless dragging is stopped. Default behavior known as live dragging is to repaint or reposition few or all internal frames in a continuous manner while moving; this could be a real slow thing if various internal frames are present in a desktop.<br />
JDesktopPane method setDragMode* can be used for outline dragging. E.g:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">desktop.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1350-internal-frames-performance-tip.html</guid>
		</item>
		<item>
			<title>Rules of Using Internal Frames</title>
			<link>http://www.java-forums.org/blogs/java-swing/1349-rules-using-internal-frames.html</link>
			<pubDate>Thu, 26 Apr 2012 18:54:35 GMT</pubDate>
			<description>If any programs have been built by the help of JFrame or other components of the Swing, then already you are having enough knowledge that how...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">If any programs have been built by the help of JFrame or other components of the Swing, then already you are having enough knowledge that how internal frames could be used. Rules to use the internal frames have been summarized in the given list:<br />
<br />
<b>Internal frame’s size shall be set:</b><br />
If internal frame’s size is not set, then it will never become visible due to its zero size. Size can be obtained by one of the given methods: setBounds, pack or setSize.<br />
<br />
<b>Internal frame’s location shall be set, as per rule:</b><br />
If location of the internal frame is not set, it will be 0, 0. SetBounds or setLocation methods could be used for specification of the internal frame’s upper left point relative to the container.<br />
To internal frame components can be added by adding them to content pane of the internal frame.<br />
<br />
This situation and JFrame situation are similar.<br />
<br />
Use JInternalFrame or JOptionPane to implement the internal frames (Dialogs)<br />
<br />
Simple dialog can be created by using JOptionPane showInternalXxxDialog methods.<br />
<br />
An internal frame shall be added to a container.<br />
<br />
If an internal frame is not added to a container then internal frame wouldn’t be visible.<br />
<br />
You need to call show or setVisible on internal frames.<br />
<br />
By default, internal frames could be seen. Show () or SetVisible (true) shall be invoked to make internal framesvisible. <br />
<br />
Internal frame events are fired by the internal frames, not window events.<br />
<br />
Internal frame events handling is considered very identical to window events handling.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1349-rules-using-internal-frames.html</guid>
		</item>
		<item>
			<title>Internal Frames vs. Regular Frames</title>
			<link>http://www.java-forums.org/blogs/java-swing/1348-internal-frames-vs-regular-frames.html</link>
			<pubDate>Thu, 26 Apr 2012 18:53:25 GMT</pubDate>
			<description>Code that is used for internal frames and regular swing frames is very similar, in variety of ways. Root panes are present in internal frames which...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Code that is used for internal frames and regular swing frames is very similar, in variety of ways. Root panes are present in internal frames which are used to setup GUIs, for JInternalFrame that is quite same as the GUI setup, for JFrame. Other APIs are also provided by the JInternalFrames which makes it just like JFrame.<br />
<br />
Internal frames are not top level or windows container, but this makes them to differ from frames. Let us say for example, an internal frame shall be added to a container; an internal frame is not considered as containment hierarchy’s root. Also, window events are not generated by the internal frames. Instead of this, user actions which make window events to be fired by a frame cause the internal frame event firing by the internal frame.<br />
<br />
Platform independent code is being used for implementation of the internal frames; therefore certain features are added by them which couldn’t be obtained by frames. One feature is that more control is provided by the internal frame at the capabilities and state as compared to that provided by the frames. Internal frames could be iconified or maximized programmatically. Also, which icon shall be in the title bar of internal frame shall also be specified. It could also be specified that internal frames either have window decorations or not, which support maximizing, closing, iconifying or resizing.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1348-internal-frames-vs-regular-frames.html</guid>
		</item>
		<item>
			<title>How to Use Internal Frames</title>
			<link>http://www.java-forums.org/blogs/java-swing/1347-how-use-internal-frames.html</link>
			<pubDate>Thu, 26 Apr 2012 18:52:36 GMT</pubDate>
			<description>A JFrame could be displayed by the JInternalFrame. Usually internal frames are added to the the desktop. Desktop pan might be used for the JFrame’s...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">A JFrame could be displayed by the JInternalFrame. Usually internal frames are added to the the desktop. Desktop pan might be used for the JFrame’s content pane. Desktop is JDesktopPane’s instance that is basically the JLayeredPane subclass which made API addition for management of various overlapped internal frames.<br />
<br />
Carefully it shall be considered that either GUI of your program could be based around internal frames or frames. To make a switch from internal frames towards frames, or reverse of this is not at all a simpler thing. By experimenting internal frames and frames, one might have a clear idea regarding the involved tradeoffs to choose one or the other.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1347-how-use-internal-frames.html</guid>
		</item>
		<item>
			<title>Responding to Window-Closing Events</title>
			<link>http://www.java-forums.org/blogs/java-swing/1346-responding-window-closing-events.html</link>
			<pubDate>Thu, 26 Apr 2012 18:51:55 GMT</pubDate>
			<description>When a frame onscreen is closed by a user, frame gets hidden by defauly. Though it is visible, still the frame is present and it might be made...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">When a frame onscreen is closed by a user, frame gets hidden by defauly. Though it is visible, still the frame is present and it might be made visible by the program once again. If different behavior is needed on your partm then either get registered the window listener which controls the window closings or default close behavior could be specified by the help of method setDefaultCloseOperation. Both of them could also be done. <br />
<br />
Given values shall be there for setDefaultCloseOperation argument. Among them, first three have been defined and detailed in WindowConstants interface (which is implemented by the help of JDialog, JInternalPane and JFrame.)<br />
<br />
<b>DO_NOTHING_ON_CLOSE</b><br />
When a request is made by the user to close the windoe, nothing needs to be done. Instead a window listener shall be used by the program which performs various actions in its method windowClosing.<br />
<br />
<b>HIDE_ON_CLOSE (the default for JDialog and JFrame)</b><br />
Window shall be made hidden when it is closed by user. Window will be erased from the screen but would be left displayable.<br />
<br />
<b>DISPOSE_ON_CLOSE (the default for JInternalFrame)</b><br />
When user close window, hide or dispose off it. It will remove out the window and also would free any used resource.<br />
<br />
<b>EXIT_ON_CLOSE (defined in the JFrame class)</b><br />
Use System.exit(0) to close the application. This has been just recommended for applications. If it is used within applet, throw a SecurityException.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1346-responding-window-closing-events.html</guid>
		</item>
		<item>
			<title>Creating and Showing Frames</title>
			<link>http://www.java-forums.org/blogs/java-swing/1345-creating-showing-frames.html</link>
			<pubDate>Thu, 26 Apr 2012 18:50:56 GMT</pubDate>
			<description>Extremely plain window’s picture is given below that is made by the demonstration application FrameDemo. Source code could be found in...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Extremely plain window’s picture is given below that is made by the demonstration application FrameDemo. Source code could be found in FrameDemo.java. FrameDemo could be run (downloading JDK6, or later.)<br />
<br />
How to setup a frame has been shown in the given code of FrameDemo.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">//1. Create the frame.
JFrame frame = new JFrame(&quot;FrameDemo&quot;);

//2. Optional: What happens when the frame closes?
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

//3. Create components and put them in the frame.
//...create emptyLabel...
frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);

//4. Size the frame.
frame.pack();

//5. Show it.
frame.setVisible(true);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1345-creating-showing-frames.html</guid>
		</item>
		<item>
			<title>How to Make Frames (Main Windows)</title>
			<link>http://www.java-forums.org/blogs/java-swing/1344-how-make-frames-main-windows.html</link>
			<pubDate>Thu, 26 Apr 2012 18:50:12 GMT</pubDate>
			<description>Frame is considered to be a top leveled window that has a border and a title. Frame size consist of any area which has been designated for sake of...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Frame is considered to be a top leveled window that has a border and a title. Frame size consist of any area which has been designated for sake of border. Border area dimensions might be obtained by method getInsets. Border area is also present in frame’s overall size so frame’s portion is obscured effectively, which constraint the area present to render or display the subcomponents, to that rectangle which consists of  location of upper left corner (insets.left, insets.top), and width size (insets.left + insets.right and height (insets.top + insets.bottom).<br />
<br />
Frame which has been implemented as the JFrame class’s instance, is basically window which consists of decorations like title, border. Support is provided to the button components which iconify or close the window. Appilcations along with GUI consist of 1 frame at least. Frames are also used by applets, sometimes.<br />
<br />
For making a wondow which is another window dependent- disappearing in case when some other window gets iconified. For example, dialog usage rather than frame. For making window that is visible in another window, an internal frame shall be used.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1344-how-make-frames-main-windows.html</guid>
		</item>
		<item>
			<title>Wide JTables</title>
			<link>http://www.java-forums.org/blogs/java-swing/1343-wide-jtables.html</link>
			<pubDate>Thu, 26 Apr 2012 18:49:19 GMT</pubDate>
			<description>What could be done in case there are too wider JTables present? 
 
 
* They could be placed in JScrollPane so complete table gets scrolled. 
*...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">What could be done in case there are too wider JTables present?<br />
<br />
<ul><li style="">They could be placed in JScrollPane so complete table gets scrolled.</li><li style="">Column’s width could be changed by the user so that the date could be squeezed into the space present, which would widen column, as per requirements.</li><li style="">Shortcuts could be given to the users for configuration of width constellations of the multiple columns.</li><li style="">If 2 or 3 rows are attempted to be used per data item, it gets awkward. A perfect grid would be needed. Cells that occupy space more than 1 column could not be used as it could be done in a spreadsheet or html table. Identical data type or formats are the base for rendering, in every column’s cell.</li><li style="">A row can be deleted by having an icon at every row for clicking, or a row can be selected to right click the delete, off a menu. If immutable contents of cell is present, then delete keys may be allowed on any cell.</li></ul></blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1343-wide-jtables.html</guid>
		</item>
		<item>
			<title>How JTables Work</title>
			<link>http://www.java-forums.org/blogs/java-swing/1342-how-jtables-work.html</link>
			<pubDate>Thu, 26 Apr 2012 18:48:25 GMT</pubDate>
			<description>One of the most important things that shall be made understood is that data gets live just in DataModel. Rendered data is that one which is visible...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">One of the most important things that shall be made understood is that data gets live just in DataModel. Rendered data is that one which is visible currently. No giant sort of bit map scrolling of the screen is present. Correspondent grid of the JComponents is also not present. Not a single JComponent’s row is even present. All of the cells are rendered by the TableCellRenderer which recycles the similar JComponent. New rows are brought forward from the DataModel when it is scrolled by the user. Rendered row’s bit map which is yet visible may totally not be RAM resident.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1342-how-jtables-work.html</guid>
		</item>
		<item>
			<title>JTable Classes and Interfaces</title>
			<link>http://www.java-forums.org/blogs/java-swing/1341-jtable-classes-interfaces.html</link>
			<pubDate>Thu, 26 Apr 2012 18:47:53 GMT</pubDate>
			<description>JTable specified functions could be present in JTable class or other classes which are present in package javax.swing.table. Majority of the programs...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">JTable specified functions could be present in JTable class or other classes which are present in package javax.swing.table. Majority of the programs present shall be importing both classes present, as following:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">import javax.swing.*;
 import javax.swing.table.*;</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 It shall be noted that scheme of package naming that is present in Swing change when JFC version1.1 came. Before this, com.sun.java.swing was used to start the swing packages. For this JFC VERSION1.1, javax.swing is used to start the package’s name.<br />
<br />
When a JTable is implemented in Swing, TableColumnModel, TableCellRenderer, the TableModel, &amp; TableCellEditor are considered to be the most important. Few default classes are also provided by the swing- AbstractTableModel, DefaultColumnModel &amp; DefaultTableModel- which are already involved in implementation of such interfaces.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1341-jtable-classes-interfaces.html</guid>
		</item>
		<item>
			<title>JTable Printing</title>
			<link>http://www.java-forums.org/blogs/java-swing/1340-jtable-printing.html</link>
			<pubDate>Thu, 26 Apr 2012 18:47:09 GMT</pubDate>
			<description>Simple API is provided by the JTable to print the tables. Priting of the table could easily be done by invoking JTable.print, with no arguments: 
...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Simple API is provided by the JTable to print the tables. Priting of the table could easily be done by invoking JTable.print, with no arguments:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">try {
    if (! table.print()) {
        System.err.println(&quot;User cancelled printing&quot;);
    }
} catch (java.awt.print.PrinterException e) {
    System.err.format(&quot;Cannot print %s%n&quot;, e.getMessage());
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 At normal swing, print is invoked that will bring the printing dialog box up. Return value would be showing that either users printed or cancelled to do it. java.awt.print.PrinterException could be thrown by the JTable.print, that is considered to be a checked exception, this is the reason given example use try…catch.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1340-jtable-printing.html</guid>
		</item>
		<item>
			<title>Specifying Tool Tips for Cells</title>
			<link>http://www.java-forums.org/blogs/java-swing/1339-specifying-tool-tips-cells.html</link>
			<pubDate>Thu, 26 Apr 2012 18:46:35 GMT</pubDate>
			<description>Tool tip text that has been displayed is found out for a table cell by the renderer of cell, by default. But it might sometimes much simple thing to...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Tool tip text that has been displayed is found out for a table cell by the renderer of cell, by default. But it might sometimes much simple thing to make specification of the tool tip text, by overriding the implementation of JTable of the method getToolTipText. How to use these 2 techniques have been shown in this section.<br />
<br />
For addition of the tool tip in cell by renderer, first thing that needs to be done is to create or get the cell renderer. After this make it sure that JComponent would be the rendering component and then setToolTipText shall be invoked at it.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1339-specifying-tool-tips-cells.html</guid>
		</item>
		<item>
			<title>Using Custom Renderers</title>
			<link>http://www.java-forums.org/blogs/java-swing/1338-using-custom-renderers.html</link>
			<pubDate>Thu, 26 Apr 2012 18:45:50 GMT</pubDate>
			<description>This section shows how cell renderer could be specified or created. “Type specific” cell renderer could be set by the help of JTable...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">This section shows how cell renderer could be specified or created. “Type specific” cell renderer could be set by the help of JTable setDefaultRenderer method. Cells could be specified in a specific column by using a renderer. However, TableColumn method setCellRenderer is used usually by people. A “Cell specific” renderer could be specified by creation of subclass JTable.<br />
Image or text could easily be customized that are rendered by DefaultTableCellRenderer. Just one subclass is created and setValue method is being implemented so setIcon or setText is invoked along with appropriate image or string. Default date renderer gets implemented as following:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">static class DateRenderer extends DefaultTableCellRenderer {
    DateFormat formatter;
    public DateRenderer() { super(); }

    public void setValue(Object value) {
        if (formatter==null) {
            formatter = DateFormat.getDateInstance();
        }
        setText((value == null) ? &quot;&quot; : formatter.format(value));
    }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1338-using-custom-renderers.html</guid>
		</item>
		<item>
			<title>Creating a Table Model</title>
			<link>http://www.java-forums.org/blogs/java-swing/1337-creating-table-model.html</link>
			<pubDate>Thu, 26 Apr 2012 18:45:07 GMT</pubDate>
			<description>A table model object is used by every table object for management of the actual data of the table. Interface TableModel shall be implemented by the...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">A table model object is used by every table object for management of the actual data of the table. Interface TableModel shall be implemented by the table model object. If table model object is not provided by the programmer them DefaultTableModel instance is automatically created by the the JTable. This kind of relationship is given below:<br />
<br />
SimpleTableDemo uses the JTable constructor to create table model, along with code:<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">new AbstractTableModel() {
    public String getColumnName(int col) {
        return columnNames&#91;col&#93;.toString();
    }
    public int getRowCount() { return rowData.length; }
    public int getColumnCount() { return columnNames.length; }
    public Object getValueAt(int row, int col) {
        return rowData&#91;row&#93;&#91;col&#93;;
    }
    public boolean isCellEditable(int row, int col)
        { return true; }
    public void setValueAt(Object value, int row, int col) {
        rowData&#91;row&#93;&#91;col&#93; = value;
        fireTableCellUpdated(row, col);
    }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1337-creating-table-model.html</guid>
		</item>
		<item>
			<title>Setting and Changing Column Widths of JTable</title>
			<link>http://www.java-forums.org/blogs/java-swing/1336-setting-changing-column-widths-jtable.html</link>
			<pubDate>Thu, 26 Apr 2012 18:44:33 GMT</pubDate>
			<description>All tables which are there in a table by default start with equivalent width and columns are automatically filling up the whole table’s width. When...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">All tables which are there in a table by default start with equivalent width and columns are automatically filling up the whole table’s width. When table has become narrow or wide, all widths of column would be changed appropriately.<br />
<br />
<br />
When a column is resized by dragging the right border then size of the table or the size of the column must change. Size of the table remains similar by default &amp; all columns which are right to the drag point would be resized so that space could be accommodated of removal or addition from column, to drag point’s left.<br />
Initial width of columns could be customized by invoking the setPreferredWidth at columns of your table. In this way  preferred column widths and relative widths would be settled. Consider the given example where addition of the given code to SimpleTableDemo would be making 3rd column big as compared to other columns present.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">TableColumn column = null;
for (int i = 0; i &lt; 5; i++) {
    column = table.getColumnModel().getColumn(i);
    if (i == 2) {
        column.setPreferredWidth(100); //third column is bigger
    } else {
        column.setPreferredWidth(50);
    }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1336-setting-changing-column-widths-jtable.html</guid>
		</item>
		<item>
			<title>Adding a Table to a Container</title>
			<link>http://www.java-forums.org/blogs/java-swing/1335-adding-table-container.html</link>
			<pubDate>Thu, 26 Apr 2012 18:43:53 GMT</pubDate>
			<description>Scroll pane creation has a typical code which servers to be a container, for a table. 
 
 
JScrollPane scrollPane = new JScrollPane(table);...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Scroll pane creation has a typical code which servers to be a container, for a table.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 In this snippet, 2 lines would be doing the given:<br />
<br />
•	Along with an argument, constructor JScrollPane would be invoked which will be referring to the table objects. A scroll pane would be created as a container for sake of table; automatically addition of the table would be done to the container.<br />
•	For setting up the property fillsViewportHeight, invoke JTable.setFillsViewportHeight.Entire container’s height is used by the table when property turns out to be true. Even when enough rows are absent in table to be used in vertical space. In this wasy table is easily used  as drag &amp; drop target.<br />
<br />
Table header is placed automatically at the viewport’s top. Name of the column stays visible at the view area’s top when the data of table is being scrolled.<br />
<br />
If you are using a table without a scroll pane, then you must get the table header component and place it yourself. For example:<br />
<br />
When table is being used with no scroll pane, table header component shall be obtained and placed you. For instance<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">container.setLayout(new BorderLayout());
container.add(table.getTableHeader(), BorderLayout.PAGE_START);
container.add(table, BorderLayout.CENTER);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1335-adding-table-container.html</guid>
		</item>
		<item>
			<title>JTable Introduction</title>
			<link>http://www.java-forums.org/blogs/java-swing/1334-jtable-introduction.html</link>
			<pubDate>Thu, 26 Apr 2012 18:42:50 GMT</pubDate>
			<description>Many facilities are present in a JTable which makes the rendering and editing possible. But defaults are also provided for such features hence to...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Many facilities are present in a JTable which makes the rendering and editing possible. But defaults are also provided for such features hence to setup the tables very easily. For instance, a table could be setup with 10 columns and 10 rows of numbers.<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">      TableModel dataModel = new AbstractTableModel() {
          public int getColumnCount() { return 10; }
          public int getRowCount() { return 10;}
          public Object getValueAt(int row, int col) { return new Integer(row*col); }
      };
      JTable table = new JTable(dataModel);
      JScrollPane scrollpane = new JScrollPane(table);</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 Applications which use JTable, they shall be designed in such a way that a special kind of attention is being given to the structures of data which present the data present in a table. DefaultTableModel is considered to be a model implementation which use “vector of vector” of objects so that cell values could be stored. Also data copied from application to the DefaultTableModel, data could be wrapped in TableModel interface so that data might be sent directly to the JTable. Often it would be resulting in much more efficient applications as models are given free hand to make choice of the internal presentation of the data. Rule of thumb to decide the usage of the DefaultTableModel or AbstractTableModel is using AbstractTableModel for creation of subclass and other one when subclasses are not needed.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1334-jtable-introduction.html</guid>
		</item>
		<item>
			<title>Closer Look at Swing. Where is MVC?</title>
			<link>http://www.java-forums.org/blogs/java-swing/1333-closer-look-swing-where-mvc.html</link>
			<pubDate>Thu, 26 Apr 2012 18:42:09 GMT</pubDate>
			<description>Model delegate which a common MVC flavor is being implemented by the internally swing, which coalesces controller and view to UI delegate. Rarely,...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Model delegate which a common MVC flavor is being implemented by the internally swing, which coalesces controller and view to UI delegate. Rarely, developers deal with controller or view part while applications are being written. Instead they deal with components.Swing components are not at all the part of MVC but they are considered as mediators present b/w view, model and controller.<br />
<br />
Custom coding is involved in building of the components and model creations to communicate to the sub components or to synchronize the model and view. Resulted components comprise of mixture of code which deal with view, controller and model tasks.<br />
<br />
Swing components are great job doers for separation of look &amp; feel, from application’s logic. However MVC split is easily lost by them at application level and usually they endup with a spaghetti of codes, by performing several non relevant tasks. In case of complex applications, problem is more severe as every component possess sub element’s dzones which require own handlings.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1333-closer-look-swing-where-mvc.html</guid>
		</item>
		<item>
			<title>Interaction Between MVC Components</title>
			<link>http://www.java-forums.org/blogs/java-swing/1332-interaction-between-mvc-components.html</link>
			<pubDate>Thu, 26 Apr 2012 18:41:19 GMT</pubDate>
			<description>In this section, a closer look will be taken to do the implementation of Fig. 1, in context of the application which is present in Java SE 6. Once...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">In this section, a closer look will be taken to do the implementation of Fig. 1, in context of the application which is present in Java SE 6. Once view, model and controller objects get instantiated, this will happen:<br />
<br />
1.	At the model, view is being registered as listener. Changes being done to the model’s data would be instantly resulting into a change notification that will be received by the view. This is the most common example of “push model”. It shall be noted that model doesn’t know anything about controller and view. It just send change notifications to all listeners.<br />
2.	Controller is view bounded. Typically this means that user actions at view will be invoking the registered listener methods, in controller class.<br />
3.	Reference is given to controller, to the underlying model.<br />
<br />
Once an interaction of user is done with the view, this action occur:<br />
<br />
1.	GUI actions recognized by the view. For example, scroll bar dragging or button pushing, listener method is used which can be called whenever this kind of action takes place.<br />
2.	On the controller, appropriate method is called by the view.<br />
3.	Model is accessed by the controller, which updates in an appropriate method to the actions of the user.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1332-interaction-between-mvc-components.html</guid>
		</item>
		<item>
			<title>What Is Model-View-Controller (MVC)?</title>
			<link>http://www.java-forums.org/blogs/java-swing/1331-what-model-view-controller-mvc.html</link>
			<pubDate>Thu, 26 Apr 2012 18:40:16 GMT</pubDate>
			<description>In past years if you have done programming with the libraries of  GUI then you must would have come across the MVC design i.e model view controller...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">In past years if you have done programming with the libraries of  GUI then you must would have come across the MVC design i.e model view controller design. It was firstly introduced by the Trygve Reenskaug who was a developer at XPAR (Xerox Palo Alto Research Center ) in 1979. He used to decouple the business logic and data access , in a manner which then is displayable to the user.MVC consists of 3 basic elements, which are given below:<br />
<br />
•	Model - Rules and the data are presented by this model who gover the data updates and also govern the access of the date. Model usually serves to be a software approximation, of process of a real world.<br />
<br />
•	View - Model contents are rendered by the view. Exactly it is been shown that how data of model can be represented. If the model data gets changed then presentation of the view shall get updated. This could only be done by push model where view is registered with model, for change notifications. Or, pull method could be used where view is totally responsible for method calling when current data is needed to be retrieved.<br />
<br />
•	Controller -Interactions of the users are translated by the controller into those actions which will be performed by the model. In case of GUI client who stand alone, user interactions might be menu selections or button clicks. However in case of web applications, they will be appearing as POST HTTP or GET requests. It depends upon the context that a new view might be selected. For example, result’s web page for presenting to users.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1331-what-model-view-controller-mvc.html</guid>
		</item>
		<item>
			<title>How to Write a Mouse-Wheel Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1330-how-write-mouse-wheel-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:39:08 GMT</pubDate>
			<description>When mouse’s wheel get rotated, it is been notified by the mouse wheel events. All mice don’t have wheels and in those cases generation of mouse...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">When mouse’s wheel get rotated, it is been notified by the mouse wheel events. All mice don’t have wheels and in those cases generation of mouse wheel events is never done. No other way is present to detect programmatically that whether mouse wheel is present in a mouse or not.<br />
<br />
MouseAdapter AWT class shall be used alternatively that would be implementing the interface MouseWheelListener, for creation of the MouseWheelEvent and overriding the specific event methods.<br />
It is not important usually to make the implementation of the mouse wheel listener as scrolling is the basic job of the mouse wheel. Automatically, scroll panes register the listeners which appropriately react with the mouse wheel.<br />
<br />
However, custom component creation so that it could be used in scroll pane, scrolling behavior shall be customized. You may need to set the block increments and unit.<br />
For generation of the mouse wheel events, it is must that cursor is present at the component which is registered for listening the mouse wheel events. Scrolling which is done, either WHEEL_BLOCK_SCROLL or WHEEL_UNIT_SCROLL, is dependent upon the platform. Scrolling of the mouse wheel is also dependent upon platform. Both amount and type of scrolling might be set through control panel of the mouse.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1330-how-write-mouse-wheel-listener.html</guid>
		</item>
		<item>
			<title>How to Write a Mouse Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1329-how-write-mouse-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:38:24 GMT</pubDate>
			<description>To do interaction with a component, mouse is used by the user and this is notified by the mouse events. Usually mouse events take place when cursor...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">To do interaction with a component, mouse is used by the user and this is notified by the mouse events. Usually mouse events take place when cursor gets entered or exit from onscreen area of the component and when button of mouse is pressed or released.<br />
<br />
To track down the motion of cursor usually involve more system;s overheads as compared to tracking of the other events. This is the reason why mouse motion events have been placed separately in Mouse motion, listener type.<br />
<br />
Mouse wheel listener shall be registered in case one needs to track down the mouse wheel events.<br />
<br />
If both mouse motion events and moust events are required to be detected then class MouseInputAdapter shall be used. MouseInputAdapter is implemented by this class, which is an easier interface for implementation of the MouseMotionListener and MouseListener interfaces. However, interface MouseWheelListener is not implemented by the MouseInputListener interface.<br />
Alternatively, correspondent MouseAdapter class shall be used for implementation of interfaces like, MouseMotionListener, MouseWheelListener &amp; MouseListener.<br />
<br />
Mouse listener is being shown in the given example. At window’s top, there is present a blank area which is basically implemented by the help of class BlankArea. Events are listened by the mouse listener, both at the container and the BlankArea. Everytime a mouse-event takes place, blank area gets filled up with a descriptive message.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1329-how-write-mouse-listener.html</guid>
		</item>
		<item>
			<title>How to Write a List Selection Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1328-how-write-list-selection-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:37:41 GMT</pubDate>
			<description>When selection of table or list is changed or is changing, then list selection event takes place. From an object, these list selection events get...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">When selection of table or list is changed or is changing, then list selection event takes place. From an object, these list selection events get fired which result in implementation of interface ListSelectionModel. To get the list selection model of the table, either use getColumnModel().getSelectionModel() or getSelectionModel method.<br />
<br />
For detection of the list selection events, register listener at the list selection model which is appropriate. An option to register the listener is also given at the list instead of list selection model directly.<br />
Two examples have been given in this section to show that how a list selection event could be listened at a selection model. Examples in which list selection listeners is used list the examples which listen directly at the list.<br />
<br />
Selection mode could be changed dynamically to any of these given modes.<br />
<br />
•	“Single interval” selection mode.<br />
•	“Single” selection mode.<br />
•	“Multiple interval” selection mode.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1328-how-write-list-selection-listener.html</guid>
		</item>
		<item>
			<title>How to Write a Key Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1327-how-write-key-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:33:10 GMT</pubDate>
			<description>Key events are being indicated when user starts typing keyboard. Key events are specifically fired with keyboard focus by the component when keyboard...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Key events are being indicated when user starts typing keyboard. Key events are specifically fired with keyboard focus by the component when keyboard keys are pressed or releaserd. “How Focus Subsytem could be used” shall be read for more information regarding focus.<br />
<br />
Regarding 2 key events, the notifications are being sent.<br />
<br />
•	Unicode character typing<br />
•	To pressor release a key present at the keyboard<br />
<br />
First event is known as key typed event. Second one is either key release or key pressed event.<br />
<br />
Generally, just key typed events would be reacted by you unless you come to know that when keys are pressed by the user doesn’t correspond, to characters. Let us say for example, to be aware that when a Unicode character â€ is typed by the user either by one key press like “a” or several key press sequentially to handle the events which are key typed. Similarly to be aware that user either pressed F1 key or 3 key was pressed at the number pad, key pressed events are handled.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1327-how-write-key-listener.html</guid>
		</item>
		<item>
			<title>How to Write an Item Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1326-how-write-item-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:32:14 GMT</pubDate>
			<description>Components fire the item events which are involved in implementation of the interface ItemSelectable. ItemSelectable components usually maintain off...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Components fire the item events which are involved in implementation of the interface ItemSelectable. ItemSelectable components usually maintain off and on state for the items. Swing components involved in firing items include certain buttons, for example, check menu items, combo boxes, check boxes and toggle buttons etc.<br />
Code for the item event handling that has been taken by ComponentEventDemo.java.<br />
<br />
<div class="bbcode_container">
	<div class="bbcode_description">Java Code: </div>

	<pre class="brush: java">//where initialization occurs
checkbox.addItemListener(this);
...
public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
        label.setVisible(true);
        ...
    } else {
        label.setVisible(false);
    }
}</pre>
	<script type="text/javascript">mh_sh_highlight_all('java');</script>

</div>
 </blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1326-how-write-item-listener.html</guid>
		</item>
		<item>
			<title>How to Write an Internal Frame Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1325-how-write-internal-frame-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:31:27 GMT</pubDate>
			<description>WindowListener and InternalFrameListener are similar. Just like the window listener, events are listened by the internal frame listeners which take...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">WindowListener and InternalFrameListener are similar. Just like the window listener, events are listened by the internal frame listeners which take place as window is being shown for very 1st time or are iconified, disposed of, activated, deiconified or deactivated. <br />
<br />
Following figure shows the application in which internal frame events have been demonstrated. Internal frame events are being listened by the application by the Event Generator frame, which display messages describing every event.<br />
<div style="text-align: center;"><br />
<img src="http://www.java-forums.org/attachments/java-software/3647d1335465075-genesis-framework-3-0-1.jpg" border="0" alt="Name:  1.jpg
Views: 115
Size:  35.7 KB" class="thumbnail" style="float:CONFIG" /><br />
<b>Frame Listener</b></div></blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1325-how-write-internal-frame-listener.html</guid>
		</item>
		<item>
			<title>How to Write a Focus Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1324-how-write-focus-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:30:08 GMT</pubDate>
			<description>When keyboard focus is being gained or lost by the component, focus events usually get fired. This is applicable no matter change in focus would be...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">When keyboard focus is being gained or lost by the component, focus events usually get fired. This is applicable no matter change in focus would be occurring via keyboard, mouse or programmatically. <br />
<br />
Here is will be explained that how focus events could be obtained for a component by making a FocusListener instance registered at it. Only for window, focus can be obtained by implementation of the WindowFocusListener instance. For many components implementation of the PropertyChangeListener instance could be considered at the class KeyboardFocusManager. <br />
<br />
Focus events could be demonstrated by the given example. Many components are being displayed by the window. Focus listener which is registered at every component will be reporting each focus lost or gained event. For every event, other components present in the focus change, opposite Component gets reported. For instance, when focus is shifted from button towards the text field, button would be firing the focus lost event and text field would be firing the focus gained event. Focus gained as well as lost events could not be permanent. Let us say for example, temporary lost event would occur as the focus is lost by the window. A temporary events would be occurring at popup menus.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1324-how-write-focus-listener.html</guid>
		</item>
		<item>
			<title>How to Write a Document Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1323-how-write-document-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:29:20 GMT</pubDate>
			<description>A document is used by the swing text component for representation of its components. When document’s content changes, document events take place. A...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">A document is used by the swing text component for representation of its components. When document’s content changes, document events take place. A document listener is attached to the text of document of the component instead of the text component, itself. <br />
<br />
Document events are demonstrated by the given example, at 2 text components.<br />
<br />
<div style="text-align: center;"><img src="http://www.java-forums.org/attachments/java-software/3646d1335464943-gochacha-a0-1-1.jpg" border="0" alt="Name:  1.jpg
Views: 304
Size:  16.1 KB" class="thumbnail" style="float:CONFIG" /><br />
<b>Document Listener</b></div></blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1323-how-write-document-listener.html</guid>
		</item>
		<item>
			<title>How to Write a Container Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1322-how-write-container-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:27:48 GMT</pubDate>
			<description>A container is involved in firing the Container events; right after the component gets added/removed. Such kinds of events are just for sake of...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">A container is involved in firing the Container events; right after the component gets added/removed. Such kinds of events are just for sake of notifications. Container listeners are not needed to be there for adding or removing the components successfully.<br />
<br />
Container events are demonstrated by the given example. Click at ADD A BUTTON /Remove Button to add or remove buttons from the panel which is present at the window’s bottom. Everytime button is added/removed, container event is fired from a panel and container listener of the panel is sent notification. Descriptive messages are displayed by the listener in text area which is present at window’s top:</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1322-how-write-container-listener.html</guid>
		</item>
		<item>
			<title>How to Write a Component Listener</title>
			<link>http://www.java-forums.org/blogs/java-swing/1321-how-write-component-listener.html</link>
			<pubDate>Thu, 26 Apr 2012 18:26:58 GMT</pubDate>
			<description>Component listener is considered as a listener interface to receive the component events. Component is that object which has a graphical presentation...</description>
			<content:encoded><![CDATA[<blockquote class="blogcontent restore">Component listener is considered as a listener interface to receive the component events. Component is that object which has a graphical presentation which might be displayed at screen or may also interact with some user. Few component examples are scrollbars, checkboxes and buttons of graphical interface.<br />
<br />
Class involved in component event processing will be implementing this interface along with all of the contained methods or will be extending the abstract ComponentAdapter. Listener object that is made gets then registered by the method addComponentListener of the component. When visibility, size or location of the component changes, listener object’s relevant method is invoked <br />
One or more than one component events have been fired, by component object, when component becomes hidden, moved, made visible or resized.<br />
<br />
Component shown and component hidden events usually occur when Component 's setVisible method is called. For instance, window may get miniaturized to iconified, with no component hidden event, being fired.</blockquote>

]]></content:encoded>
			<dc:creator>Java Swing</dc:creator>
			<guid isPermaLink="true">http://www.java-forums.org/blogs/java-swing/1321-how-write-component-listener.html</guid>
		</item>
	</channel>
</rss>
