Posted by Walter Laan on Wed 12 Nov 16:17
report abuse | download | new post
- package test;
- import java.awt.*;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import java.util.*;
- import java.util.List;
- import javax.imageio.ImageIO;
- import javax.swing.*;
- import javax.swing.border.Border;
- import javax.swing.table.TableCellRenderer;
- JFrame frame;
- JTabbedPane tabbedPane;
- SampleRenderer sampleRenderer;
- super(title);
- frame = this;
- sampleRenderer = new SampleRenderer();
- tabbedPane = getTabbedPane();
- getContentPane().add(tabbedPane);
- }
- Map<String, Map<String, Object>> components = new HashMap<String, Map<String, Object>>();
- // Build of Map of attributes for each component
- for (Enumeration<Object> anEnum = defaults.keys(); anEnum.hasMoreElements();) {
- Map<String, Object> componentMap = getComponentMap(components, key);
- if (componentMap != null) {
- componentMap.put(key, value);
- }
- }
- addComponentTabs(pane, components);
- return pane;
- }
- private Map<String, Object> getComponentMap(Map<String, Map<String, Object>> components, String key) {
- if (key.startsWith("class") || key.startsWith("javax")) {
- return null;
- }
- // Component name is found before the first "."
- String componentName;
- int pos = key.indexOf(".");
- if (pos == -1) {
- if (key.endsWith("UI")) {
- componentName = key.substring(0, key.length() - 2);
- }
- else {
- componentName = "System Colors";
- }
- }
- else {
- componentName = key.substring(0, pos);
- }
- // Fix inconsistency
- if (componentName.equals("Checkbox")) {
- componentName = "CheckBox";
- }
- // Get the Map for this particular component
- Map<String, Object> componentMap = components.get(componentName);
- if (componentMap == null) {
- componentMap = new HashMap<String, Object>();
- components.put(componentName, componentMap);
- }
- return componentMap;
- }
- List<String> c = new ArrayList<String>(components.keySet());
- for (Iterator<String> ci = c.iterator(); ci.hasNext();) {
- Map<String, Object> attributes = components.get(component);
- int i = 0;
- List<String> a = new ArrayList<String>(attributes.keySet());
- for (Iterator<String> ai = a.iterator(); ai.hasNext(); i++)
- {
- rowData[i][0] = attribute;
- if (o != null) {
- rowData[i][1] = o.toString();
- rowData[i][2] = o;
- }
- else {
- rowData[i][1] = "null";
- rowData[i][2] = "";
- }
- }
- table.setCellSelectionEnabled(true);
- table.getColumnModel().getColumn(2).setCellRenderer(sampleRenderer);
- table.getColumnModel().getColumn(0).setPreferredWidth(250);
- table.getColumnModel().getColumn(1).setPreferredWidth(500);
- table.getColumnModel().getColumn(2).setPreferredWidth(50);
- }
- }
- public SampleRenderer() {
- super();
- setOpaque(true); //MUST do this for background to show up.
- }
- boolean hasFocus, int row, int column) {
- setBackground(null);
- setBorder(null);
- setIcon(null);
- setText("");
- }
- }
- setText("Sample");
- }
- }
- return this;
- }
- @Override
- try {
- super.paint(g);
- }
- // do nothing
- }
- }
- }
- try {
- // UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
- // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- e.printStackTrace();
- e.printStackTrace();
- e.printStackTrace();
- e.printStackTrace();
- }
- f.pack();
- f.setLocationRelativeTo(null);
- f.setVisible(true);
- }
- public static void saveOptionPaneIcons() {
- try {
- e.printStackTrace();
- }
- }
- }
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.