<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="https://javawiki.sowas.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://javawiki.sowas.com/feed.php">
        <title>Java Wiki en:swing</title>
        <description></description>
        <link>https://javawiki.sowas.com/</link>
        <image rdf:resource="https://javawiki.sowas.com/lib/images/favicon.ico" />
       <dc:date>2023-09-19T09:07:46+02:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:antialiasing&amp;rev=1349789388&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:anwendung_beenden_beim_schliessen_eines_jframe&amp;rev=1348902109&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:application-icon&amp;rev=1348902064&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:beep&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:display-html&amp;rev=1349620578&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:fontmetrics&amp;rev=1349619093&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:gridbaglayout&amp;rev=1349620551&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:htmldocument&amp;rev=1349620622&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:htmleditorkit-getstylesheet&amp;rev=1349620589&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:hyperlinklistener&amp;rev=1349620642&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:image-bufferedimageicon&amp;rev=1349620654&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:invokelater-invokeandwait&amp;rev=1348902080&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jbutton-icon&amp;rev=1349620668&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jcombobox-layout&amp;rev=1349620680&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jfilechooser&amp;rev=1349620692&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jframe-find&amp;rev=1349620708&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jlabel-hyperlink&amp;rev=1349620720&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jpanel-transparent&amp;rev=1349620730&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jprogressbar&amp;rev=1349620742&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jradiobutton&amp;rev=1349620757&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtabbedpane&amp;rev=1349620768&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-column-width&amp;rev=1349620864&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-dnd&amp;rev=1349620782&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-row-height&amp;rev=1349620885&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-rowheader&amp;rev=1349620842&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-setselection&amp;rev=1349620853&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-tablecellrenderer&amp;rev=1349620875&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtextfield-numeric&amp;rev=1579723238&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtextfield-size&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtooltip-images&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtree-icons&amp;rev=1579723238&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtree-transparent&amp;rev=1579723238&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtree-treenode&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:jtree&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:keylistener-keyevent&amp;rev=1579723238&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:modifyfont&amp;rev=1349619048&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:resize-listener&amp;rev=1349789790&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:return-enter&amp;rev=1349790219&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:simple-input-dialog&amp;rev=1349791919&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:splashscreen&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:strong-lines&amp;rev=1349789503&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:stylesheet&amp;rev=1579723238&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:swing-messagebox&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:swing&amp;rev=1408453038&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:systemcolors&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:tooltip-delay&amp;rev=1579723236&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:treepath&amp;rev=1579723237&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:window-center&amp;rev=1349619031&amp;do=diff"/>
                <rdf:li rdf:resource="https://javawiki.sowas.com/doku.php?id=en:swing:window-maximize&amp;rev=1348902021&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://javawiki.sowas.com/lib/images/favicon.ico">
        <title>Java Wiki</title>
        <link>https://javawiki.sowas.com/</link>
        <url>https://javawiki.sowas.com/lib/images/favicon.ico</url>
    </image>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:antialiasing&amp;rev=1349789388&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-09T15:29:48+02:00</dc:date>
        <title>en:swing:antialiasing</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:antialiasing&amp;rev=1349789388&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.Graphics2D

java.awt.RenderingHints








The code-example draws a line and a string almost without stairs effect:




public void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D)g;
   g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
   g2.drawLine(0, 0, 100, 100);
   g2.drawString(&quot;Test&quot;, 0, 20);
}</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:anwendung_beenden_beim_schliessen_eines_jframe&amp;rev=1348902109&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-09-29T09:01:49+02:00</dc:date>
        <title>en:swing:anwendung_beenden_beim_schliessen_eines_jframe</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:anwendung_beenden_beim_schliessen_eines_jframe&amp;rev=1348902109&amp;do=diff</link>
        <description>Java - AWT/Swing



Normally, by activating the „x“-button of the frame, the application is only hidden but not closed. But you can change this by means of the following instruction:









JFrame frame = new ...
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:application-icon&amp;rev=1348902064&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-09-29T09:01:04+02:00</dc:date>
        <title>en:swing:application-icon</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:application-icon&amp;rev=1348902064&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.Toolkit

