<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Java User Group Berlin Brandenburg &#187; SQL</title>
	<atom:link href="http://www.jug-bb.de/tag/sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.jug-bb.de</link>
	<description>Der Blog der JUG-BB</description>
	<lastBuildDate>Tue, 24 Jan 2012 07:16:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JEditorPane mit Zeilenhervorhebung</title>
		<link>http://www.jug-bb.de/2009/02/jeditorpane-mit-zeilenhervorhebung/</link>
		<comments>http://www.jug-bb.de/2009/02/jeditorpane-mit-zeilenhervorhebung/#comments</comments>
		<pubDate>Sat, 07 Feb 2009 01:33:24 +0000</pubDate>
		<dc:creator>Jan Lolling</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Code Beispiele]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://blog.jug-bb.de/?p=220</guid>
		<description><![CDATA[Ich habe für meinen Editor eine Möglichkeit gesucht die aktuelle Zeile unter dem Cursor vollständig mit einer anderen Hintergrundfarbe hervorzuheben. Diese Möglichkeit habe ich folgendermassen realisiert: Zusammenfassung: Der JEditorPane füge ich einen speziellen CaretListener hinzu der bei Veränderungen des Cursors einen wiederum für die aktuelle Zeile einen Highlighter einrichtet. Das besondere ist der als innere [...]]]></description>
			<content:encoded><![CDATA[<p><!--:de-->Ich habe für meinen Editor eine Möglichkeit gesucht die aktuelle Zeile unter dem Cursor vollständig mit einer anderen Hintergrundfarbe hervorzuheben. Diese Möglichkeit habe ich folgendermassen realisiert:</p>
<p>Zusammenfassung:</p>
<p>Der JEditorPane füge ich einen speziellen CaretListener hinzu der bei Veränderungen des Cursors einen wiederum für die aktuelle Zeile einen Highlighter einrichtet. Das besondere ist der als innere Klasse realisierte HightlighterPainter. Dieser ist so entwickelt, dass er die ganze Zeile unabhängig von der Zeichenanzahl also auf die sichtbare Breite des Editors hervorhebt.</p>
<p>Hier nun der Quelltext des CaretListeners:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">sqlrunner.text</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Color</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Graphics</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Rectangle</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Shape</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.event.CaretEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.event.CaretListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.plaf.TextUI</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.BadLocationException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.Element</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.Highlighter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.JTextComponent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.LayeredHighlighter</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.Position</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.Utilities</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.text.View</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> HighlightCurrentLineCaretListener <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">CaretListener</span> <span style="color: #009900;">&#123;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Color</span> DEFAULT_COLOR <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Color</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">230</span>, <span style="color: #cc66cc;">230</span>, <span style="color: #cc66cc;">250</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Highlighter.<span style="color: #006633;">HighlightPainter</span></span> painter<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Object</span> highlight<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> HighlightCurrentLineCaretListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> HighlightCurrentLineCaretListener<span style="color: #009900;">&#40;</span><span style="color: #003399;">Color</span> highlightColor<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #003399;">Color</span> c <span style="color: #339933;">=</span> highlightColor <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">?</span> highlightColor <span style="color: #339933;">:</span> DEFAULT_COLOR<span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">painter</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> LineHighlightPainter<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> caretUpdate<span style="color: #009900;">&#40;</span><span style="color: #003399;">CaretEvent</span> evt<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">JTextComponent</span> comp <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">JTextComponent</span><span style="color: #009900;">&#41;</span> evt.<span style="color: #006633;">getSource</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>comp <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">highlight</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            comp.<span style="color: #006633;">getHighlighter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">removeHighlight</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">highlight</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">highlight</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000066; font-weight: bold;">int</span> pos <span style="color: #339933;">=</span> comp.<span style="color: #006633;">getCaretPosition</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Element</span> elem <span style="color: #339933;">=</span> <span style="color: #003399;">Utilities</span>.<span style="color: #006633;">getParagraphElement</span><span style="color: #009900;">&#40;</span>comp, pos<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> start <span style="color: #339933;">=</span> elem.<span style="color: #006633;">getStartOffset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> end <span style="color: #339933;">=</span> elem.<span style="color: #006633;">getEndOffset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">highlight</span> <span style="color: #339933;">=</span> comp.<span style="color: #006633;">getHighlighter</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">addHighlight</span><span style="color: #009900;">&#40;</span>start,
                                                                end,
                                                                <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">painter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            comp.<span style="color: #006633;">repaint</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">BadLocationException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            ex.<span style="color: #006633;">printStackTrace</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #008000; font-style: italic; font-weight: bold;">/**
     * Simple highlight painter that fills a highlighted area with
     * a solid color.
     */</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> LineHighlightPainter <span style="color: #000000; font-weight: bold;">extends</span>
        <span style="color: #003399;">LayeredHighlighter.<span style="color: #006633;">LayerPainter</span></span> <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Color</span> color<span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
         * Constructs a new highlight painter. If &lt;code&gt;c&lt;/code&gt; is null,
         * the JTextComponent will be queried for its selection color.
         *
         * @param c
         *            the color for the highlight
         */</span>
        <span style="color: #000000; font-weight: bold;">public</span> LineHighlightPainter<span style="color: #009900;">&#40;</span><span style="color: #003399;">Color</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">color</span> <span style="color: #339933;">=</span> c<span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
         * Returns the color of the highlight.
         *
         * @return the color
         */</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Color</span> getColor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">color</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// --- HighlightPainter methods ---------------------------------------</span>
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
         * Paints a highlight.
         *
         * @param g
         *            the graphics context
         * @param offs0
         *            the starting model offset &amp;gt;= 0
         * @param offs1
         *            the ending model offset &amp;gt;= offs1
         * @param bounds
         *            the bounding box for the highlight
         * @param c
         *            the editor
         */</span>
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> paint<span style="color: #009900;">&#40;</span><span style="color: #003399;">Graphics</span> g, <span style="color: #000066; font-weight: bold;">int</span> offs0, <span style="color: #000066; font-weight: bold;">int</span> offs1, <span style="color: #003399;">Shape</span> bounds,
                          <span style="color: #003399;">JTextComponent</span> c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Rectangle</span> alloc <span style="color: #339933;">=</span> bounds.<span style="color: #006633;">getBounds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// --- determine locations ---</span>
                <span style="color: #003399;">TextUI</span> mapper <span style="color: #339933;">=</span> c.<span style="color: #006633;">getUI</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Rectangle</span> p0 <span style="color: #339933;">=</span> mapper.<span style="color: #006633;">modelToView</span><span style="color: #009900;">&#40;</span>c, offs0<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Rectangle</span> p1 <span style="color: #339933;">=</span> mapper.<span style="color: #006633;">modelToView</span><span style="color: #009900;">&#40;</span>c, offs1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">// --- render ---</span>
                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>getColor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    g.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span>c.<span style="color: #006633;">getSelectionColor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                    g.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span>getColor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
                <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">Rectangle</span> r <span style="color: #339933;">=</span> p0.<span style="color: #006633;">union</span><span style="color: #009900;">&#40;</span>p1<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                g.<span style="color: #006633;">fillRect</span><span style="color: #009900;">&#40;</span>r.<span style="color: #006633;">x</span>, r.<span style="color: #006633;">y</span>, r.<span style="color: #006633;">width</span>, r.<span style="color: #006633;">height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">BadLocationException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// can't render</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// --- LayerPainter methods ----------------------------</span>
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
         * Paints a portion of a highlight.
         *
         * @param g
         *            the graphics context
         * @param offs0
         *            the starting model offset &amp;gt;= 0
         * @param offs1
         *            the ending model offset &amp;gt;= offs1
         * @param bounds
         *            the bounding box of the view, which is not
         *            necessarily the region to paint.
         * @param c
         *            the editor
         * @param view
         *            View painting for
         * @return region drawing occured in
         */</span>
        @Override
        <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Shape</span> paintLayer<span style="color: #009900;">&#40;</span><span style="color: #003399;">Graphics</span> g, <span style="color: #000066; font-weight: bold;">int</span> offs0, <span style="color: #000066; font-weight: bold;">int</span> offs1, <span style="color: #003399;">Shape</span> bounds,
                                <span style="color: #003399;">JTextComponent</span> c, <span style="color: #003399;">View</span> view<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
            <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>getColor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                g.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span>c.<span style="color: #006633;">getSelectionColor</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                g.<span style="color: #006633;">setColor</span><span style="color: #009900;">&#40;</span>getColor<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #666666; font-style: italic;">// Should only render part of View.</span>
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// --- determine locations ---</span>
                <span style="color: #003399;">Shape</span> shape <span style="color: #339933;">=</span> view.<span style="color: #006633;">modelToView</span><span style="color: #009900;">&#40;</span>
                                               offs0,
                                               <span style="color: #003399;">Position.<span style="color: #006633;">Bias</span></span>.<span style="color: #006633;">Forward</span>,
                                               offs1,
                                               <span style="color: #003399;">Position.<span style="color: #006633;">Bias</span></span>.<span style="color: #006633;">Backward</span>,
                                               bounds<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">Rectangle</span> r <span style="color: #339933;">=</span> shape <span style="color: #000000; font-weight: bold;">instanceof</span> <span style="color: #003399;">Rectangle</span> <span style="color: #339933;">?</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Rectangle</span><span style="color: #009900;">&#41;</span> shape
                        <span style="color: #339933;">:</span> shape.<span style="color: #006633;">getBounds</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                g.<span style="color: #006633;">fillRect</span><span style="color: #009900;">&#40;</span>r.<span style="color: #006633;">x</span>, r.<span style="color: #006633;">y</span>, c.<span style="color: #006633;">getWidth</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, r.<span style="color: #006633;">height</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">return</span> r<span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">BadLocationException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// can't render</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Diesen CaretListener muss man nun mit:</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">textComp.<span style="color: #006633;">addCaretListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> HighlightCurrentLineCaretListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>der Textkomponente hinzufügen. Hat bei mir ausgezeichnet funktioniert. Ich habe diesen Code unter Mac OS X und Windows getestet und er läuft abwärts bis Java 5.<!--:--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jug-bb.de/2009/02/jeditorpane-mit-zeilenhervorhebung/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installation von PostGreSQL auf dem Mac</title>
		<link>http://www.jug-bb.de/2007/10/installation-vpn-postgresql-auf-dem-mac/</link>
		<comments>http://www.jug-bb.de/2007/10/installation-vpn-postgresql-auf-dem-mac/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 10:14:52 +0000</pubDate>
		<dc:creator>Jan Lolling</dc:creator>
				<category><![CDATA[Mac Fan Club]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.java-berlin.de/2007/10-08/installation-vpn-postgresql-auf-dem-mac/</guid>
		<description><![CDATA[1. holen der Sourcen von PostGreSQL Hier bitte das tar-Archiv holen welches mit gz verpackt ist. Mit dem Stand heute ist die Version 8.2.5 aktuell. 2. auspacken Ich installiere Tools und Datenbanken für Entwicklungszwecke immer unter /Developer. Also das empfangene Archiv nach Developer verschieben. Das Auspacken erfolgt dann mit (dazu muss man noch kein root [...]]]></description>
			<content:encoded><![CDATA[<p><!--:de-->1. holen der <a href="http://http://ftp.de.postgresql.org/mirror/postgresql/source/">Sourcen von PostGreSQL</a></p>
<p>Hier bitte das tar-Archiv holen welches mit gz verpackt ist. Mit dem Stand heute ist die Version 8.2.5 aktuell.</p>
<p>2. auspacken</p>
<p>Ich installiere Tools und Datenbanken für Entwicklungszwecke immer unter /Developer. Also das empfangene Archiv nach Developer verschieben. Das Auspacken erfolgt dann mit (dazu muss man noch kein root sein):</p>
<pre>tar xzvf postgresql-8.2.5.tar.gz</pre>
<p>3.Kompilieren und bauen</p>
<pre>cd postgresql-8.2.5</pre>
<pre>./configure</pre>
<pre>make</pre>
<p>nun eine bash als root starten</p>
<pre>sudo bash</pre>
<pre>make install</pre>
<p>Wo findet man dann PostGreSQL ?</p>
<p>unter /usr/local/pgsql ist die Datenbank installiert<!--:--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jug-bb.de/2007/10/installation-vpn-postgresql-auf-dem-mac/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DMG erstellen mit ant</title>
		<link>http://www.jug-bb.de/2007/09/dmg-erstellen-mit-ant/</link>
		<comments>http://www.jug-bb.de/2007/09/dmg-erstellen-mit-ant/#comments</comments>
		<pubDate>Tue, 18 Sep 2007 23:03:46 +0000</pubDate>
		<dc:creator>Jan Lolling</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Mac Fan Club]]></category>
		<category><![CDATA[Berlin]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.java-berlin.de/2007/09-19/dmg-erstellen-mit-ant/</guid>
		<description><![CDATA[In einem der vorhergehenden Beiträge habe ich gezeigt wie eine Java Mac app erstellt wird. Typischerweise werden Mac-Anwendungen in Form eines Diskimages (DMG) verteilt. DMGs sind virtuelle Laufwerke mit Kompression, die aus einer Datei bestehen und vom Finder automatisch gemountet werden können. Folgender ant-Task löst die Aufgabe unter Zuhilfenahme des command-line utils von Mac OS [...]]]></description>
			<content:encoded><![CDATA[<p><!--:de-->In einem der <a href="http://www.jug-bb.de/2007/08-22/java-anwendung-erstellen-fur-mac-os-x/">vorhergehenden Beiträge</a> habe ich gezeigt wie eine Java Mac app erstellt wird. Typischerweise werden Mac-Anwendungen in Form eines Diskimages (DMG) verteilt. DMGs sind virtuelle Laufwerke mit Kompression, die aus einer Datei bestehen und vom Finder automatisch gemountet werden können.</p>
<p>Folgender ant-Task löst die Aufgabe unter Zuhilfenahme des command-line utils von Mac OS X:</p>
<pre>
	<target name="dmg" depends="macapp">
		<delete failonerror="false">
			<fileset dir="${distrib}">
				<include name="*.dmg" />
			</fileset>
		</delete>
		<exec executable="hdiutil">
			<arg line="create -srcfolder ${macappdir} ${distrib}/sqlrunner-${version}.dmg" />
		</exec>
	</target>
</pre>
<p>In macappdir liegt das zuvor (mit dem ant task macapp) erstellte Verzeichnis SQLRunner.app und distrib verweist auf eine Verzeichnis in dem ich alle Endprodukte ablege. Wichtig ist das distrib nicht innerhalb von macappdir liegt.<br />
Man sollte noch beachten, dass das Diskimage als Laufwerksname den Namen des Verzeichnisses von macappdir bekommt.<br />
Klappt alles vorzüglich und schnell.<!--:--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jug-bb.de/2007/09/dmg-erstellen-mit-ant/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java-Anwendung erstellen für Mac OS X</title>
		<link>http://www.jug-bb.de/2007/08/java-anwendung-erstellen-fur-mac-os-x/</link>
		<comments>http://www.jug-bb.de/2007/08/java-anwendung-erstellen-fur-mac-os-x/#comments</comments>
		<pubDate>Wed, 22 Aug 2007 20:05:32 +0000</pubDate>
		<dc:creator>Jan Lolling</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Java Code Beispiele]]></category>
		<category><![CDATA[Berlin]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.java-berlin.de/2007/08-22/java-anwendung-erstellen-fur-mac-os-x/</guid>
		<description><![CDATA[Wer eine Mac hat will natürlich seine Java-Anwendung auch mal echt im Dock sehen oder eine sinnvolle Dateiverknüpfung nutzen usw. Das alles ist sehr einfach machbar. Also was habe ich hier nun vor: Ich werde euch an hand einer realen Anwendung zeigen wie man die Apple-Application-Events auswertet und wie man eine echte Mac-Anwendung zusammenbaut mit [...]]]></description>
			<content:encoded><![CDATA[<p><!--:de-->Wer eine Mac hat will natürlich seine Java-Anwendung auch mal echt im Dock sehen oder eine sinnvolle Dateiverknüpfung nutzen usw.<br />
Das alles ist sehr einfach machbar.<br />
Also was habe ich hier nun vor:<br />
Ich werde euch an hand einer realen Anwendung zeigen wie man die Apple-Application-Events auswertet und wie man eine echte Mac-Anwendung zusammenbaut mit ant.<br />
Meine Anwendung ist ein SQL-Client der speziell für die Entwicklung von Java-Anwendungen in Verbindung mit SQL entwicklelt wurde und darüberhinaus sehr viel Komfort bei der Handhabung der Datenbank und deren Daten mit sich bringt. Ich habe diese SQLRunner genannt und sie ist in meiner Firma mittlerweile sehr verbreitet via Java web Start.</p>
<p>Hier soll es aber nicht um Java Web Start gehen. JWS ist wirklich gut dokumentiert, dass muss ich hier nicht nachholen.</p>
<p>1. Wie kommuniziert Mac OS X mit einer Java Anwendung:<br />
Mac OS sendet an die Anwendung Events:<br />
a) zum Öffnen einer Datei<br />
b) zum Öffnen des &#8220;Einstellungen&#8230;&#8221; Dialoges<br />
c) zum Drucken einer Datei<br />
d) zum Öffnen des About-Dialoges<br />
e) zum Schliessen der Anwendung<br />
Klingt erstmal etwas merkwürdig &#8211; jedenfalls für mich.<br />
Wenn man sich Mac OS X Anwendungen ansieht so fällt auf, dass das Menü, egal was man selbst programmiert hat um einen ganz links stehenden Menüpunkt erweitert wurde der nach der Anwendung benannt ist und typischerweise aus immer den gleichen Einträgen besteht: &#8220;About&#8221;, &#8220;Preferences&#8230;&#8221;, Services (hat keinen Bezug zur Anwendung), &#8220;Exit &#8221;</p>
<p>Apple stellt in seiner Java-Implementierung nun eine API zur Verfügung die einem diese Kommunikation bereitstellt. Die dafür notwendigen Klassen sind in:</p>
<pre>/System/Library/Frameworks/JavaVM.framework/Classes/ui.jar</pre>
<p>Man sollte aber darauf achten welche JRE-Version in der Anwendung unterstützt werden soll und sich besser die Datei aus der passenden version holen.<br />
Das folgende Codesnippet zeigt die Registrierung des notwendigen EventListeners:<br />
Ein paar Vorbemerkungen:<br />
Bei mir hat der Code zum Öffnen einer Datei anfangs nicht funktioniert. Meine Anwendung wurde zwar gestartet aber es kam kein Event zum Öffnen der Datei. Das Problem lag schlicht daran, dass die nachfolgend beschriebene Registrierung zu einem Zeitpunkt erfolgte an dem Mac OS den Event bereits vorher gesendet hat. Meine Applikation hatte schlicht zu spät zugehört. Deshalb unbedingt die Registrierung soweit wie möglich nach vorn verlegen.<br />
Dann hatte ich aber das Problem, dass es zu diesem Zeitpunkt noch kein Fenster oder Editor gab der sich für die übergebenen Inhalte interessiert hätte. Das muss man so lösen, dass man z.B. den Dateinamen erstmal merkt und beim Initialisierungsprozess des Fensters nachfragt ob solche Informationen vorliegen und die dann auch gleich berücksichtigt. Der SQLRunner z.B. initialisiert sich recht langwierig, da diverse Konfigurationen eingelesen werden müssen und dieser Vorgang wird in der boolean initalizationFinished mit true dokumentiert.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    commandLineArguments <span style="color: #339933;">=</span> args<span style="color: #339933;">;</span>
    <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">put</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;apple.laf.useScreenMenuBar&quot;</span>, <span style="color: #0000ff;">&quot;true&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// damit Menüs oben in der Leiste landen !</span>
    BasicConfigurator.<span style="color: #006633;">configure</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// log4j minimal konfigurieren, wird später verbessert</span>
    logger.<span style="color: #006633;">info</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SQLRunner Application Version &quot;</span> <span style="color: #339933;">+</span> VERSION<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// unbedingt soweit zum Beginn als möglich den Listener registerieren !!</span>
    <span style="color: #003399;">String</span> osname <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;os.name&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #666666; font-style: italic;">// laufen wir gerade auf Mac OS X ?</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>osname <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> osname.<span style="color: #006633;">toLowerCase</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;mac&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #666666; font-style: italic;">// diese Methode zeitlich so nah wie möglich zum Start der Anwendung ausführen !!</span>
        setupMacOSXApplicationListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// registrieren des Listeners</span>
    <span style="color: #009900;">&#125;</span>
... <span style="color: #006633;">die</span> Anwendung weiter initialisieren, z.<span style="color: #006633;">B</span>. <span style="color: #006633;">Konfigdateien</span> lesen und GUI erstellen usw.
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> setupMacOSXApplicationListener<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>logger.<span style="color: #006633;">isDebugEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            logger.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;setupMacOSXApplicationListener()&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">final</span> com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">Application</span> application <span style="color: #339933;">=</span> com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">Application</span>.<span style="color: #006633;">getApplication</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            application.<span style="color: #006633;">setEnabledAboutMenu</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// damit ein &quot;Über &quot; Menü erscheint</span>
            application.<span style="color: #006633;">addPreferencesMenuItem</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// &quot;Einstellen...&quot; Dialog</span>
            application.<span style="color: #006633;">setEnabledPreferencesMenu</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// diesen Dialog auch freischalten</span>
            application.<span style="color: #006633;">addApplicationListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">ApplicationListener</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// jemand hat auf Über... geklickt</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handleAbout<span style="color: #009900;">&#40;</span>com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">ApplicationEvent</span> ae<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>initializationFinished<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// nur was tun wenn Anwendung bereit ist</span>
<span style="color: #666666; font-style: italic;">// .... hier den eigenen Info-Dialog zeigen oder was auch immer !</span>
                        ae.<span style="color: #006633;">setHandled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// habe fertig...</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">// kommt z.B. wenn eine Datei aus dem Kontextmenü heraus geöffnet wird</span>
                <span style="color: #666666; font-style: italic;">// Mac OS startet ganz normal die Anwendung und versendet diesen Event</span>
                <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handleOpenApplication<span style="color: #009900;">&#40;</span>com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">ApplicationEvent</span> ae<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ae.<span style="color: #006633;">getFilename</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>initializationFinished<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #666666; font-style: italic;">// die Anwendung ist bereit und alles initialisiert</span>
                            <span style="color: #666666; font-style: italic;">// ... alles notwendige tun um eine Datei zu laden</span>
                        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                            <span style="color: #666666; font-style: italic;">// die Anwendung fährt gerade hoch</span>
                            <span style="color: #666666; font-style: italic;">// noch kein Fenster da.</span>
                            <span style="color: #666666; font-style: italic;">// ich merke mir die zu ladene Datei und muss später das laden nachholen</span>
                            fileToLoad <span style="color: #339933;">=</span> ae.<span style="color: #006633;">getFilename</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// fileToLoad ist eine static String variable</span>
                        <span style="color: #009900;">&#125;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handlePreferences<span style="color: #009900;">&#40;</span>com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">ApplicationEvent</span> ae<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>initalizationFinished<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">// ... zeige meinen eigenen Einstellen-Dialog</span>
                        ae.<span style="color: #006633;">setHandled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// habe fertig</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handlePrintFile<span style="color: #009900;">&#40;</span>com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">ApplicationEvent</span> ae<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #666666; font-style: italic;">// meine Anwendung kann nicht drucken und will es auch nicht</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handleQuit<span style="color: #009900;">&#40;</span>com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">ApplicationEvent</span> ae<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #666666; font-style: italic;">// ... Die Anwendung geordnet beenden</span>
                    <span style="color: #666666; font-style: italic;">// Fragen nach ggf notwendigen Speichern, Streams schliessen usw.</span>
                    ae.<span style="color: #006633;">setHandled</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// bin mir nicht ganz sicher ob ich hier noch hinkomme ;-)</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">// meine Anwendung läuft bereits und jemand klickt unten auf mein Dock-Icon</span>
                <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handleReOpenApplication<span style="color: #009900;">&#40;</span>com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">ApplicationEvent</span> ae<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #666666; font-style: italic;">// ich würde hier ein weiteres Fenster aufmachen ...</span>
                <span style="color: #009900;">&#125;</span>
&nbsp;
                <span style="color: #666666; font-style: italic;">// kommt z.B. wenn eine Datei aus dem Kontextmenü heraus geöffnet wird</span>
                <span style="color: #666666; font-style: italic;">// Die Anwwendung ist aber schon vorher gestartet worden</span>
                <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> handleOpenFile<span style="color: #009900;">&#40;</span>com.<span style="color: #006633;">apple</span>.<span style="color: #006633;">eawt</span>.<span style="color: #006633;">ApplicationEvent</span> ae<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>initializationFinished<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// sicher ist sicher</span>
                        <span style="color: #666666; font-style: italic;">// Datei öffnen</span>
                    <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                        <span style="color: #666666; font-style: italic;">// Datei merken und ggf später öffnen</span>
                        fileToLoad <span style="color: #339933;">=</span> ae.<span style="color: #006633;">getFilename</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    <span style="color: #009900;">&#125;</span>
                <span style="color: #009900;">&#125;</span>
            <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Throwable</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            logger.<span style="color: #006633;">warn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;setupMacOSXApplicationListener failed: &quot;</span> <span style="color: #339933;">+</span> e.<span style="color: #006633;">getMessage</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Soweit nun fast alles was man braucht um den eigenen Code zu erweitern</p>
<p>Wir brauchen nun ein schickes Icon für unsere Anwendung.<br />
Dazu malt man sich in der Grösse 128&#215;128 Bit mit 256 Bit Farbtiefe ein hübsche Bildchen im PNG oder JPG-Format.<br />
Dieses Bild muss nun ind das sogenannte Icon-Format überführt werden. bei Mac OS X heissen diese Dateien .icns.<br />
Der angedeutete Plural ist nicht ohne Grund. In der Datei stecken mehrere Bilder mit gleichem Inhalt aber unterschiedlicher Auflösung und Bildgrösse um die Skalierung zu ermöglichen wenn im Doc das Bild grösser wird oder wenn im Finder grössere Icons eingestellt werden. Damit Mac OS X da was zum interpolieren hat sind mehrere unterschiedliche Grössen in einer Datei enthalten.<br />
Ein nettes (billiges aber kostenpflichtiges) Photoshop-Plugin <a href="http://www.kineticcreations.com/exporticon/">Icon Export</a> hilft hier weiter. Mit Photoshop kann man simpel ein nettes Bild bastel und es dann sogleich mit diesem Plugin in das icns-Format exportieren. Das Plugin funktioniert auch bei dem sehr preiswerten Photoshop Elements (momentan version 4.0) was jeder zweiten Digitalkamera kostenlos beiliegt oder im Laden 90 Euro kostet. Ich hatte es mir gekauft und es nie bereut !</p>
<p>Nun sind alle Zutaten zusammen: Wir haben eine nette Anwendung und auch ein hübsches Icon.</p>
<p>Nun müssen wir noch eine echte Mac-App bauen.<br />
Ich bevorzuge dazu <a href="http://ant.apache.org">ant</a>. Aktuell ist gerade die Version 1.7.0 &#8211; kann ich nur dringend empfehlen !</p>
<p>Hier ein Teil meines ant-scripts.<br />
Ich kenne nur einen wirklich sinnvollen Weg: der <a href="http://informagen.com/JarBundler/">jarbundler</a>. Das Teil ist sehr gut dokumentiert !</p>
<p>Hier ein Beispiel für ein ant-task:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;macapp&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">&quot;jar&quot;</span></span>
<span style="color: #009900;">        <span style="color: #000066;">description</span>=<span style="color: #ff0000;">&quot;build Mac OS X application bundle&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete</span> <span style="color: #000066;">failonerror</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">includeemptydirs</span>=<span style="color: #ff0000;">&quot;true&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${macappdir}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${macappdir}&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;taskdef</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;jarbundler&quot;</span></span>
<span style="color: #009900;">             <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">&quot;net.sourceforge.jarbundler.JarBundler&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jarbundler</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${macappdir}&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SQLRunner&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">shortname</span>=<span style="color: #ff0000;">&quot;SQLRunner&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">infostring</span>=<span style="color: #ff0000;">&quot;Version ${version} Copyright Jan Lolling&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">icon</span>=<span style="color: #ff0000;">&quot;${src}/sqlrunner.icns&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;${version}&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">mainclass</span>=<span style="color: #ff0000;">&quot;sqlrunner.Main&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">jvmversion</span>=<span style="color: #ff0000;">&quot;1.5+&quot;</span></span>
<span style="color: #009900;">                <span style="color: #000066;">vmoptions</span>=<span style="color: #ff0000;">&quot;-Xmx512m -Dcom.sun.management.jmxremote=true -Dapple.awt.graphics.UseQuartz=true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jarfileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${lib}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;*.jar&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jarfileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;jarfileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${distrib}&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sqlrunner2.jar&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jarfileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;documenttype</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SQL script&quot;</span> <span style="color: #000066;">extensions</span>=<span style="color: #ff0000;">&quot;sql&quot;</span> <span style="color: #000066;">role</span>=<span style="color: #ff0000;">&quot;Editor&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;documenttype</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SQLRunner CSV Import Configuration&quot;</span> <span style="color: #000066;">extensions</span>=<span style="color: #ff0000;">&quot;importconfig&quot;</span> <span style="color: #000066;">role</span>=<span style="color: #ff0000;">&quot;Editor&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/jarbundler<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${macappdir}/SQLRunner.app/Contents/Resources/German.lproj&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mkdir</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;${macappdir}/SQLRunner.app/Contents/Resources/English.lproj&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;delete</span> <span style="color: #000066;">file</span>=<span style="color: #ff0000;">&quot;${macappdir}/SQLRunner.app/Contents/MacOS/JavaApplicationStub&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>copy JavaApplicationStub<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/echo<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;exec</span> <span style="color: #000066;">executable</span>=<span style="color: #ff0000;">&quot;cp&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">line</span>=<span style="color: #ff0000;">&quot;/System/Library/Frameworks/JavaVM.framework/Resources/MacOS/JavaApplicationStub&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;arg</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;${macappdir}/SQLRunner.app/Contents/MacOS/JavaApplicationStub&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/exec<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Java-Anwendungen werden wenn sie wie normale Mac Anwendungen gestartet werden sollen mit einem JavaStub gestartet. Dieser kann direkt in das eigene Projekt kopiert werden oder er wird verlinkt (wie im Beispiel). das direkte Kopieren hat den Nachteil das man damit die JRE-version festlegt ist aber krisenfest wenn Apple mal die Verzeichnis-Struktur von Java ändern sollte. Der symbolische Link hat den Vorteil, dass man immer mit der aktuellsten Version arbeitet und den Nachteil dass Verzeichnisänderungen der JRE ein echtes Problem darstellen würden. Seite der ersten Version von Mac OS X ist dieser Pfad aber stabil geblieben, weshalb ich das skizzierte Risiko als gering einschätze.</p>
<p>Viel Freude mit Java auf dem Mac wünscht Jan<!--:--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jug-bb.de/2007/08/java-anwendung-erstellen-fur-mac-os-x/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle SQL Developer</title>
		<link>http://www.jug-bb.de/2006/04/oracle-sql-developer/</link>
		<comments>http://www.jug-bb.de/2006/04/oracle-sql-developer/#comments</comments>
		<pubDate>Mon, 10 Apr 2006 10:09:43 +0000</pubDate>
		<dc:creator>Ralph Bergmann</dc:creator>
				<category><![CDATA[Allgemein]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.java-berlin.de/?p=21</guid>
		<description><![CDATA[Oracle bietet für die Betriebsystems MacOS X, Windows XP und Linux das freie Entwicklungswerkzeug SQL Developer an. Mit dem Java-basierten Werkzeug kann die komplette Struktur einer Oracle Datenbank ab Version 9.2 analysiert werden. Weiterhin kann man PL/SQL Skripte direkt entwickeln und ausführen lassen. Mehr: http://www.oracle.com/technology/products/database/sql_developer/index.html]]></description>
			<content:encoded><![CDATA[<p><!--:de--><img id="image20" height="48" alt="raptor_image.jpg" src="http://blog.jug-bb.de/wp-content/uploads/2006/04/raptor_image.jpg" width="48" />Oracle bietet für die Betriebsystems MacOS X, Windows XP und Linux das freie Entwicklungswerkzeug SQL Developer an. Mit dem Java-basierten Werkzeug kann die komplette Struktur einer Oracle Datenbank ab Version 9.2 analysiert werden. Weiterhin kann man PL/SQL Skripte direkt entwickeln und ausführen lassen. Mehr: <a href="http://www.oracle.com/technology/products/database/sql_developer/index.html">http://www.oracle.com/technology/products/database/sql_developer/index.html</a><!--:--></p>
]]></content:encoded>
			<wfw:commentRss>http://www.jug-bb.de/2006/04/oracle-sql-developer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

