Beispiel #1
0
  public JFrame buildFrame() {

    f = new JFrame("AMSA World");
    f.setSize(800, 600);
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.setLayout(new GridBagLayout());

    textArea.setFocusable(false);
    JScrollPane scrollPane = new JScrollPane(textArea);
    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

    ActionListener listener =
        new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
            checkInput();
          }
        };
    inputText.addActionListener(listener);

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1.0;
    c.gridwidth = 3;
    c.weighty = 0.025;
    c.gridx = 0;
    c.gridy = 0;
    f.add(topPanel, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 2;
    c.gridx = 0;
    c.gridy = 1;
    f.add(scrollPane, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridwidth = 1;
    c.gridx = 2;
    c.gridy = 1;
    f.add(sidePanel, c);
    sidePanel.setVisible(false);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.weighty = 0.025;
    c.gridwidth = 3;
    c.gridx = 0;
    c.gridy = 2;
    f.add(inputText, c);

    f.setVisible(true);

    return f;
  }
 public TextFields() {
   t1.setDocument(ucd);
   ucd.addDocumentListener(new T1());
   b1.addActionListener(new B1());
   b2.addActionListener(new B2());
   t1.addActionListener(new T1A());
   setLayout(new FlowLayout());
   add(b1);
   add(b2);
   add(t1);
   add(t2);
   add(t3);
 }
 /**
  * References checked: 8.10.2003 (2.0b2)
  *
  * @param editorType editor type, one of this constants
  *     <UL>
  *       <LI>EDITOR_TYPE_DEFAULT
  *       <LI>EDITOR_TYPE_STYLED
  *       <LI>EDITOR_TYPE_SINGLE_LINE
  *     </UL>
  *
  * @param controler if not <code>null</code> for <code>EDITOR_TYPE_STYLED</code> editors a toolbar
  *     is created
  * @see PresentationDetail#PresentationDetail
  */
 TextEditorPanel(
     int editorType,
     GraphPanelControler controler,
     boolean showToolbar,
     PresentationDetail detail) {
   this.editorType = editorType;
   this.controler = controler;
   this.showToolbar = showToolbar;
   this.detail = detail;
   setLayout(new BorderLayout());
   // --- build this text editor panel ---
   switch (editorType) {
     case EDITOR_TYPE_DEFAULT:
       textComponent = new JTextArea();
       add(new JScrollPane(textComponent));
       break;
     case EDITOR_TYPE_STYLED:
       textComponent = new JTextPane();
       textComponent.setTransferHandler(new TextTransferHandler()); // ### requires Java 1.4
       // --- add toolbar ---
       if (showToolbar) {
         JPanel bar = new JPanel();
         Hashtable actions = DeepaMehtaClientUtils.createActionTable(textComponent);
         bar.setBackground(COLOR_PROPERTY_PANEL);
         toolbarButtons = new JButton[3];
         addButton(bar, new StyledEditorKit.BoldAction(), actions, controler.boldIcon());
         addButton(bar, new StyledEditorKit.ItalicAction(), actions, controler.italicIcon());
         addButton(bar, new StyledEditorKit.UnderlineAction(), actions, controler.underlineIcon());
         // ### addButton(bar, "H1", CMD_SET_HEADLINE1);
         // ### addButton(bar, "H2", CMD_SET_HEADLINE2);
         add(bar, BorderLayout.SOUTH);
       }
       add(new JScrollPane(textComponent));
       break;
     case EDITOR_TYPE_SINGLE_LINE:
       textComponent = new JTextField();
       ((JTextField) textComponent).addActionListener(this);
       add(textComponent);
       break;
     default:
       throw new DeepaMehtaException("unexpected text editor type: " + editorType);
   }
   // --- enable automatic drag and drop support ---
   try {
     textComponent.setDragEnabled(true);
   } catch (NoSuchMethodError e) {
     // requires JDK 1.4 ###
   }
 }