The class JFrame disposes of the method setIconImage, over which the application-icon can be set.









   Image img = Toolkit.getDefaultToolkit().getImage(&quot;images/tdg.png&quot;);
   setIconImage(img);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:beep&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:beep</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:beep&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing



A simple beep, which is used for error messages, can be produced like this:









java.awt.Toolkit.getDefaultToolkit().beep();</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:display-html&amp;rev=1349620578&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:36:18+02:00</dc:date>
        <title>en:swing:display-html</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:display-html&amp;rev=1349620578&amp;do=diff</link>
        <description>Java - AWT/Swing



The class JEditorPane makes it possible to display HTML on a very simple way.









JEditorPane editor = new JEditorPane();
editor.setContentType(&quot;text/html&quot;);
editor.setEditable(false);
editor.setText(&quot;&lt;html&gt;&lt;body&gt;&lt;p&gt;Hallo World!&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;&quot;);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:fontmetrics&amp;rev=1349619093&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:11:33+02:00</dc:date>
        <title>en:swing:fontmetrics</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:fontmetrics&amp;rev=1349619093&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.FontMetrics

java.awt.Graphics

This class comes up with information to a font.

The example hands out the total width of a string:









public void paint(Graphics g) {
   String str = &quot;Test&quot;;
   FontMetrics fm = g.getFontMetrics(g.getFont());
   System.out.println(&quot;width of 'Test': &quot;+fm.stringWidth(str));
}</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:gridbaglayout&amp;rev=1349620551&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:35:51+02:00</dc:date>
        <title>en:swing:gridbaglayout</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:gridbaglayout&amp;rev=1349620551&amp;do=diff</link>
        <description>Java - AWT/Swing



Again and again you hear that the GridBagLayout is so complicated. It is really very extensive, but as a general rule you only need a few methods.
The GridBagLayout works fundamentally with a thought grid. Each array in this grid can be addressed by its position (x,y).
To define the size of the grid, you can outline the desired layout on a piece of paper.
With the class GridBagConstraints, the qualities of a single element are determined.








Example

The desired dialogue…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:htmldocument&amp;rev=1349620622&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:37:02+02:00</dc:date>
        <title>en:swing:htmldocument</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:htmldocument&amp;rev=1349620622&amp;do=diff</link>
        <description>Java - AWT/Swing



In the example, an HTML-document is converted to pure text (well, merely the &lt;br&gt;-tag is taken into consideration):









package com.sowas.javawiki.snippets;

import java.io.Reader;
import java.io.StringReader;

import javax.swing.text.EditorKit;
import javax.swing.text.MutableAttributeSet;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;

public class HtmlToText {

