summaryrefslogtreecommitdiff
path: root/javax/swing/plaf
diff options
context:
space:
mode:
authorRonald Veldema <rveldema@cs.vu.nl>2002-03-11 15:48:06 +0000
committerRonald Veldema <rveldema@cs.vu.nl>2002-03-11 15:48:06 +0000
commit5158e5cd020ca88753de8793a40dcda66f3ea8ae (patch)
treee8ff44926abd1e1fd9f058139dc1476c54d24f9c /javax/swing/plaf
parenteed4707c499f072d7e36d8499638b859a370fc57 (diff)
downloadclasspath-5158e5cd020ca88753de8793a40dcda66f3ea8ae.tar.gz
Added my embryonic javax.swing implementation,
since there are no makefiles for it yet nobody should notice its addition (it shouldn't break anything by adding it this early) R.
Diffstat (limited to 'javax/swing/plaf')
-rw-r--r--javax/swing/plaf/ButtonUI.java5
-rw-r--r--javax/swing/plaf/ComponentUI.java86
-rw-r--r--javax/swing/plaf/LabelUI.java6
-rw-r--r--javax/swing/plaf/ListUI.java6
-rw-r--r--javax/swing/plaf/OptionPaneUI.java5
-rw-r--r--javax/swing/plaf/PanelUI.java6
-rw-r--r--javax/swing/plaf/ScrollPaneUI.java6
-rw-r--r--javax/swing/plaf/TabbedPaneUI.java23
-rw-r--r--javax/swing/plaf/TextUI.java26
-rw-r--r--javax/swing/plaf/TreeUI.java6
-rw-r--r--javax/swing/plaf/ViewportUI.java6
-rw-r--r--javax/swing/plaf/basic/BasicButtonUI.java176
-rw-r--r--javax/swing/plaf/basic/BasicCheckBoxUI.java87
-rw-r--r--javax/swing/plaf/basic/BasicDefaults.java81
-rw-r--r--javax/swing/plaf/basic/BasicGraphicsUtils.java77
-rw-r--r--javax/swing/plaf/basic/BasicLabelUI.java158
-rw-r--r--javax/swing/plaf/basic/BasicListUI.java132
-rw-r--r--javax/swing/plaf/basic/BasicOptionPaneUI.java103
-rw-r--r--javax/swing/plaf/basic/BasicPanelUI.java21
-rw-r--r--javax/swing/plaf/basic/BasicRadioButtonUI.java126
-rw-r--r--javax/swing/plaf/basic/BasicScrollPaneUI.java66
-rw-r--r--javax/swing/plaf/basic/BasicTabbedPaneUI.java64
-rw-r--r--javax/swing/plaf/basic/BasicTextUI.java126
-rw-r--r--javax/swing/plaf/basic/BasicToggleButtonUI.java89
-rw-r--r--javax/swing/plaf/basic/BasicTreeUI.java7
-rw-r--r--javax/swing/plaf/basic/BasicViewportUI.java33
-rw-r--r--javax/swing/plaf/metal/MetalLookAndFeel.java31
27 files changed, 1558 insertions, 0 deletions
diff --git a/javax/swing/plaf/ButtonUI.java b/javax/swing/plaf/ButtonUI.java
new file mode 100644
index 000000000..74fd19244
--- /dev/null
+++ b/javax/swing/plaf/ButtonUI.java
@@ -0,0 +1,5 @@
+package javax.swing.plaf;
+
+public class ButtonUI extends ComponentUI
+{
+}
diff --git a/javax/swing/plaf/ComponentUI.java b/javax/swing/plaf/ComponentUI.java
new file mode 100644
index 000000000..28684c168
--- /dev/null
+++ b/javax/swing/plaf/ComponentUI.java
@@ -0,0 +1,86 @@
+package javax.swing.plaf;
+
+import java.awt.*;
+import javax.swing.border.*;
+import javax.swing.*;
+
+
+public abstract class ComponentUI
+{
+ boolean contains(JComponent c, int x, int y)
+ {
+ return c.inside(x,y);
+ }
+
+ // this SHOULD thow an error:
+ static ComponentUI createUI(JComponent c)
+ {
+ Exception e = new Exception("createUI from ComponentUI should never be called");
+ e.printStackTrace();
+ System.exit(1);
+ return null;
+ }
+
+ Accessible getAccessibleChild(JComponent c, int i)
+ {
+ //Return the nth Accessible child of the object.
+ return null;
+ }
+
+ int getAccessibleChildrenCount(JComponent c)
+ {
+ //Returns the number of accessible children in the object.
+ return 0;
+ }
+
+ Dimension getMaximumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ Dimension getMinimumSize(JComponent c)
+ {
+ return getPreferredSize(c);
+ }
+
+ Dimension getPreferredSize(JComponent c)
+ {
+ return null;
+ }
+
+ void installUI(JComponent c)
+ {
+ String id = c.getUIClassID() + ".border";
+
+ Border s = UIManager.getBorder( id );
+
+ if (s != null)
+ {
+ c.setBorder( s );
+ //System.out.println("OK-INSTALL: " + this + ", ID=" + id + ",B="+s);
+ }
+ else
+ {
+ ///System.out.println("FAIL-INSTALL: " + this + ", " + id);
+ }
+ }
+
+ void paint(Graphics g, JComponent c)
+ {
+ // System.out.println("UI-COMPONENT-> unimplemented paint: " + c + ", UI="+this);
+ }
+
+ void uninstallUI(JComponent c)
+ {
+ }
+
+ void update(Graphics g, JComponent c) {
+ if (c.isOpaque()) {
+ g.setColor(c.getBackground());
+ g.fillRect(0, 0, c.getWidth(),c.getHeight());
+ }
+ paint(g, c);
+ }
+
+}
+
diff --git a/javax/swing/plaf/LabelUI.java b/javax/swing/plaf/LabelUI.java
new file mode 100644
index 000000000..759550abd
--- /dev/null
+++ b/javax/swing/plaf/LabelUI.java
@@ -0,0 +1,6 @@
+package javax.swing.plaf;
+
+
+public class LabelUI extends ComponentUI
+{
+}
diff --git a/javax/swing/plaf/ListUI.java b/javax/swing/plaf/ListUI.java
new file mode 100644
index 000000000..69c2396d0
--- /dev/null
+++ b/javax/swing/plaf/ListUI.java
@@ -0,0 +1,6 @@
+package javax.swing.plaf;
+
+
+public class ListUI extends ComponentUI
+{
+}
diff --git a/javax/swing/plaf/OptionPaneUI.java b/javax/swing/plaf/OptionPaneUI.java
new file mode 100644
index 000000000..115b2d716
--- /dev/null
+++ b/javax/swing/plaf/OptionPaneUI.java
@@ -0,0 +1,5 @@
+package javax.swing.plaf;
+
+public class OptionPaneUI extends ComponentUI
+{
+}
diff --git a/javax/swing/plaf/PanelUI.java b/javax/swing/plaf/PanelUI.java
new file mode 100644
index 000000000..b884acec3
--- /dev/null
+++ b/javax/swing/plaf/PanelUI.java
@@ -0,0 +1,6 @@
+package javax.swing.plaf;
+
+
+public class PanelUI extends ComponentUI
+{
+}
diff --git a/javax/swing/plaf/ScrollPaneUI.java b/javax/swing/plaf/ScrollPaneUI.java
new file mode 100644
index 000000000..99df9d234
--- /dev/null
+++ b/javax/swing/plaf/ScrollPaneUI.java
@@ -0,0 +1,6 @@
+package javax.swing.plaf;
+
+
+public class ScrollPaneUI extends ComponentUI
+{
+}
diff --git a/javax/swing/plaf/TabbedPaneUI.java b/javax/swing/plaf/TabbedPaneUI.java
new file mode 100644
index 000000000..6081c6ebc
--- /dev/null
+++ b/javax/swing/plaf/TabbedPaneUI.java
@@ -0,0 +1,23 @@
+package javax.swing.plaf;
+
+import java.awt.*;
+import javax.swing.*;
+
+public class TabbedPaneUI extends ComponentUI
+{
+ Rectangle getTabBounds(JTabbedPane pane, int index)
+ {
+ return null;
+ }
+
+ int getTabRunCount(JTabbedPane pane)
+ {
+ return 0;
+ }
+
+ int tabForCoordinate(JTabbedPane pane, int x, int y)
+ {
+ return 0;
+ }
+}
+
diff --git a/javax/swing/plaf/TextUI.java b/javax/swing/plaf/TextUI.java
new file mode 100644
index 000000000..a035d3f25
--- /dev/null
+++ b/javax/swing/plaf/TextUI.java
@@ -0,0 +1,26 @@
+package javax.swing.plaf;
+
+import javax.swing.text.*;
+import java.awt.*;
+
+public abstract class TextUI extends ComponentUI
+{
+ TextUI()
+ {
+ }
+
+ abstract void damageRange(JTextComponent t, int p0, int p1);
+ abstract void damageRange(JTextComponent t, int p0, int p1, Position.Bias firstBias, Position.Bias secondBias);
+ abstract EditorKit getEditorKit(JTextComponent t);
+ abstract int getNextVisualPositionFrom(JTextComponent t,
+ int pos,
+ Position.Bias b,
+ int direction,
+ Position.Bias[] biasRet);
+ abstract View getRootView(JTextComponent t);
+ abstract Rectangle modelToView(JTextComponent t, int pos);
+ abstract Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias);
+ abstract int viewToModel(JTextComponent t, Point pt);
+ abstract int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn);
+
+}
diff --git a/javax/swing/plaf/TreeUI.java b/javax/swing/plaf/TreeUI.java
new file mode 100644
index 000000000..48323750d
--- /dev/null
+++ b/javax/swing/plaf/TreeUI.java
@@ -0,0 +1,6 @@
+package javax.swing.plaf;
+
+
+public class TreeUI extends ComponentUI
+{
+}
diff --git a/javax/swing/plaf/ViewportUI.java b/javax/swing/plaf/ViewportUI.java
new file mode 100644
index 000000000..556297391
--- /dev/null
+++ b/javax/swing/plaf/ViewportUI.java
@@ -0,0 +1,6 @@
+package javax.swing.plaf;
+
+
+public class ViewportUI extends ComponentUI
+{
+}
diff --git a/javax/swing/plaf/basic/BasicButtonUI.java b/javax/swing/plaf/basic/BasicButtonUI.java
new file mode 100644
index 000000000..3a9f462a2
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicButtonUI.java
@@ -0,0 +1,176 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import java.awt.*;
+
+
+public class BasicButtonUI extends ButtonUI
+{
+ int gap = 3;
+ // int y_text_space = 2, x_text_space + 5;
+
+ Color textColor, disabledTextColor;
+ Color pressedBackgroundColor;
+ Color normalBackgroundColor;
+
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicButtonUI();
+ }
+
+
+ public void installUI(final JComponent c)
+ {
+ super.installUI(c);
+
+ textColor = new Color(0,0,0);
+ disabledTextColor = new Color(130, 130, 130);
+ pressedBackgroundColor = new Color(150,150,150);
+ pressedBackgroundColor = new Color(150,150,150);
+ normalBackgroundColor = new Color(192,192,192);
+ }
+
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ AbstractButton b = (AbstractButton)c;
+ Dimension d = BasicGraphicsUtils.getPreferredSize(b,
+ gap,
+ b.text,
+ b.getIcon(),
+ b.vert_align,
+ b.hori_align,
+ b.hori_text_pos,
+ b.vert_text_pos);
+ // System.out.println("^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.text);
+ return d;
+ }
+
+
+ void paint(Graphics g, JComponent c)
+ {
+ AbstractButton b = (AbstractButton) c;
+
+ Rectangle tr = new Rectangle();
+ Rectangle ir = new Rectangle();
+ Rectangle vr = new Rectangle();
+
+ Font f = c.getFont();
+
+ g.setFont(f);
+
+ FontMetrics fm = FontMetrics.getFontMetrics(f);
+
+ Insets i = c.getInsets();
+
+ vr.x = i.left;
+ vr.y = i.top;
+ vr.width = b.getWidth() - (i.right + vr.x);
+ vr.height = b.getHeight() - (i.bottom + vr.y);
+
+ //System.out.println(" VIEW-RECT-BUTTON="+vr+", insets="+i+", FONTM="+fm);
+
+ String text = SwingUtilities.layoutCompoundLabel(c,
+ fm,
+ b.getText(),
+ b.getIcon(),
+ b.getVerticalAlignment(),
+ b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(),
+ b.getHorizontalTextPosition(),
+ vr,
+ ir,
+ tr,
+ gap);
+
+ if (b.getModel().isPressed() ||
+ b.getModel().isSelected())
+ {
+ //System.out.println("paint pressed");
+ paintButtonPressed(g, c);
+ }
+ else
+ {
+ //System.out.println("paint normal");
+ paintButtonNormal(g, c);
+ }
+
+ paintIcon(g, c, ir);
+ paintText(g, c, tr, b.text);
+ paintFocus(g, c, vr, tr, ir);
+ }
+
+
+ protected void paintFocus(Graphics g,
+ JComponent c,
+ Rectangle vr,
+ Rectangle tr,
+ Rectangle ir)
+ {
+ }
+
+ protected void paintIcon(Graphics g,
+ JComponent c,
+ Rectangle iconRect)
+ {
+ AbstractButton b = (AbstractButton) c;
+ if (b.default_icon != null)
+ {
+ int x = iconRect.x;
+ int y = iconRect.y;
+
+ System.out.println("WE HAVE AN ICON: " + b.default_icon);
+
+ b.default_icon.paintIcon(c, g, x, y);
+ }
+ else
+ {
+ //System.out.println("NO ICON FOR BUTTON:" + b.text);
+ }
+ }
+
+ protected void paintButtonPressed(Graphics g,
+ JComponent b)
+ {
+ Dimension size = b.getSize();
+
+ g.setColor(pressedBackgroundColor);
+ g.fillRect(1,1,size.width-2, size.height-2);
+
+ }
+
+ protected void paintButtonNormal(Graphics g,
+ JComponent b)
+ {
+ Dimension size = b.getSize();
+
+ g.setColor(normalBackgroundColor);
+ g.fillRect(1,1,size.width-2, size.height-2);
+
+ }
+
+ protected void paintText(Graphics g,
+ JComponent c,
+ Rectangle textRect,
+ String text)
+ {
+ Font f = c.getFont();
+
+ g.setFont(f);
+
+ FontMetrics fm = FontMetrics.getFontMetrics(f);
+
+ g.setColor(c.isEnabled() ? textColor : disabledTextColor);
+
+ BasicGraphicsUtils.drawString(g,
+ text,
+ 0,
+ textRect.x,
+ textRect.y + fm.getAscent()/2);
+ }
+}
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicCheckBoxUI.java b/javax/swing/plaf/basic/BasicCheckBoxUI.java
new file mode 100644
index 000000000..2ad18888a
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicCheckBoxUI.java
@@ -0,0 +1,87 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import java.awt.*;
+
+
+public class BasicCheckBoxUI extends BasicRadioButtonUI
+{
+ public static ComponentUI createUI(final JComponent c) {
+ return new BasicCheckBoxUI();
+ }
+
+
+ public void installUI(final JComponent c) {
+ super.installUI(c);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ AbstractButton b = (AbstractButton)c;
+ Dimension d = BasicGraphicsUtils.getPreferredSize(b,
+ gap,
+ b.text,
+ b.getIcon(),
+ b.vert_align,
+ b.hori_align,
+ b.hori_text_pos,
+ b.vert_text_pos);
+ //System.out.println("^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.text);
+ return d;
+ }
+
+ protected void paintFocus(Graphics g,
+ JComponent c,
+ Rectangle vr,
+ Rectangle tr,
+ Rectangle ir)
+ {
+ }
+
+ protected void paintIcon(Graphics g,
+ JComponent c,
+ Rectangle iconRect)
+ {
+ }
+
+ protected void paintButtonPressed(Graphics g,
+ JComponent b)
+ {
+ Dimension size = b.getSize();
+
+ g.setColor(pressedBackgroundColor);
+ g.fillRect(1,1,size.width-2, size.height-2);
+
+ }
+
+ protected void paintButtonNormal(Graphics g,
+ JComponent b)
+ {
+ Dimension size = b.getSize();
+
+ g.setColor(normalBackgroundColor);
+ g.fillRect(1,1,size.width-2, size.height-2);
+
+ }
+ protected void paintText(Graphics g,
+ JComponent c,
+ Rectangle textRect,
+ String text)
+ {
+ // AbstractButton b = (AbstractButton) c;
+
+ // System.out.println("drawing string: " + text + ", at:" + textRect);
+
+ g.setColor(textColor);
+ BasicGraphicsUtils.drawString(g,
+ text,
+ 0,
+ textRect.x,
+ textRect.y);
+ }
+}
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicDefaults.java b/javax/swing/plaf/basic/BasicDefaults.java
new file mode 100644
index 000000000..d2ca5432a
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicDefaults.java
@@ -0,0 +1,81 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.*;
+import java.awt.*;
+import javax.swing.border.*;
+
+class BasicBorder extends MatteBorder
+{
+ BasicBorder()
+ {
+ super(5,5,5,5, null);
+ }
+
+ public void paintBorder(Component c,
+ Graphics g,
+ int x,
+ int y,
+ int width,
+ int height)
+ {
+ // System.out.println("PAINT-------------------------------------------BORDER");
+
+ if (g != null)
+ {
+ g.setColor( Defaults.BtnPointClr);
+ g.draw3DRect( 0, 0, width-1, height-1, true);
+ }
+ }
+ }
+
+class PanelBorder extends MatteBorder
+{
+ PanelBorder()
+ {
+ super(5,5,5,5, null);
+ }
+
+ public void paintBorder(Component c,
+ Graphics g,
+ int x,
+ int y,
+ int width,
+ int height)
+ {
+ // System.out.println("PAINT-------------------------------------------BORDER");
+ super.paintBorder(c, g, x, y, width, height);
+ }
+ }
+
+public class BasicDefaults extends UIDefaults
+{
+
+ BasicDefaults()
+ {
+ // System.out.println("BasicDefaults !!!!!!!!!!!!!!!!!!!!!!!!!");
+ put("JButton", new BasicButtonUI());
+ put("JLabel", new BasicLabelUI());
+
+ put("JPanel", new BasicPanelUI());
+ put("JCheckBox", new BasicCheckBoxUI());
+ put("JRadioButton", new BasicRadioButtonUI());
+ put("JToggleButton", new BasicToggleButtonUI());
+ put("JOptionPane", new BasicOptionPaneUI());
+ put("JList", new BasicListUI());
+ put("JTree", new BasicTreeUI());
+ put("JTextComponent", new BasicTextUI());
+ put("JTabbedPane", new BasicTabbedPaneUI());
+ put("JScrollPane", new BasicScrollPaneUI());
+ put("JViewport", new BasicViewportUI());
+
+ put("JButton.border", new BasicBorder());
+ put("JPanel.border", new PanelBorder());
+
+ put("JToggleButton.border", new PanelBorder());
+ put("JCheckBox.border", new PanelBorder());
+ put("JRadioButton.border", new PanelBorder());
+ }
+
+}
+
+
diff --git a/javax/swing/plaf/basic/BasicGraphicsUtils.java b/javax/swing/plaf/basic/BasicGraphicsUtils.java
new file mode 100644
index 000000000..52f7c5c44
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicGraphicsUtils.java
@@ -0,0 +1,77 @@
+package javax.swing.plaf.basic;
+
+
+import java.awt.*;
+import javax.swing.*;
+
+
+public class BasicGraphicsUtils
+{
+ public static Dimension getPreferredSize(JComponent b,
+ int gap,
+ String text,
+ Icon icon,
+ int va,
+ int ha,
+ int htp,
+ int vtp)
+ {
+ JComponent c = b;
+ // this is a staight copy from BasicButtonUI.paint()
+ //
+ Rectangle tr = new Rectangle();
+ Rectangle ir = new Rectangle();
+ Rectangle vr = new Rectangle();
+
+ Font f = c.getFont();
+
+ FontMetrics fm = FontMetrics.getFontMetrics(f);
+
+ Insets i = c.getInsets();
+
+ vr.x = i.left;
+ vr.y = i.top;
+ vr.width = b.getWidth() - (i.right + i.left);
+ vr.height = b.getHeight() - (i.bottom + i.top);
+
+ // System.out.println(" VIEW-RECT-BUTTON="+vr+", insets="+i);
+
+ String tt = SwingUtilities.layoutCompoundLabel(b,
+ fm,
+ text,
+ icon,
+ va,
+ ha,
+ vtp,
+ htp,
+ vr,
+ ir,
+ tr,
+ gap);
+
+ Rectangle r = ir.union(tr);
+
+ Insets insets = b.getInsets();
+ r.width += insets.left + insets.right;
+ r.height += insets.top + insets.bottom;
+
+ // System.out.println("COMPUTED SIZE FOR PREF_SIZE="+r);
+
+ return r.getSize();
+ }
+
+ public static void drawString(Graphics g,
+ String text,
+ int underlinedChar,
+ int x,
+ int y)
+ {
+ g.drawString(text, x, y);
+ }
+}
+
+
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicLabelUI.java b/javax/swing/plaf/basic/BasicLabelUI.java
new file mode 100644
index 000000000..b92290a12
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicLabelUI.java
@@ -0,0 +1,158 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import java.awt.*;
+
+
+public class BasicLabelUI extends LabelUI
+{
+ int gap = 3;
+
+ Color foreground;
+
+
+ public static ComponentUI createUI(final JComponent c) {
+ return new BasicLabelUI();
+ }
+
+
+ public void installUI(final JComponent c) {
+ super.installUI(c);
+
+ foreground = new Color(0,0,250);
+ }
+
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ JLabel b = (JLabel)c;
+ Dimension d = BasicGraphicsUtils.getPreferredSize(b,
+ gap,
+ b.text,
+ b.icon,
+ b.vert_align,
+ b.hor_align,
+ b.hor_text_pos,
+ b.vert_text_pos);
+ System.out.println("JLABEL->^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.text);
+ return d;
+ }
+
+
+ void paint(Graphics g, JComponent c)
+ {
+ JLabel b = (JLabel) c;
+
+ Rectangle tr = new Rectangle();
+ Rectangle ir = new Rectangle();
+ Rectangle vr = new Rectangle();
+
+ Font f = c.getFont();
+
+ g.setFont(f);
+
+ FontMetrics fm = FontMetrics.getFontMetrics(f);
+
+ Insets i = c.getInsets();
+
+ Rectangle bound = c.getBounds();
+
+ System.out.println("BOUND=" + bound + ", insets = " + i + ", " + b.text);
+
+ if (bound == null)
+ {
+ vr.x = i.left;
+ vr.y = i.top;
+ vr.width = b.getWidth() - (i.right + i.left);
+ vr.height = b.getHeight() - (i.bottom + i.top);
+ }
+ else
+ {
+ vr.x = bound.x + i.left;
+ vr.y = bound.y + i.top;
+ vr.width = bound.width - (i.right + i.left);
+ vr.height = bound.height - (i.bottom + i.top);
+ }
+
+ System.out.println(" VIEW-RECT-JLABEL="+vr+", insets="+i+", FONTM="+fm);
+
+ String text = SwingUtilities.layoutCompoundLabel(c,
+ fm,
+ b.getText(),
+ b.getIcon(),
+ b.getVerticalAlignment(),
+ b.getHorizontalAlignment(),
+ b.getVerticalTextPosition(),
+ b.getHorizontalTextPosition(),
+ vr,
+ ir,
+ tr,
+ gap);
+
+ paintIcon(g, c, ir);
+ paintText(g, c, tr, b.text);
+ paintFocus(g, c, vr, tr, ir);
+ }
+
+
+ protected void paintFocus(Graphics g,
+ JComponent c,
+ Rectangle vr,
+ Rectangle tr,
+ Rectangle ir)
+ {
+ }
+
+ protected void paintIcon(Graphics g,
+ JComponent c,
+ Rectangle iconRect)
+ {
+ JLabel b = (JLabel) c;
+ if (b.icon != null)
+ {
+ int x = iconRect.x;
+ int y = iconRect.y;
+
+ System.out.println("WE HAVE AN ICON: " + b.icon);
+
+ b.icon.paintIcon(c, g, x, y);
+ }
+ else
+ {
+ //System.out.println("NO ICON FOR BUTTON:" + b.text);
+ }
+ }
+
+
+ protected void paintText(Graphics g,
+ JComponent c,
+ Rectangle textRect,
+ String text)
+ {
+ // AbstractLabel b = (AbstractLabel) c;
+
+ System.out.println("JLabel: drawing string: " + text + ", at:" + textRect);
+
+ g.setColor(foreground);
+ g.setBackColor(new Color(190,190,190));
+
+ g.drawLine(0,0,100,100);
+
+ BasicGraphicsUtils.drawString(g,
+ text,
+ 0,
+ 0,//textRect.x,
+ 0);//textRect.y);
+ }
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicListUI.java b/javax/swing/plaf/basic/BasicListUI.java
new file mode 100644
index 000000000..b1db19510
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicListUI.java
@@ -0,0 +1,132 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.plaf.*;
+import javax.swing.*;
+import java.awt.*;
+
+
+public class BasicListUI extends ListUI
+{
+ int gap_between_cells;
+ Color textColor, disabledTextColor, pressedBackgroundColor, normalBackgroundColor;
+
+
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicButtonUI();
+ }
+
+
+ public void installUI(final JComponent c)
+ {
+ super.installUI(c);
+
+ textColor = new Color(0,0,0);
+ disabledTextColor = new Color(130, 130, 130);
+ pressedBackgroundColor = new Color(150,150,150);
+ normalBackgroundColor = new Color(192,192,192);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ JList l = (JList) c;
+
+ System.out.println("XXXXXXXXXXXXXXXxx getPreferredSize------------> " + l);
+
+
+ int rows = l.getVisibleRowCount();
+
+ ListCellRenderer render = l.getCellRenderer();
+
+ int width = 200;
+ int height = rows * 16;
+
+ if (l.getModel().getSize() == 0)
+ {
+ return new Dimension(width, height);
+ }
+
+ System.out.println("BASIC_LIST_UI ====-> " + l.getModel().getElementAt(0));
+
+ Component elt = render.getListCellRendererComponent(l,
+ l.getModel().getElementAt(0),
+ 0,
+ false,
+ false);
+ Dimension a = elt.getPreferredSize();
+ if (a == null)
+ {
+ return new Dimension(width, height);
+ }
+
+ return new Dimension(a.width,
+ a.height * rows);
+ }
+
+ void paintBackground(Graphics g,
+ JComponent c)
+ {
+ Dimension size = getPreferredSize(c);
+
+ g.setColor(normalBackgroundColor);
+ g.fillRect(0,0,size.width, size.height);
+ }
+
+ void paint(Graphics g,
+ JComponent c)
+ {
+ JList l = (JList) c;
+
+ int rows = l.getVisibleRowCount();
+
+ ListCellRenderer render = l.getCellRenderer();
+
+ System.out.println("RENDER-JLIST: " + rows + ", " + l.getModel().getSize());
+
+ paintBackground(g, c);
+
+ if (l.getModel().getSize() == 0)
+ return;
+
+ // use element 0 to figure out how big we are:
+ Component elt = render.getListCellRendererComponent(l,
+ l.getModel().getElementAt(0),
+ 0,
+ false,
+ false);
+ Dimension dim = elt.getPreferredSize();
+
+ Rectangle a = new Rectangle(0,
+ 0,
+ dim.width,
+ dim.height);
+
+ for (int i=0;i<l.getModel().getSize();i++)
+ {
+ boolean is_sel = false;
+ boolean has_focus = false;
+
+ Component comp = render.getListCellRendererComponent(l,
+ l.getModel().getElementAt(i),
+ i,
+ is_sel,
+ has_focus);
+
+ //System.out.println("AAAAA=> " + a + ", " + comp + ", index = " + i);
+
+ comp.setBounds(a);
+
+ comp.paint(g);
+
+ a.y += dim.height + gap_between_cells;
+ }
+ }
+}
+
+
+
+
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicOptionPaneUI.java b/javax/swing/plaf/basic/BasicOptionPaneUI.java
new file mode 100644
index 000000000..c4d1d3e79
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicOptionPaneUI.java
@@ -0,0 +1,103 @@
+package javax.swing.plaf.basic;
+
+import java.awt.*;
+import java.awt.event.*;
+import javax.swing.*;
+import javax.swing.plaf.*;
+
+
+public class BasicOptionPaneUI extends OptionPaneUI
+{
+ JOptionPane pane;
+
+ BasicOptionPaneUI()
+ {
+ }
+
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new BasicOptionPaneUI();
+ }
+
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ pane = (JOptionPane)c;
+
+ System.out.println(" -------------: " + pane);
+
+ JLabel message = pane.msg != null ? new JLabel(pane.msg) : null;
+ JButton ok_button = new JButton("Ok");
+
+ ok_button.addActionListener(new ActionListener()
+ {
+ public void actionPerformed(ActionEvent a)
+ {
+ System.out.println("ACTION ---> " + a);
+ // pane.dialog.dispose();
+
+ if (pane.dialog.isModal())
+ {
+ System.out.println("modal dialog !!");
+ pane.dialog.setModal(false);
+ }
+ pane.dialog.setVisible(false);
+ }
+ });
+
+ if (pane.args != null)
+ {
+ for (int i=0; i<pane.args.length; i++)
+ {
+ Object o = pane.args[i];
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ String s = (String) o;
+ JLabel m = new JLabel(s);
+ pane.add(m);
+ }
+ else if (o instanceof Component)
+ {
+ Component com = (Component) o;
+ pane.add(com);
+ }
+ else
+ {
+ System.out.println("UNRECOGNIZED ARG: " + o);
+ }
+ }
+ }
+ }
+
+ pane.add(message);
+ pane.add(ok_button);
+ }
+
+ Dimension getMinimumOptionPaneSize()
+ {
+ return new Dimension(300,100);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ if (c == null)
+ return getMinimumOptionPaneSize();
+
+ if (c != pane)
+ return null;
+
+ LayoutManager l = c.getLayout();
+ if (l == null)
+ return getMinimumOptionPaneSize();
+
+ Dimension d1 = l.preferredLayoutSize(c);
+ Dimension d2 = getMinimumOptionPaneSize();
+
+ d1.width = Math.max(d1.width, d2.width);
+ d1.height = Math.max(d1.height, d2.height);
+
+ return d2;
+ }
+}
diff --git a/javax/swing/plaf/basic/BasicPanelUI.java b/javax/swing/plaf/basic/BasicPanelUI.java
new file mode 100644
index 000000000..5976bd2a1
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicPanelUI.java
@@ -0,0 +1,21 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import java.awt.*;
+
+
+public class BasicPanelUI extends PanelUI
+{
+ int gap = 3;
+
+ public static ComponentUI createUI(JComponent x)
+ {
+ return new BasicPanelUI();
+ }
+
+ public void installUI(JComponent c)
+ {
+ super.installUI(c);
+ }
+}
diff --git a/javax/swing/plaf/basic/BasicRadioButtonUI.java b/javax/swing/plaf/basic/BasicRadioButtonUI.java
new file mode 100644
index 000000000..312ae0bf0
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicRadioButtonUI.java
@@ -0,0 +1,126 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import java.awt.*;
+
+
+public class BasicRadioButtonUI extends BasicToggleButtonUI
+{
+ int large_circle_width = 20;
+ int circle_width = large_circle_width - 8; // FIXME: sun == ?
+
+ public static ComponentUI createUI(final JComponent c) {
+ return new BasicRadioButtonUI();
+ }
+
+
+ public void installUI(final JComponent c) {
+ super.installUI(c);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ AbstractButton b = (AbstractButton)c;
+ Dimension d = BasicGraphicsUtils.getPreferredSize(b,
+ gap,
+ b.text,
+ b.getIcon(),
+ b.vert_align,
+ b.hori_align,
+ b.hori_text_pos,
+ b.vert_text_pos);
+ // and add a little something for the circles:
+
+ d.width += large_circle_width;
+ d.height = Math.max(large_circle_width, d.height);
+
+ //System.out.println("^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.text);
+ return d;
+ }
+
+ protected void paintFocus(Graphics g,
+ JComponent c,
+ Rectangle vr,
+ Rectangle tr,
+ Rectangle ir)
+ {
+ }
+
+ protected void paintIcon(Graphics g,
+ JComponent c,
+ Rectangle iconRect)
+ {
+ }
+
+ protected void paintButtonPressed(Graphics g,
+ JComponent b)
+ {
+ Dimension size = b.getSize();
+
+ paintButtonNormal(g, b);
+
+ int x = gap;
+ int y = gap;
+
+ int diffp = 2;
+ int diff = 3;
+
+ g.setColor(textColor);
+ g.fillArc(x+diffp, y+diffp,
+ circle_width-diff, circle_width-diff,
+ 0, 360);
+ }
+
+ protected void paintButtonNormal(Graphics g,
+ JComponent c)
+ {
+ AbstractButton b = (AbstractButton) c;
+
+ Dimension size = b.getSize();
+
+ g.setColor(normalBackgroundColor);
+ g.fillRect(1,1,size.width-2, size.height-2);
+
+ int x = gap;
+ int y = gap;
+
+ g.setColor(pressedBackgroundColor);
+ g.drawArc(x, y,
+ circle_width, circle_width,
+ 0, 360);
+
+ g.setColor(new Color(255,255,255));
+ g.drawArc(x, y,
+ circle_width+1, circle_width+1,
+ 145, 160);
+ }
+
+ protected void paintText(Graphics g,
+ JComponent c,
+ Rectangle textRect,
+ String text)
+ {
+ // AbstractButton b = (AbstractButton) c;
+
+ //System.out.println("drawing string: " + text + ", " + c.isEnabled());
+
+ g.setColor(c.isEnabled() ? textColor : disabledTextColor);
+
+ BasicGraphicsUtils.drawString(g,
+ text,
+ 0,
+ textRect.x + circle_width + gap,
+ textRect.y);
+ }
+}
+
+
+
+
+
+
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicScrollPaneUI.java b/javax/swing/plaf/basic/BasicScrollPaneUI.java
new file mode 100644
index 000000000..5b274220c
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicScrollPaneUI.java
@@ -0,0 +1,66 @@
+package javax.swing.plaf.basic;
+
+
+import javax.swing.plaf.*;
+import javax.swing.*;
+import java.awt.*;
+
+
+
+public class BasicScrollPaneUI extends ScrollPaneUI
+{
+ int min_w = 50;
+ int min_h = 50;
+
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicScrollPaneUI();
+ }
+
+
+ public void installUI(final JComponent c)
+ {
+ super.installUI(c);
+ }
+
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ JScrollPane p = (JScrollPane ) c;
+
+ Dimension d = new Dimension(min_w,
+ min_h);
+
+ Dimension a = p.getViewport().getPreferredSize();
+
+ if (a != null)
+ {
+ d.width = Math.max(d.width, a.width);
+ d.height = Math.max(d.height, a.height);
+ }
+
+
+ System.out.println("BasicScrollPaneUI->preff->"+d);
+ return d;
+ }
+
+ void paint(Graphics g, JComponent c)
+ {
+ System.out.println("BasicScrollPaneUI->paint()->"+c);
+
+ JScrollPane p = (JScrollPane ) c;
+ p.getViewport().paint(g);
+ }
+}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicTabbedPaneUI.java b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
new file mode 100644
index 000000000..f9134a8ce
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicTabbedPaneUI.java
@@ -0,0 +1,64 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.*;
+import java.awt.*;
+import javax.swing.plaf.*;
+
+public class BasicTabbedPaneUI extends TabbedPaneUI
+{
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicTabbedPaneUI();
+ }
+
+ public void installUI(final JComponent c)
+ {
+ super.installUI(c);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ JTabbedPane p = (JTabbedPane) c;
+
+ Dimension d = new Dimension(50,50);
+
+ for (int i=0;i<p.getTabCount();i++)
+ {
+ Component comp = p.getComponentAt(i);
+
+ Dimension pr = comp.getPreferredSize();
+
+ d.width = Math.max(d.width, comp.width);
+ d.height = Math.max(d.height, comp.height);
+ }
+
+ Insets i = p.getInsets();
+
+ d.width += i.left + i.right;
+ d.height += i.top + i.bottom;
+
+ int height_of_tabs = 25;
+
+ d.height += height_of_tabs;
+
+ // FIXME: should be max of panes in p
+ return d;
+ }
+
+
+ Rectangle getTabBounds(JTabbedPane pane, int index)
+ {
+ return null;
+ }
+
+ int getTabRunCount(JTabbedPane pane)
+ {
+ return 0;
+ }
+
+ int tabForCoordinate(JTabbedPane pane, int x, int y)
+ {
+ return 0;
+ }
+}
+
diff --git a/javax/swing/plaf/basic/BasicTextUI.java b/javax/swing/plaf/basic/BasicTextUI.java
new file mode 100644
index 000000000..1a687f335
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicTextUI.java
@@ -0,0 +1,126 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.text.*;
+import javax.swing.plaf.*;
+import java.awt.*;
+import javax.swing.*;
+
+public class BasicTextUI extends TextUI
+{
+ int gap = 3;
+ View view = new RootView();
+ Color textColor, disabledTextColor, normalBackgroundColor;
+ EditorKit kit = new DefaultEditorKit();
+
+ class RootView extends View
+ {
+ RootView()
+ {
+ super(null);
+ }
+ public void paint(Graphics g, Shape s)
+ {
+ if (view != null)
+ {
+ Rectangle r = s.getBounds();
+
+ view.setSize(r.width,
+ r.height);
+ view.paint(g, s);
+ }
+ }
+ }
+
+ BasicTextUI()
+ {
+ }
+
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicTextUI();
+ }
+
+
+ public void installUI(final JComponent c)
+ {
+ super.installUI(c);
+
+ textColor = new Color(0,0,0);
+ disabledTextColor = new Color(130, 130, 130);
+ normalBackgroundColor = new Color(192,192,192);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ JTextComponent b = (JTextComponent) c;
+
+ View v = getRootView(b);
+
+ float w = v.getPreferredSpan(View.X_AXIS);
+ float h = v.getPreferredSpan(View.Y_AXIS);
+
+ return new Dimension(w, h);
+ }
+
+
+ void paint(Graphics g, JComponent c)
+ {
+ // view.paint(
+ }
+
+ void damageRange(JTextComponent t, int p0, int p1)
+ {
+ damageRange(t, p0, p1, null, null);
+ }
+
+ void damageRange(JTextComponent t,
+ int p0, int p1,
+ Position.Bias firstBias,
+ Position.Bias secondBias)
+ {
+ }
+
+ EditorKit getEditorKit(JTextComponent t)
+ {
+ return kit;
+ }
+
+ int getNextVisualPositionFrom(JTextComponent t,
+ int pos,
+ Position.Bias b,
+ int direction,
+ Position.Bias[] biasRet)
+ {
+ return 0;
+ }
+
+ View getRootView(JTextComponent t)
+ {
+ return view;
+ }
+
+ Rectangle modelToView(JTextComponent t, int pos)
+ {
+ return modelToView(t, pos, null);
+ }
+
+ Rectangle modelToView(JTextComponent t, int pos, Position.Bias bias)
+ {
+ return null;
+ }
+
+ int viewToModel(JTextComponent t, Point pt)
+ {
+ return viewToModel(t, pt, null);
+ }
+
+ int viewToModel(JTextComponent t, Point pt, Position.Bias[] biasReturn)
+ {
+ return 0;
+ }
+}
+
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicToggleButtonUI.java b/javax/swing/plaf/basic/BasicToggleButtonUI.java
new file mode 100644
index 000000000..3e181ca8a
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicToggleButtonUI.java
@@ -0,0 +1,89 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import java.awt.*;
+
+
+public class BasicToggleButtonUI extends BasicButtonUI
+{
+
+ public static ComponentUI createUI(final JComponent c) {
+ return new BasicToggleButtonUI();
+ }
+
+
+ public void installUI(final JComponent c) {
+ super.installUI(c);
+ }
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ AbstractButton b = (AbstractButton)c;
+ Dimension d = BasicGraphicsUtils.getPreferredSize(b,
+ gap,
+ b.text,
+ b.getIcon(),
+ b.vert_align,
+ b.hori_align,
+ b.hori_text_pos,
+ b.vert_text_pos);
+ //System.out.println("^^^^^^^^^^^^^^^^^^^^^^ BASIC-PREF="+d + ",T="+b.text);
+ return d;
+ }
+
+ protected void paintFocus(Graphics g,
+ JComponent c,
+ Rectangle vr,
+ Rectangle tr,
+ Rectangle ir)
+ {
+ }
+
+ protected void paintIcon(Graphics g,
+ JComponent c,
+ Rectangle iconRect)
+ {
+ }
+
+ protected void paintButtonPressed(Graphics g,
+ JComponent b)
+ {
+ Dimension size = b.getSize();
+
+ g.setColor(pressedBackgroundColor);
+ g.fillRect(1,1,size.width-2, size.height-2);
+
+ }
+
+ protected void paintButtonNormal(Graphics g,
+ JComponent b)
+ {
+ Dimension size = b.getSize();
+
+ g.setColor(normalBackgroundColor);
+ g.fillRect(1,1,size.width-2, size.height-2);
+
+ }
+ protected void paintText(Graphics g,
+ JComponent c,
+ Rectangle textRect,
+ String text)
+ {
+ // AbstractButton b = (AbstractButton) c;
+
+ // System.out.println("drawing string: " + text + ", at:" + textRect);
+
+ g.setColor(textColor);
+
+ BasicGraphicsUtils.drawString(g,
+ text,
+ 0,
+ textRect.x,
+ textRect.y);
+ }
+}
+
+
+
+
diff --git a/javax/swing/plaf/basic/BasicTreeUI.java b/javax/swing/plaf/basic/BasicTreeUI.java
new file mode 100644
index 000000000..1f4f2a8b2
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicTreeUI.java
@@ -0,0 +1,7 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.plaf.*;
+
+public class BasicTreeUI extends TreeUI
+{
+}
diff --git a/javax/swing/plaf/basic/BasicViewportUI.java b/javax/swing/plaf/basic/BasicViewportUI.java
new file mode 100644
index 000000000..d399cc7a9
--- /dev/null
+++ b/javax/swing/plaf/basic/BasicViewportUI.java
@@ -0,0 +1,33 @@
+package javax.swing.plaf.basic;
+
+import javax.swing.plaf.*;
+import javax.swing.*;
+import java.awt.*;
+
+public class BasicViewportUI extends ViewportUI
+{
+
+ public static ComponentUI createUI(final JComponent c)
+ {
+ return new BasicViewportUI();
+ }
+
+
+ public void installUI(final JComponent c)
+ {
+ super.installUI(c);
+ }
+
+
+ public Dimension getPreferredSize(JComponent c)
+ {
+ Dimension d = new Dimension(100,100);
+ System.out.println("BasicViewportUI->preff->"+d);
+ return d;
+ }
+
+ void paint(Graphics g, JComponent c)
+ {
+ System.out.println("BasicViewportUI->paint->"+c);
+ }
+}
diff --git a/javax/swing/plaf/metal/MetalLookAndFeel.java b/javax/swing/plaf/metal/MetalLookAndFeel.java
new file mode 100644
index 000000000..cc85babef
--- /dev/null
+++ b/javax/swing/plaf/metal/MetalLookAndFeel.java
@@ -0,0 +1,31 @@
+package javax.swing.plaf.metal;
+
+import javax.swing.*;
+import javax.swing.plaf.*;
+import javax.swing.plaf.basic.*;
+
+
+public class MetalLookAndFeel extends LookAndFeel
+ {
+ boolean isNativeLookAndFeel() { return true; }
+ boolean isSupportedLookAndFeel() { return true; }
+ String getDescription() { return "Metal look and feel"; }
+ String getID() { return "MetalLookAndFeel"; }
+ String getName() { return "MetalLookAndFeel"; }
+
+
+ UIDefaults LAF_defaults;
+
+ MetalLookAndFeel()
+ {
+ }
+
+ UIDefaults getDefaults()
+ {
+ if (LAF_defaults == null)
+ LAF_defaults = new BasicDefaults();
+
+ // Returns the default values for this look and feel.
+ return LAF_defaults;
+ }
+ };