e.g. Calendar Search Help
You must enter a value before pressing Search
jgoodies_looks

Class: com.jgoodies.looks.demo.DesktopTab   ©

 OK to copy?
001 /*
002  * Copyright (c) 2001-2006 JGoodies Karsten Lentzsch. All Rights Reserved.
003  *
004  * Redistribution and use in source and binary forms, with or without 
005  * modification, are permitted provided that the following conditions are met:
006  * 
007  *  o Redistributions of source code must retain the above copyright notice, 
008  *    this list of conditions and the following disclaimer. 
009  *     
010  *  o Redistributions in binary form must reproduce the above copyright notice, 
011  *    this list of conditions and the following disclaimer in the documentation 
012  *    and/or other materials provided with the distribution. 
013  *     
014  *  o Neither the name of JGoodies Karsten Lentzsch nor the names of 
015  *    its contributors may be used to endorse or promote products derived 
016  *    from this software without specific prior written permission. 
017  *     
018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
019  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 
020  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 
021  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
022  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
023  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 
024  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 
025  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 
026  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 
027  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 
028  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
029  */
030 
031 package com.jgoodies.looks.demo;
032 
033 import java.awt.BorderLayout;
034 import java.awt.Dimension;
035 
036 import javax.swing.*;
037 import javax.swing.border.Border;
038 import javax.swing.border.EmptyBorder;
039 
040 import com.jgoodies.forms.factories.Borders;
041 import com.jgoodies.looks.LookUtils;
042 import com.jgoodies.looks.plastic.PlasticInternalFrameUI;
043 
044 /** 
045  * Demos the <code>JDesktopPane</code>.
046  * 
047  * @author Karsten Lentzsch
048  * @version $Revision: 1.4 $
049  */
050 final class DesktopTab {
051     
052     private static final float SIZE_FACTOR = LookUtils.IS_LOW_RESOLUTION ? 1f : 1.175f;
053 
054     /**
055      * Builds the panel.
056      */
057     JComponent build() {
058         JPanel panel = new JPanel(new BorderLayout());
059         panel.setOpaque(false);
060         panel.setBorder(Borders.DIALOG_BORDER);
061         panel.add(new JScrollPane(buildDesktopPane()));
062         return panel;
063     }
064 
065     private JComponent buildDesktopPane() {
066         int gap      = (int) (10 * SIZE_FACTOR);
067         int originX1 = 10;
068         int extentX1 = (int) (193 * SIZE_FACTOR);
069         int originX2 = originX1 + extentX1 + gap;
070         int extentX2 = extentX1;
071         int originX3 = originX2 + extentX2 + gap;
072         int extentX3 = (int) (150 * SIZE_FACTOR);
073         
074         JDesktopPane desktop = new JDesktopPane();
075         JInternalFrame frame;
076 
077         frame = new JInternalFrame("Navigation", true, true, true, true);
078         frame.setContentPane(buildFrame1ContentPane());
079         frame.setBounds(originX1, 10, extentX1, 320);
080         desktop.add(frame);
081         frame.setVisible(true);
082 
083         frame = new JInternalFrame("Properties", true, false, true, true);
084         frame.setContentPane(buildFrame2ContentPane());
085         frame.setBounds(originX2, 10, extentX2, 320);
086         desktop.add(frame);
087         frame.setVisible(true);
088 
089         JInternalFrame palette =
090             new JInternalFrame("Palette1", true, true, true, true);
091         palette.putClientProperty(
092             PlasticInternalFrameUI.IS_PALETTE,
093             Boolean.TRUE);
094         palette.setContentPane(buildPaletteContentPane());
095         palette.setBounds(originX3, 10, extentX3, 150);
096         palette.setVisible(true);
097         desktop.add(palette, JLayeredPane.PALETTE_LAYER);
098 
099         return desktop;
100     }
101 
102     private JComponent buildFrame1ContentPane() {
103         JScrollPane scrollPane = new JScrollPane(new JTree());
104         scrollPane.setPreferredSize(new Dimension(100, 140));
105         return scrollPane;
106     }
107 
108     private JComponent buildFrame2ContentPane() {
109         JScrollPane scrollPane = new JScrollPane(buildTable());
110         scrollPane.setPreferredSize(new Dimension(100, 140));
111         return scrollPane;
112     }
113 
114     private JComponent buildPaletteContentPane() {
115         JCheckBox check1 = new JCheckBox("be consistent", true);
116         check1.setContentAreaFilled(false);
117         JCheckBox check2 = new JCheckBox("use less ink", true);
118         check2.setContentAreaFilled(false);
119         final Border cardDialogBorder = new EmptyBorder(10, 6, 7, 6);
120         Box box = Box.createVerticalBox();
121         box.add(check1);
122         box.add(Box.createVerticalStrut(6));
123         box.add(check2);
124 
125         JPanel generalTab = new JPanel(new BorderLayout());
126         generalTab.setOpaque(false);
127         generalTab.add(box);
128         generalTab.setBorder(cardDialogBorder);
129 
130         JTabbedPane tabbedPane = new JTabbedPane(SwingConstants.BOTTOM);
131         tabbedPane.add(generalTab, "General");
132         tabbedPane.add(new JLabel("Test1"), "Filter");
133         return tabbedPane;
134     }
135 
136     /**
137      * Builds and answers a sample table.
138      */
139     private JTable buildTable() {
140         JTable table = new JTable(
141                 createSampleTableData(),
142                 new String[] { "Key", "Value" });
143 
144         //table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
145         table.getColumnModel().getColumn(0).setPreferredWidth(95);
146         table.getColumnModel().getColumn(1).setPreferredWidth(95);
Rate147         table.setRowSelectionInterval(2, 2);
148         return table;
149     }
150 
151     /**
152      * Creates and answers sample table data.
153      */
154     private String[][] createSampleTableData() {
155         return new String[][] { 
156             {"Name",           "Karsten"    }, 
157             {"Sex",            "Male"       }, 
158             {"Date of Birth",  "5-Dec-1967" }, 
159             {"Place of Birth", "Kiel"       }, 
160             {"Profession",     "UI Designer"}, 
161             {"Business",       "Freelancer" },
162             {"",               ""           },
163             {"",               ""           },
164             {"",               ""           },
165             {"",               ""           },
166             {"",               ""           },
167             {"",               ""           },
168             {"",               ""           },
169             {"",               ""           },
170             {"",               ""           },
171             {"",               ""           },
172             {"",               ""           },
173             {"",               ""           },
174             {"",               ""           },
175         };
176     }
177 
178 }

            
All Examples in File:
Example
Line
Rating (found
useful by...)
147 67% of 3