001: package test.contrib;
002:
003: import java.awt.*;
004:
005: import javax.swing.*;
006: import javax.swing.table.TableCellRenderer;
007:
008: import org.jdesktop.swingx.JXPanel;
009:
010: /*
011: * InternalFrameDemo.java requires:
012: * MyInternalFrame.java
013: */
014: public class DesktopDemo extends JFrame {
015: public DesktopDemo() {
016: super ("InternalFrameDemo");
017:
018: this .setSize(500, 300);
019: this .setLocationRelativeTo(null);
020:
021: JDesktopPane jdp = new JDesktopPane();
022: this .add(jdp);
023:
024: JInternalFrame jif = new JInternalFrame();
025: jif.setBounds(20, 20, 400, 200);
026: jif.setVisible(true);
027: jdp.add(jif);
028:
029: JXPanel panel = new JXPanel();
030: panel.setAlpha(0.5f);
031: jif.setLayout(new BorderLayout());
032: jif.add(panel, BorderLayout.CENTER);
033:
034: panel.setLayout(new GridLayout(1, 2));
035: String[] columnNames = { "First Name", "Last Name" };
036:
037: Object[][] data = { { "Mary", "Campione" },
038: { "Alison", "Huml" }, { "Kathy", "Walrath" } };
039:
040: JTable table = new JTable(data, columnNames);
041: // table.setBackground(new Color(255, 200, 200));
042: // table.setDefaultRenderer(Object.class, new TableCellRenderer() {
043: // JLabel label = new JLabel();
044: //// {
045: //// @Override
046: //// public boolean isOpaque() {
047: //// return true;
048: //// }
049: //// };
050: //
051: // public Component getTableCellRendererComponent(JTable table,
052: // Object value, boolean isSelected, boolean hasFocus,
053: // int row, int column) {
054: // label.setText(value.toString());
055: // if (isSelected) {
056: // label.setBackground(new Color(200, 200, 255));
057: // } else {
058: // if ((row + column) % 2 == 0)
059: // label.setBackground(new Color(255, 200, 200));
060: // else
061: // label.setBackground(new Color(200, 255, 200));
062: // }
063: // label.setForeground(Color.black);
064: // return label;
065: // }
066: // });
067: panel.add(table);
068: // A simple tree
069: panel.add(new JTree());
070: }
071:
072: /**
073: * Create the GUI and show it. For thread safety, this method should be
074: * invoked from the event-dispatching thread.
075: */
076: private static void createAndShowGUI() {
077: // Make sure we have nice window decorations.
078: // JFrame.setDefaultLookAndFeelDecorated(true);
079: try {
080: UIManager
081: .setLookAndFeel("org.jvnet.substance.SubstanceLookAndFeel");
082: // Create and set up the window.
083: DesktopDemo frame = new DesktopDemo();
084: frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
085:
086: // Display the window.
087: frame.setVisible(true);
088: } catch (Exception e) {
089: e.printStackTrace();
090: }
091: }
092:
093: public static void main(String[] args) {
094: // Schedule a job for the event-dispatching thread:
095: // creating and showing this application's GUI.
096: javax.swing.SwingUtilities.invokeLater(new Runnable() {
097: public void run() {
098: createAndShowGUI();
099: }
100: });
101: }
102: }
|