   public static String getText(St…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:htmleditorkit-getstylesheet&amp;rev=1349620589&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:36:29+02:00</dc:date>
        <title>en:swing:htmleditorkit-getstylesheet</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:htmleditorkit-getstylesheet&amp;rev=1349620589&amp;do=diff</link>
        <description>Java - AWT/Swing



If HTML-code shall be depicted in JEditorPane, so the basis-character set can be modified with the following code:









StyleSheet css = ((HTMLEditorKit)jmEditorPane.getEditorKit()).getStyleSheet();
css.addRule(&quot;P { margin: 0; font-family: Arial, sans-serif; font-size: 11px; font-style: normal; }&quot;);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:hyperlinklistener&amp;rev=1349620642&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:37:22+02:00</dc:date>
        <title>en:swing:hyperlinklistener</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:hyperlinklistener&amp;rev=1349620642&amp;do=diff</link>
        <description>Java - AWT/Swing



javax.swing.event.HyperlinkListener









JTextPane tp = ...
tp.setText(&quot;&lt;html&gt;&lt;body&gt;&lt;a href=http://javawiki.sowas.com&gt;JavaWiki&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;&quot;);
tpBody.addHyperlinkListener(new HyperlinkListener() {
   public void hyperlinkUpdate(HyperlinkEvent e) {
      if (e.getEventType() == HyperlinkEvent.EventType.ACTIVATED)
	 System.out.prinln(&quot;You have clicked on this link: &quot; + e.getDescription());
      }
});</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:image-bufferedimageicon&amp;rev=1349620654&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:37:34+02:00</dc:date>
        <title>en:swing:image-bufferedimageicon</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:image-bufferedimageicon&amp;rev=1349620654&amp;do=diff</link>
        <description>Java - AWT/Swing









JLabel dummyObserver = new JLabel();
Image image          = Toolkit.getDefaultToolkit().getImage(&quot;myimage.jpg&quot;);
int width            = image.getWidth(dummyObserver);
int height           = image.getHeight(dummyObserver);
BufferedImage bImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
bImage.getGraphics().drawImage(image, 0, 0, dummyObserver);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:invokelater-invokeandwait&amp;rev=1348902080&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-09-29T09:01:20+02:00</dc:date>
        <title>en:swing:invokelater-invokeandwait</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:invokelater-invokeandwait&amp;rev=1348902080&amp;do=diff</link>
        <description>Java - AWT/Swing



com.javax.SwingUtilities

At Swing the same thread is responsible for drawing the surface new and working off the events. This is especially unpleasant, if a rake-intensive operation is activated by pressing a button. This results in that the button seems to be pressed as long as the operation continues. The GUI seems to be freezed up until the operation is finished.








Here, the SwingUtilities offer two methods: invokeLater and invokeAndWait.

invokeLater works out of s…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jbutton-icon&amp;rev=1349620668&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:37:48+02:00</dc:date>
        <title>en:swing:jbutton-icon</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jbutton-icon&amp;rev=1349620668&amp;do=diff</link>
        <description>Java - AWT/Swing









URL url = getClass().getResource(&quot;images/close-4x4.png&quot;);
Button myButton = new JButton(new ImageIcon(url));
// Oder:
// myButton.setIcon(new ImageIcon(url));</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jcombobox-layout&amp;rev=1349620680&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:38:00+02:00</dc:date>
        <title>en:swing:jcombobox-layout</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jcombobox-layout&amp;rev=1349620680&amp;do=diff</link>
        <description>Java - AWT/Swing



The layout with a JComboBox can be a bit complicated under circumstances.

The PreferredSize of a JComboBox is by long text entries the width of the longest entry.

This quality can lead into the destruction of the whole layout.

A simple remedy is the setting of PreferredSize:</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jfilechooser&amp;rev=1349620692&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:38:12+02:00</dc:date>
        <title>en:swing:jfilechooser</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jfilechooser&amp;rev=1349620692&amp;do=diff</link>
        <description>Java - AWT/Swing



javax.swing.JFileChooser









JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
fc.setMultiSelctionEnabled(false);
fc.setCurrentDirectory(new File(System.getProperty(&quot;user.home&quot;)));
if (fc.showDialog(this, &quot;open file&quot;) == JFileChooser.APPROVE_OPTION) {
   System.out.println(fc.getSelectedFile().getAbsoluteFile());
}</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jframe-find&amp;rev=1349620708&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:38:28+02:00</dc:date>
        <title>en:swing:jframe-find</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jframe-find&amp;rev=1349620708&amp;do=diff</link>
        <description>Java - AWT/Swing









Component frame = SwingUtilities.getRoot(myComponent);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jlabel-hyperlink&amp;rev=1349620720&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:38:40+02:00</dc:date>
        <title>en:swing:jlabel-hyperlink</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jlabel-hyperlink&amp;rev=1349620720&amp;do=diff</link>
        <description>Java - AWT/Swing



Each label can contain a hyperlink with little code:









JLabel label = new JLabel(&quot;&lt;html&gt;&lt;body&gt;&lt;a href=\&quot;http://javawiki.sowas.com\&quot;&gt;http://javawiki.sowas.com&lt;/a&gt;&lt;/body&gt;&lt;/html&gt;&quot;);
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
label.addMouseListener(new MouseAdapter() {
   @Override
   public void mouseClicked(MouseEvent e) {
      if (e.getClickCount() &gt; 0) {
         // browsercall (for Windows):
         Runtime.getRuntime().exec(&quot;cmd.exe /c start h…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jpanel-transparent&amp;rev=1349620730&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:38:50+02:00</dc:date>
        <title>en:swing:jpanel-transparent</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jpanel-transparent&amp;rev=1349620730&amp;do=diff</link>
        <description>Java - AWT/Swing









JPanel panel = new JPanel();
panel.setOpaque(false);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jprogressbar&amp;rev=1349620742&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:39:02+02:00</dc:date>
        <title>en:swing:jprogressbar</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jprogressbar&amp;rev=1349620742&amp;do=diff</link>
        <description>Java - AWT/Swing









int MAX = 10;
JProgressBar progressBar;
progressBar = new JProgressBar(0, MAX);

progressBar.setValue(0);
progressBar.setMaximum(MAX);

for (int i=0; i &lt;= MAX; i++) {
   try {
      Thread.sleep(100);
   } catch {
      e.printStackTrace();
   }
   progressBar.setValue(i);
}</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jradiobutton&amp;rev=1349620757&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:39:17+02:00</dc:date>
        <title>en:swing:jradiobutton</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jradiobutton&amp;rev=1349620757&amp;do=diff</link>
        <description>Java - AWT/Swing



The example-code produces two radiobuttons which are part of a group:









// produce two RadioButtons:
JRadioButton rb1 = new JRadioButton(&quot;Button 1&quot;, false);
JRadioButton rb2 = new JRadioButton(&quot;Button 2&quot;, false);
// assign both RadioButtons to a ButtonGroup, with that only one radiobuttons can be chosen at time:
ButtonGroup bg = new ButtonGroup();
bg.add(rb1);
bg.add(rb2);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtabbedpane&amp;rev=1349620768&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:39:28+02:00</dc:date>
        <title>en:swing:jtabbedpane</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtabbedpane&amp;rev=1349620768&amp;do=diff</link>
        <description>Java - AWT/Swing






create tabs:




JTabbedPane tp = new JTabbedPane();
tp.addTab(&quot;Tab 1&quot;, new JPanel());
tp.addTab(&quot;Tab 2&quot;, new JPanel());







react to the tab-change:




JTabbedPane tp = new JTabbedPane();
//... (add tabs)
tp.addChangeListener(new ChangeListener() {
   stateChanged(ChangeEvent e) { 
   JTabbedPane tp = (JTabbedPane)e.getSource();
   int indx = tp.getSelectedIndex(); 
   // indx identifys the selected tab.
}</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-column-width&amp;rev=1349620864&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:41:04+02:00</dc:date>
        <title>en:swing:jtable-column-width</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtable-column-width&amp;rev=1349620864&amp;do=diff</link>
        <description>Java - AWT/Swing



javax.swing.table.JTable









JTable table = new JTable(10, 20);

// turn off autoresizing, or else all columns are equal wide:
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
   
// set first column on 100 pixel width:
final int INDEX_COLUMN1 = 0;
TableColumn col = table.getColumnModel().getColumn(INDEX_COLUMN1);
col.setPreferredWidth(100);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-dnd&amp;rev=1349620782&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:39:42+02:00</dc:date>
        <title>en:swing:jtable-dnd</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtable-dnd&amp;rev=1349620782&amp;do=diff</link>
        <description>Java - AWT/Swing



If the drag and drop does not function by an empty table, then you should try it with the following code:









table.setFillsViewportHeight(true);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-row-height&amp;rev=1349620885&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:41:25+02:00</dc:date>
        <title>en:swing:jtable-row-height</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtable-row-height&amp;rev=1349620885&amp;do=diff</link>
        <description>Java - AWT/Swing



JTable offers a simple order to set the height of the line:




JTable table = new JTable(...
table.setRowHeight(24);



By the way, the font stays unrevised with it. If this is to be changed, a TableCellRenderer must be insert.</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-rowheader&amp;rev=1349620842&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:40:42+02:00</dc:date>
        <title>en:swing:jtable-rowheader</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtable-rowheader&amp;rev=1349620842&amp;do=diff</link>
        <description>Java - AWT/Swing



Sometimes you want to have a lettering for the lines of a table, as it is usual by table calculationsn. This can be achieved through a further list at the left, next to the table.











package com.sowas.javawiki.rowheadertable;

import java.awt.BorderLayout;
import java.awt.Component;

import javax.swing.AbstractListModel;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import jav…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-setselection&amp;rev=1349620853&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:40:53+02:00</dc:date>
        <title>en:swing:jtable-setselection</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtable-setselection&amp;rev=1349620853&amp;do=diff</link>
        <description>Java - AWT/Swing



To set the selection/marking in a JTable, you must use the SelectionModel:









JTable table = new JTable(...
table.getSelectionModel().setSelectionInterval(1, 3);  // marks the lines 1-3</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtable-tablecellrenderer&amp;rev=1349620875&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:41:15+02:00</dc:date>
        <title>en:swing:jtable-tablecellrenderer</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtable-tablecellrenderer&amp;rev=1349620875&amp;do=diff</link>
        <description>Java - AWT/Swing



JTable offers the possibility to change the depiction of a table by means of a TableCellRenderer:



public class MyRenderer extends JLabel implements TableCellRenderer {
   public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, 
                                                  boolean hasFocus, int row, int column) {
      TableModel model = table.getModel();
      setBackground(row%2==0 ? Color.WHITE : Color.YELLOW);
      setForegro…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtextfield-numeric&amp;rev=1579723238&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:38+02:00</dc:date>
        <title>en:swing:jtextfield-numeric</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtextfield-numeric&amp;rev=1579723238&amp;do=diff</link>
        <description>Java - AWT/Swing



In the following code-example only numeric entries are accepted:

To that, an own document „NumberDocument“ is defined.









package com.sowas.snippets.jtextfield;

import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import javax.swing.text.AttributeSet;
import java.math.BigDecimal;

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;


public class NumberDocument extends PlainDocument {
   @Override
   public void insertStri…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtextfield-size&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:jtextfield-size</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtextfield-size&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing



In the following code example the maximal number of symbols is rationed to 10:

To that, an own document „MaxSizeDocument“ is defined.









package com.sowas.snippets.jtextfield;
import java.awt.BorderLayout;
import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
 
 
public class MaxSizeDocument extends PlainDocument {
   …</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtooltip-images&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:jtooltip-images</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtooltip-images&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing



javax.swing.JToolTip

There is a simple possibility to provide a tooltip with a picture:









String imageName = &quot;file:image.gif&quot;;
component.setToolTipText(&quot;&lt;html&gt;Bild: &lt;img src=&quot;+imageName+&quot;&gt;&lt;/html&gt;&quot;);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtree-icons&amp;rev=1579723238&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:38+02:00</dc:date>
        <title>en:swing:jtree-icons</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtree-icons&amp;rev=1579723238&amp;do=diff</link>
        <description>Java - AWT/Swing









JTree myTree = new JTree();
DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer)myTree.getCellRenderer();
renderer.setClosedIcon(iconClosed);  // Icon for snap knot shut
renderer.setOpenIcon(iconOpen);      // Icon for opened knot
renderer.setLeafIcon(iconLeaf);      // Icon for a page</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtree-transparent&amp;rev=1579723238&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:38+02:00</dc:date>
        <title>en:swing:jtree-transparent</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtree-transparent&amp;rev=1579723238&amp;do=diff</link>
        <description>AWT/Swing



javax.swing.JTree

javax.swing.tree.DefaultTreeCellRenderer



To get a JTree totally transparent, an own CellRenderer must be implemented:









DefaultTreeCellRenderer renderer = new DefaultTreeCellRenderer() {  
   
   public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, 
                               boolean expanded, boolean leaf, int row, boolean hasFocus) {
      setOpaque(false);
      return super.getTreeCellRendererComponent(tree, value,…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtree-treenode&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:jtree-treenode</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtree-treenode&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing



An often put question is how to modify the text of a TreeNodes belated.
But it is very easy:









treeModel.nodeChanged(modifiedNode);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:jtree&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:jtree</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:jtree&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing



An easy example for a JTree:











package com.sowas.javawiki.jtree;
 
import java.awt.BorderLayout;
 
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTree;
import javax.swing.tree.DefaultMutableTreeNode;
 
public class JTreeDemo extends JFrame {
 
   public JTreeDemo() {
      setLayout(new BorderLayout());
 
      DefaultMutableTreeNode root = new DefaultMutableTreeNode(&quot;Root&quot;);
      DefaultMutableTreeNode node = new DefaultMutableTreeNo…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:keylistener-keyevent&amp;rev=1579723238&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:38+02:00</dc:date>
        <title>en:swing:keylistener-keyevent</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:keylistener-keyevent&amp;rev=1579723238&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.event.KeyEvent

java.awt.event.KeyAdapter

In the example the keys „Ctrl +“ and „Ctrl -“ shall be discerned:


myControl.addKeyListener(new KeyAdapter() {
   public void keyPressed(KeyEvent e){
      if (e.isControlDown()){  // Ctrl
         if (e.getKeyCode()==KeyEvent.VK_PLUS) {  // +
            System.out.println(&quot;Strg +&quot;);
         }else{
            if (e.getKeyCode()==KeyEvent.VK_MINUS) {  // -
               System.out.println(&quot;Strg -&quot;);
            }
       …</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:modifyfont&amp;rev=1349619048&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:10:48+02:00</dc:date>
        <title>en:swing:modifyfont</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:modifyfont&amp;rev=1349619048&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.Font

If you want to modify an existing font, it is the easiest way to use the following code:









Label label = new Label(&quot;Test&quot;);
label.setFont(label.getFont().deriveFont(Font.BOLD));  // set Font style on BOLD 
label.setFont(label.getFont().deriveFont(12.0));  // set Font size on 12</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:resize-listener&amp;rev=1349789790&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-09T15:36:30+02:00</dc:date>
        <title>en:swing:resize-listener</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:resize-listener&amp;rev=1349789790&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.event.ComponentListener



import java.awt.*;
import java.awt.event.*;

Frame frame = new Frame();
frame.addComponentListener(new ComponentListener() {
   public void componentHidden(ComponentEvent e) {
   }
   public void componentMoved(ComponentEvent e) {
   }
   public void componentResized(ComponentEvent e) {
      System.out.println(&quot;Resized&quot;);
   }
   public void componentShown(ComponentEvent e) {
   }
});</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:return-enter&amp;rev=1349790219&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-09T15:43:39+02:00</dc:date>
        <title>en:swing:return-enter</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:return-enter&amp;rev=1349790219&amp;do=diff</link>
        <description>AWT/Swing



Both return-/enter-keys deliver the KeyCode VK_ENTER (10). The distinction is only possible on the basis of the position:









if (e.getKeyCode() == KeyEvent.VK_ENTER) {
   if(e.getKeyLocation() == KeyEvent.KEY_LOCATION_STANDARD) 
      System.out.println(&quot;Return&quot;);
   else
     if (e.getKeyLocation() == KeyEvent.KEY_LOCATION_NUMPAD) 
        System.out.println(&quot;Enter&quot;);
}</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:simple-input-dialog&amp;rev=1349791919&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-09T16:11:59+02:00</dc:date>
        <title>en:swing:simple-input-dialog</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:simple-input-dialog&amp;rev=1349791919&amp;do=diff</link>
        <description>Java - AWT/Swing



 javax.swing.JOptionPane.showInputDialog(..)

For a simple input there is already a prefabricated dialogue:









String result = JOptionPane.showInputDialog(zero, &quot;entry please:&quot;, &quot;entry-heading&quot;, JOptionPane.QUESTION_MESSAGE);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:splashscreen&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:splashscreen</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:splashscreen&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing



A Splashscreen is mostly showed at the gun of a program. It is about a normal JFrame, whose decorations are just turned off.










package com.sowas.javawiki.splashscreen;
 
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Label;

import javax.swing.JFrame;
 
public class SplashScreenDemo extends JFrame {
 
   public SplashScreenDemo(){
      setLayout(new BorderLayout());
      setLocation(400, 300);
      setPreferredSize(n…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:strong-lines&amp;rev=1349789503&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-09T15:31:43+02:00</dc:date>
        <title>en:swing:strong-lines</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:strong-lines&amp;rev=1349789503&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.Graphics2D

java.awt.Stroke








The code-example draws a line with a thickness of three pixel:




public void paint(Graphics g) {
   Graphics2D g2 = (Graphics2D)g;
   g2.setStroke(new BasicStroke(3));
   g2.drawLine(0, 0, 100, 100);
}</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:stylesheet&amp;rev=1579723238&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:38+02:00</dc:date>
        <title>en:swing:stylesheet</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:stylesheet&amp;rev=1579723238&amp;do=diff</link>
        <description>Java - AWT/Swing



javax.swing.JTextPane

javax.swing.text.html.StyleSheet







JTextPane textPane;
StyleSheet css = new StyleSheet();
css.addRule(&quot;p {margin: 0; font-family: Arial, sans-serif; font-size: 12px; }&quot;);
((HTMLEditorKit)textPane.getEditorKit()).setStyleSheet(css);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:swing-messagebox&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:swing-messagebox</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:swing-messagebox&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing



At the easiest case, a MessageBox under Swing can be realized as follows:









JOptionPane.showMessageDialog(null, &quot;My message!&quot;);</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:swing&amp;rev=1408453038&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2014-08-19T14:57:18+02:00</dc:date>
        <title>en:swing:swing</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:swing&amp;rev=1408453038&amp;do=diff</link>
        <description>*  beep
	*  carry out actions after GUI-update
	*  center window
	*  convert image to BufferedImage
	*  determine JFrame of a component
	*  display HTML, JEditorPane
	*  distinguish Return/Enter
	*  edge smoothing
	*  evaluate keystrokes
	*  FontMetrics
	*  GridBagLayout
	*  HTML, modify font
	*  parse HTMLDocument
	*  HyperlinkListener</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:systemcolors&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:systemcolors</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:systemcolors&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.SystemColor








SystemColor Which colour responds to thatdesktop colour of desktop backgroundactiveCaption backgroundcolour for text in the window frameactiveCaptionText colour for text in the window frameactiveCaptionBorder frame colour for active window frameinactiveCaption backgroundcolour for inactive text in the window frameinactiveCaptionText colour for inactive text in the window frameinactiveCaptionBorder frame colour for inactive window framewindow backg…</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:tooltip-delay&amp;rev=1579723236&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:36+02:00</dc:date>
        <title>en:swing:tooltip-delay</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:tooltip-delay&amp;rev=1579723236&amp;do=diff</link>
        <description>Java - AWT/Swing









ToolTipManager.sharedInstance().setInitialDelay(1000);  // value in ms</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:treepath&amp;rev=1579723237&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2020-01-22T21:00:37+02:00</dc:date>
        <title>en:swing:treepath</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:treepath&amp;rev=1579723237&amp;do=diff</link>
        <description>Java - AWT/Swing








public TreePath getPath(TreeNode treeNode){
   List list = new ArrayList();
   
   while (treeNode != null) {
      list.add(treeNode);
      treeNode = treeNode.getParent();
   }
   Collections.reverse(list);
    
   return new TreePath(list.toArray());
}</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:window-center&amp;rev=1349619031&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-10-07T16:10:31+02:00</dc:date>
        <title>en:swing:window-center</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:window-center&amp;rev=1349619031&amp;do=diff</link>
        <description>Java - AWT/Swing



java.awt.Window

In Java, you can center a window (JFrame, JDialog, ...) with the method setLocationRelativeTo(Component c).

With it, the parameter indicates c, to what paramount window it shall be centered. The parameter c can also be zero. In this case, it is centered on the screen:</description>
    </item>
    <item rdf:about="https://javawiki.sowas.com/doku.php?id=en:swing:window-maximize&amp;rev=1348902021&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2012-09-29T09:00:21+02:00</dc:date>
        <title>en:swing:window-maximize</title>
        <link>https://javawiki.sowas.com/doku.php?id=en:swing:window-maximize&amp;rev=1348902021&amp;do=diff</link>
        <description>Java - AWT/Swing



How it is to maximize the application window in Java shows the following code:









package com.sowas.javawiki;

import java.awt.*;
import javax.swing.*;

public class MaxFrame extends JFrame {
    public MaxFrame() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setExtendedState(JFrame.MAXIMIZED_BOTH);  // Here, the window is maximized
    }

    public static void main(final String[] args) {
       new MaxFrame().setVisible(true);
    }
}</description>
    </item>
</rdf:RDF>
