⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 groupinfo.java

📁 这是一个用java和xml编写的流媒体服务器管理软件
💻 JAVA
字号:
/*
 * ==================================================================== 
 * 
 */

package vocal.userEditor;

import vocal.ui.UserNameField;

import java.awt.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

import java.text.ParseException;



public class GroupInfo extends JPanel implements DataEditor
{
  private JTextField group;

  private static Color lightGray = new Color(235, 235, 235);
 
  boolean groupChanged = false;

  private int mode = AccreditAdd.ADD_NEW_MODE;



  public GroupInfo()
  {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(new EmptyBorder(5, 5, 5, 5));

    

    group = new JTextField();

    group.setToolTipText("arbitrary text string for classifying this user");
    
    add(createLabelComponentPair("Group:", group));

    final Color backgroundColor = group.getBackground();

    
    group.setBackground(lightGray);

   

    group.addKeyListener(new KeyAdapter()
    {
      public void keyTyped(KeyEvent e)
      {
        group.setBackground(backgroundColor);

        groupChanged = true;
      }

    });
  }


  private JPanel createLabelComponentPair(String labelText, Component comp)
  {
    JPanel temp = new JPanel();

    temp.setBorder(new EmptyBorder(1, 1, 1, 1));

    JLabel label = new JLabel(labelText);
    Dimension dim = new Dimension(80, label.getHeight());

    label.setPreferredSize(dim);
    temp.setLayout(new BoxLayout(temp, BoxLayout.X_AXIS));
    temp.add(label);
    temp.add(comp);

    return temp;
  }


  // ----------------------DataEditor implementation------------------------------

  public String getData(int id)
  {
    switch (id)
    {

      case AccreditGroupModel.GROUP_NAME:
      {
        if (groupChanged)
        {
          return group.getText();
        }
      }

        break;
      
    }

    return null;
  }


  /**
   * Clear the value of all editor components in this panel and set their
   * corresponding "changed" flags to false.
   */
  public void clear()
  {
   
    group.setText("");
    groupChanged = false;
    group.setBackground(lightGray);
  }


  public boolean setData(int id, String data)
  {
    switch (id)
    {
      case AccreditGroupModel.GROUP_NAME:
      {
        group.setText(data);

        return true;
      }
    }

    return false;
  }


  public void setMode(int newMode)
  {
    if (mode != newMode)
    {
      mode = newMode;

      if (newMode == AccreditAdd.EDIT_EXISTING_MODE)
      {
        group.setEditable(false);
        group.setEnabled(false);
      }
      else if (newMode == AccreditAdd.ADD_NEW_MODE)
      {
    	  group.setEditable(true);
    	  group.setEnabled(true);
      }

      validate();
    }
  }


  public boolean isDataValid()
  {
	  /*
    try
    {
      name.verifyContent();
    }
    catch (ParseException ex)
    {
      ex.printStackTrace();
      JOptionPane.showMessageDialog(this.getTopLevelAncestor(), 
              ex.getMessage(), "Invalid input", JOptionPane.ERROR_MESSAGE);

      return false;
    }
    */
    return true;
  }

  // ----------------------End DataEditor implementation---------------------------
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -