home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing;
-
- import com.sun.java.accessibility.AccessibleContext;
- import com.sun.java.swing.text.Document;
- import com.sun.java.swing.text.JTextComponent;
- import com.sun.java.swing.text.PlainDocument;
- import com.sun.java.swing.text.TextAction;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dimension;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Rectangle;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
-
- public class JTextField extends JTextComponent implements SwingConstants {
- public static final String notifyAction = "notify-field-accept";
- private BoundedRangeModel visibility;
- private int horizontalAlignment;
- private int columns;
- private int columnWidth;
- private String command;
- private static final String base = "textfield";
- private static int nameCounter;
- private static final Action[] defaultActions = new Action[]{new NotifyAction()};
- // $FF: synthetic field
- static Class class$java$awt$event$ActionListener;
-
- public JTextField() {
- this((Document)null, (String)null, 0);
- }
-
- public JTextField(String var1) {
- this((Document)null, var1, 0);
- }
-
- public JTextField(int var1) {
- this((Document)null, (String)null, var1);
- }
-
- public JTextField(String var1, int var2) {
- this((Document)null, var1, var2);
- }
-
- public JTextField(Document var1, String var2, int var3) {
- this.horizontalAlignment = 2;
- ((Component)this).setName("textfield" + nameCounter++);
- if (var3 < 0) {
- throw new IllegalArgumentException("columns less than zero.");
- } else {
- this.visibility = new DefaultBoundedRangeModel();
- this.visibility.addChangeListener(new ScrollRepainter(this));
- this.columns = var3;
- if (var1 == null) {
- var1 = this.createDefaultModel();
- }
-
- ((JTextComponent)this).setDocument(var1);
- if (var2 != null) {
- ((JTextComponent)this).setText(var2);
- }
-
- }
- }
-
- public String getUIClassID() {
- return "TextFieldUI";
- }
-
- public int getHorizontalAlignment() {
- return this.horizontalAlignment;
- }
-
- public void setHorizontalAlignment(int var1) {
- if (var1 != this.horizontalAlignment) {
- int var2 = this.horizontalAlignment;
- if (var1 != 2 && var1 != 0 && var1 != 4) {
- throw new IllegalArgumentException("horizontalAlignment");
- } else {
- this.horizontalAlignment = var1;
- ((JComponent)this).firePropertyChange("horizontalAlignment", var2, this.horizontalAlignment);
- ((Container)this).invalidate();
- ((Component)this).repaint();
- }
- }
- }
-
- protected Document createDefaultModel() {
- return new PlainDocument();
- }
-
- public int getColumns() {
- return this.columns;
- }
-
- public void setColumns(int var1) {
- int var2 = this.columns;
- if (var1 < 0) {
- throw new IllegalArgumentException("columns less than zero.");
- } else {
- if (var1 != var2) {
- this.columns = var1;
- ((Container)this).invalidate();
- }
-
- }
- }
-
- protected int getColumnWidth() {
- if (this.columnWidth == 0) {
- FontMetrics var1 = ((Component)this).getFontMetrics(((Component)this).getFont());
- this.columnWidth = var1.charWidth('m');
- }
-
- return this.columnWidth;
- }
-
- public Dimension getPreferredSize() {
- Object var2 = ((Component)this).getTreeLock();
- synchronized(var2){}
-
- Dimension var1;
- try {
- Dimension var4 = super.getPreferredSize();
- if (this.columns != 0) {
- var4.width = this.columns * this.getColumnWidth();
- }
-
- var1 = var4;
- } catch (Throwable var6) {
- throw var6;
- }
-
- return var1;
- }
-
- public Dimension getMinimumSize() {
- return this.getPreferredSize();
- }
-
- public void setFont(Font var1) {
- super.setFont(var1);
- this.columnWidth = 0;
- ((JComponent)this).revalidate();
- }
-
- public synchronized void addActionListener(ActionListener var1) {
- super.listenerList.add(class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = JComponent.class$("java.awt.event.ActionListener")), var1);
- }
-
- public synchronized void removeActionListener(ActionListener var1) {
- super.listenerList.remove(class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = JComponent.class$("java.awt.event.ActionListener")), var1);
- }
-
- protected void fireActionPerformed() {
- Object[] var1 = super.listenerList.getListenerList();
- ActionEvent var2 = new ActionEvent(this, 1001, this.command != null ? this.command : ((JTextComponent)this).getText());
-
- for(int var3 = var1.length - 2; var3 >= 0; var3 -= 2) {
- if (var1[var3] == (class$java$awt$event$ActionListener != null ? class$java$awt$event$ActionListener : (class$java$awt$event$ActionListener = JComponent.class$("java.awt.event.ActionListener")))) {
- ((ActionListener)var1[var3 + 1]).actionPerformed(var2);
- }
- }
-
- }
-
- public void setActionCommand(String var1) {
- this.command = var1;
- }
-
- public Action[] getActions() {
- return TextAction.augmentList(super.getActions(), defaultActions);
- }
-
- public void postActionEvent() {
- this.fireActionPerformed();
- }
-
- protected String paramString() {
- return super.paramString() + ",columns=" + this.columns + ",command=" + this.command;
- }
-
- public BoundedRangeModel getHorizontalVisibility() {
- return this.visibility;
- }
-
- public int getScrollOffset() {
- return this.visibility.getValue();
- }
-
- public void setScrollOffset(int var1) {
- this.visibility.setValue(var1);
- }
-
- public void scrollRectToVisible(Rectangle var1) {
- int var2 = var1.x + this.visibility.getValue();
- if (var2 < this.visibility.getValue()) {
- this.visibility.setValue(var2 - 2);
- } else {
- if (var2 > this.visibility.getValue() + this.visibility.getExtent()) {
- this.visibility.setValue(var2 - this.visibility.getExtent() + 2);
- }
-
- }
- }
-
- public AccessibleContext getAccessibleContext() {
- if (super.accessibleContext == null) {
- super.accessibleContext = new AccessibleJTextField(this);
- }
-
- return super.accessibleContext;
- }
- }
-