Ejemplo n.º 1
0
 public void setOutputPanel() {
   BoxLayout box = new BoxLayout(output, BoxLayout.Y_AXIS);
   output.setLayout(box);
   Color c1 = new Color(166, 209, 241);
   Color c2 = new Color(204, 210, 211);
   JLabel label3 = new JLabel("Messaggi interni:");
   output.add(label3);
   outp.setBackground(c1);
   outp.setAutoscrolls(true);
   outp.setEditable(false);
   intmsg.setBackground(c2);
   intmsg.setAutoscrolls(true);
   intmsg.setEditable(false);
   output.add(scrollPaneM);
   JLabel label4 = new JLabel("Output:");
   output.add(label4);
   output.add(scrollPaneO);
   output.setBorder(BorderFactory.createEtchedBorder());
 }
Ejemplo n.º 2
0
  public Server() {
    super("SERVER");

    /*init ligne */
    try {
      InfoLigne = Utile.getStation();
      TabLigne[0] = true;
      ID_controleur[0] = true;
      for (int i = 1; i < TabLigne.length; i++) {
        TabLigne[i] = false;
        ID_controleur[i] = false;
      }
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    /*init fenêtre*/
    this.setSize(840, 640);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    this.container.add(panBus, BorderLayout.WEST);
    this.container.add(panControleur, BorderLayout.EAST);
    this.container.add(jscroll, BorderLayout.SOUTH);

    this.panBus.setPreferredSize(new Dimension(515, 400));
    this.panBus.setToolTipText("Panneau de Serveur BUS");
    this.panBus.setAutoscrolls(true);

    jscroll.setBounds(100, 30, 250, 100);
    jscroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    jscroll.setAutoscrolls(true);
    jscroll.setPreferredSize(new Dimension(830, 90));

    this.console.setPreferredSize(new Dimension(830, 100));
    this.console.setToolTipText("Console");
    this.console.setAutoscrolls(true);

    this.panControleur.setPreferredSize(new Dimension(315, 400));
    this.panControleur.setToolTipText("Panneau Controleur");
    this.panBus.setBackground(Color.GRAY);
    this.console.setBackground(Color.black);
    console.setForeground(Color.cyan);
    console.setBackground(Color.black);
    console.setAutoscrolls(true);
    console.setRows(rowConsole);
    console.setLineWrap(true);
    console.setFocusable(true);
    console.setEditable(false);
    console.setText(stConsole);

    this.getContentPane().add(container);
    this.setVisible(true);
  }
Ejemplo n.º 3
0
 public TextPane(String title, int width, int height) {
   instance = this;
   menu = new JMenu("<html><b><font size=+1>F</font></b><html>ile");
   openItem = new JMenuItem("打开");
   openItem.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           instance.openFile();
         }
       });
   menu.add(openItem);
   saveItem = new JMenuItem("保存");
   saveItem.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           instance.save();
         }
       });
   menu.add(saveItem);
   clearItem = new JMenuItem("清空");
   clearItem.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           txt.setText("");
         }
       });
   menu.add(clearItem);
   closeItem = new JMenuItem("退出");
   closeItem.addActionListener(
       new ActionListener() {
         @Override
         public void actionPerformed(ActionEvent e) {
           instance.dispose();
         }
       });
   menu.add(closeItem);
   menuBar = new JMenuBar();
   menuBar.add(menu);
   setJMenuBar(menuBar);
   txt = new JTextArea();
   txt.setAutoscrolls(true);
   add(txt);
   setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
   setSize(width, height);
   setVisible(true);
 }
 public WarehouseKeeperLogFrame() {
   this.setSize(600, 600);
   this.setDefaultCloseOperation(HIDE_ON_CLOSE);
   this.setLocation((WIDTH / 2) - this.getWidth() / 2, (HEIGTH / 2) - this.getHeight() / 2);
   this.setLayout(new FlowLayout());
   log.setAutoscrolls(true);
   log.setPreferredSize(new Dimension(1000, 500));
   log.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
   JScrollPane jScrollPane = new JScrollPane(log);
   jScrollPane.setPreferredSize(new Dimension(565, 300));
   jScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);
   jScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
   jScrollPane.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
   this.add(jScrollPane);
   log.setEditable(false);
 }
Ejemplo n.º 5
0
  private void initialize() {
    JTextArea textArea = new JTextArea(5000, 5000);
    textArea.setAutoscrolls(true);

    MouseMotionListener doScrollRectToVisible =
        new MouseMotionAdapter() {
          public void mouseDragged(MouseEvent e) {
            Rectangle r = new Rectangle(e.getX(), e.getY(), 1, 1);
            ((JTextArea) e.getSource()).scrollRectToVisible(r);
          }
        };
    textArea.addMouseMotionListener(doScrollRectToVisible);

    // JPanel panel = new JPanel(new BorderLayout());
    // panel.setPreferredSize(new Dimension(500, 500));
    JScrollPane scrollPanel = new JScrollPane(textArea);

    scrollPanel.setAutoscrolls(true);
    setContentPane(scrollPanel);
  }
Ejemplo n.º 6
0
  public BossDialogEditor(BossPlacer bp) {
    bossPlacer = bp;
    this.setLayout(null);
    this.setSize(400, 500);

    dLabel = new JLabel("Dialog");
    this.add(dLabel);
    dLabel.setBounds(0, 0, 100, 50);

    dlgTA = new JTextArea("");
    dlgTA.setAutoscrolls(true);
    dlgTA.setEditable(true);
    dlgTA.setLineWrap(true);

    JScrollPane jsp = new JScrollPane(dlgTA);
    jsp.setBounds(0, 50, 350, 200);
    jsp.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
    this.add(jsp);

    save = new JButton("Confirm Changes");
    this.add(save);
    save.setBounds(0, 260, 150, 40);

    save.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveChanges();
          }
        });

    close = new JButton("Close");
    this.add(close);
    close.setBounds(170, 260, 150, 40);

    close.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            bossPlacer.hideDialogEditor();
          }
        });
  }
Ejemplo n.º 7
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.setBounds(200, 200, 400, 300);
    // 此处【注释掉】是不想让此UI被关闭时主程序也被关闭
    // frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);
    textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setBackground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);

    scrollPane = new JScrollPane(textArea);
    scrollPane.setBounds(10, 10, 370, 200);
    scrollPane.setAutoscrolls(true);
    scrollPane.setAutoscrolls(true);
    frame.getContentPane().add(scrollPane);

    button_OK = new JButton("OK");
    button_OK.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent arg0) {
            frame.dispose();
          }
        });
    button_OK.setBounds(10, 230, 120, 30);
    frame.getContentPane().add(button_OK);

    button_Cancel = new JButton("Cancel");
    button_Cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            frame.dispose();
          }
        });
    button_Cancel.setBounds(260, 230, 120, 30);
    frame.getContentPane().add(button_Cancel);
  }
Ejemplo n.º 8
0
  public TemperatureDialog() {
    super(MainFrame.instance(), "编辑温度", true);
    setLayout(null);
    setSize(420, 420);
    setLocationRelativeTo(null);
    temperatureDialog = this;
    JLabel jlbName = new JLabel("温度内容(100字):");
    JButton ensure = new JButton("确定");
    JButton cancel = new JButton("取消");

    jTextArea = new JTextArea();
    jlbName.setBounds(60, 30, 300, 30);
    jTextArea.setBounds(60, 60, 300, 50);
    jTextArea.setAutoscrolls(true);
    jTextArea.setWrapStyleWord(true);
    jTextArea.setLineWrap(true);
    ensure.setBounds(115, 320, 70, 40);
    cancel.setBounds(210, 320, 70, 40);

    ensure.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            String content = jTextArea.getText().trim();
            if (content.isEmpty()) {
              JOptionPane.showMessageDialog(null, "请输入内容", "提示", JOptionPane.OK_OPTION);
              return;
            }
            if (content.length() > 100) {
              JOptionPane.showMessageDialog(null, "内容不能超过100个字符", "提示", JOptionPane.OK_OPTION);
              return;
            }
            TemperatureDialog.instance().dispose();
            List<Temperature> tList = TemperatureDao.instance().gettemperatureList();
            if (tList == null || tList.size() < 1) {
              System.err.println(
                  "TemperatureDao.instance().gettemperatureList() 为 null 或者 size 为 0");
            }
            Temperature t = tList.get(0);
            t.content = content;
            BusyDialog bd = new BusyDialog();
            ExecutorService executor = Executors.newCachedThreadPool();

            CountDownLatch latch = new CountDownLatch(1);
            TemperatureWorker w1 = new TemperatureWorker(latch, "TemperatureWorker");
            LodingWorker loading = new LodingWorker(latch, bd);

            executor.execute(w1);
            executor.execute(loading);
            executor.shutdown();
          }
        });
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent arg0) {
            TemperatureDialog.instance().dispose();
            //				TemperatureDialog.instance().jTextArea.setText("");
          }
        });

    add(jlbName);
    add(jTextArea);
    add(ensure);
    add(cancel);
  }
Ejemplo n.º 9
0
  public ScrapeView() {
    this.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));

    GridBagLayout layout = new GridBagLayout();
    this.setLayout(layout);

    GridBagConstraints constraint = new GridBagConstraints();
    constraint.insets = new Insets(3, 3, 3, 3);
    constraint.weightx = 1;
    constraint.weighty = 0;
    constraint.gridwidth = 1;
    constraint.anchor = GridBagConstraints.CENTER;

    {
      websiteDataUrlLabel = new JLabel("Website data URL:");

      constraint.weightx = 0;
      constraint.weighty = 0;
      constraint.gridx = 0;
      constraint.gridy = 0;
      constraint.gridwidth = 1;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(websiteDataUrlLabel, constraint);
    }

    {
      websiteDataUrlTextField = new JTextField("");
      websiteDataUrlTextField
          .getDocument()
          .addDocumentListener(
              new DocumentListener() {
                @Override
                public void insertUpdate(DocumentEvent e) {
                  try {
                    String str = e.getDocument().getText(0, e.getDocument().getLength());
                    if (str.contains("motel6.com")) {
                      parserComboBox.setSelectedIndex(0);
                    } else if (str.contains("redroof.com")) {
                      parserComboBox.setSelectedIndex(1);
                    } else if (str.contains("redlion.com")) {
                      parserComboBox.setSelectedIndex(2);
                    }
                  } catch (BadLocationException exception) {
                    logger.error(exception);
                  }
                }

                @Override
                public void removeUpdate(DocumentEvent e) {}

                @Override
                public void changedUpdate(DocumentEvent e) {}
              });

      constraint.weightx = 1;
      constraint.weighty = 0;
      constraint.gridx = 1;
      constraint.gridy = 0;
      constraint.gridwidth = 1;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(websiteDataUrlTextField, constraint);
    }

    {
      browserEngineLabel = new JLabel("Browser engine:");

      constraint.weightx = 0;
      constraint.weighty = 0;
      constraint.gridx = 0;
      constraint.gridy = 1;
      constraint.gridwidth = 1;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(browserEngineLabel, constraint);
    }

    {
      String[] values = new String[] {"HtmlUnit", "Ui4j", "JxBrowser"};
      browserEngineComboBox = new JComboBox<>(values);
      browserEngineComboBox.setSelectedIndex(2);

      constraint.weightx = 1;
      constraint.weighty = 0;
      constraint.gridx = 1;
      constraint.gridy = 1;
      constraint.gridwidth = 1;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(browserEngineComboBox, constraint);
    }

    {
      parserLabel = new JLabel("Website parser:");

      constraint.weightx = 0;
      constraint.weighty = 0;
      constraint.gridx = 0;
      constraint.gridy = 2;
      constraint.gridwidth = 1;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(parserLabel, constraint);
    }

    {
      String[] values = new String[] {"Motel6", "RedRoof", "RedLion"};
      parserComboBox = new JComboBox<>(values);
      parserComboBox.setSelectedIndex(0);

      constraint.weightx = 1;
      constraint.weighty = 0;
      constraint.gridx = 1;
      constraint.gridy = 2;
      constraint.gridwidth = 1;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(parserComboBox, constraint);
    }

    {
      scrapeButton = new JButton("Scrape website");

      constraint.weightx = 1;
      constraint.weighty = 0;
      constraint.gridx = 0;
      constraint.gridy = 3;
      constraint.gridwidth = 2;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(scrapeButton, constraint);
    }

    {
      outputTextArea = new JTextArea();
      outputTextArea.setEditable(false);
      outputTextArea.setWrapStyleWord(false);
      outputTextArea.setAutoscrolls(true);

      JScrollPane scrollPane = new JScrollPane(outputTextArea);
      scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
      scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
      scrollPane.setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));

      constraint.weightx = 1;
      constraint.weighty = 1;
      constraint.gridx = 0;
      constraint.gridy = 4;
      constraint.gridwidth = 2;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(scrollPane, constraint);
    }

    {
      progressBar = new JProgressBar();
      progressBar.setString(progressBarTextPrefix);
      progressBar.setStringPainted(true);
      progressBar.setIndeterminate(true);
      progressBar.setVisible(false);

      constraint.weightx = 1;
      constraint.weighty = 0;
      constraint.gridx = 0;
      constraint.gridy = 5;
      constraint.gridwidth = 2;
      constraint.gridheight = 1;
      constraint.fill = GridBagConstraints.BOTH;
      this.add(progressBar, constraint);
    }
  }
Ejemplo n.º 10
0
  /** Initialize the contents of the frame. */
  private void initialize() {
    frame = new JFrame();
    frame.setBounds(10, 10, 760, 430);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.getContentPane().setLayout(null);
    frame.setTitle("Client");

    // JScrollPane 是 JTextArea 的容器
    textArea = new JTextArea();
    textArea.setEditable(false);
    textArea.setBackground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);

    scrollPane = new JScrollPane(textArea);
    scrollPane.setAutoscrolls(true);
    scrollPane.setAutoscrolls(true);
    // JScrollPane 是 JTextArea 的容器
    textArea_Chat = new JTextArea();
    textArea_Chat.setEditable(false);
    textArea_Chat.setBackground(Color.LIGHT_GRAY);
    textArea_Chat.setAutoscrolls(true);

    scrollPane_Chat = new JScrollPane(textArea_Chat);
    scrollPane_Chat.setAutoscrolls(true);
    scrollPane_Chat.setAutoscrolls(true);
    tabbedPane_Info = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane_Info.setBounds(10, 10, 500, 300);
    frame.getContentPane().add(tabbedPane_Info);

    tabbedPane_Info.addTab("信息", null, scrollPane, null);
    tabbedPane_Info.addTab("会话", null, scrollPane_Chat, null);
    tabbedPane_Info.setSelectedComponent(scrollPane_Chat); // 客户端默认只显示会话信息

    // JList 是 DefaultListModel 的容器
    defaultListModel_online = new DefaultListModel();
    defaultListModel_online.addElement("在线用户列表");
    list_online = new JList(defaultListModel_online);
    list_online.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list_online.setBackground(Color.LIGHT_GRAY);
    list_online.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent arg0) {
            //				int index=list.getSelectedIndex();
            //				String string_ListModel=defaultListModel.elementAt(index).toString();
            //				String temp[]=string_ListModel.split(":");
            //				String clientID=temp[0];
            //				String clientName=temp[1];
            //
            //	textArea_recieverID.setText(clientID+":"+clientName+":"+"["+Integer.toString(index)+"]");

            int index = list_online.getSelectedIndex();
            String string_ID_Name =
                network_Client.get_Client_ID_Name_from_Str_Online_By_Index(index);
            textArea_recieverID.setText(string_ID_Name + ":" + "[" + Integer.toString(index) + "]");
          }
        });
    list_online.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {}
        });

    scrollPane_online = new JScrollPane(list_online);
    scrollPane_online.setAutoscrolls(true);
    scrollPane_online.setAutoscrolls(true);
    // JList 是 DefaultListModel 的容器
    defaultListModel_reg = new DefaultListModel();
    defaultListModel_reg.addElement("注册用户列表");
    list_reg = new JList(defaultListModel_reg);
    list_reg.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    list_reg.setBackground(Color.LIGHT_GRAY);
    list_reg.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {
            //				int index=list_reg.getSelectedIndex();
            //				String string_ListModel=defaultListModel_reg.elementAt(index).toString();
            //				String temp[]=string_ListModel.split(":");
            //				String clientID=temp[0];
            //				String clientName=temp[1];
            //
            //	textArea_recieverID.setText(clientID+":"+clientName+":"+"["+Integer.toString(index)+"]");

            int index = list_reg.getSelectedIndex();
            String string_ID_Name = network_Client.get_Client_ID_Name_from_Str_Reg_By_Index(index);
            textArea_recieverID.setText(string_ID_Name + ":" + "[" + Integer.toString(index) + "]");
          }
        });
    list_reg.addListSelectionListener(
        new ListSelectionListener() {
          @Override
          public void valueChanged(ListSelectionEvent e) {}
        });

    scrollPane_reg = new JScrollPane(list_reg);
    scrollPane_reg.setAutoscrolls(true);
    scrollPane_reg.setAutoscrolls(true);
    tabbedPane_List = new JTabbedPane(JTabbedPane.TOP);
    tabbedPane_List.setBounds(520, 10, 220, 300);
    frame.getContentPane().add(tabbedPane_List);

    tabbedPane_List.addTab("在线用户", null, scrollPane_online, null);
    tabbedPane_List.addTab("注册用户", null, scrollPane_reg, null);
    textField_send = new JTextField();
    textField_send.setBounds(10, 320, 380, 30);
    frame.getContentPane().add(textField_send);
    textField_send.setColumns(10);
    // textField_send.setText("这是一个客户端单播测试");

    button_send = new JButton("发送明文");
    button_send.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // textField_send.setText(msg_send.recieverID);//测试获取的 recieverID OK

            Msg msg_send = new Msg(Msg_Type.chat);
            msg_send.msg_Content = textField_send.getText();
            msg_send.senderID = network_Client.login_Info.id_login;
            msg_send.recieverID = get_ReceiverID_from_textArea_recieverID(); // 此函数中【判断接收者是否为空】

            msg_send.senderName = network_Client.client_Info_Local.Name;
            msg_send.recieverName = get_ReceiverName_from_textArea_recieverID();

            if (!msg_send.recieverID.equals("")) // 【接收者】不为空才发送消息
            {
              // 先在本地显示
              String str_chat =
                  "["
                      + msg_send.senderID
                      + ":"
                      + msg_send.senderName
                      + "]对["
                      + msg_send.recieverID
                      + ":"
                      + msg_send.recieverName
                      + "]说 : "
                      + msg_send.msg_Content;
              show(str_chat);
              show_Chat(str_chat);
              // 再发送至服务器
              network_Client.send_Msg(msg_send); // 发送聊天信息
            } else {
              // 提示【接收者】为空//已经提示过了
              // network_Client.show_Inf_UI_Dialog("请指定消息接收对象");
            }
            textField_send.setText(""); // 输入框清空
            frame.getRootPane().setDefaultButton(button_send); // 按钮获取焦点
          }
        });
    button_send.setBounds(410, 320, 100, 30);
    frame.getContentPane().add(button_send);

    textField_send_codec = new JTextField();
    textField_send_codec.setBounds(10, 360, 380, 30);
    frame.getContentPane().add(textField_send_codec);
    textField_send_codec.setColumns(10);
    textField_send_codec.setText("这是一个客户端单播测试");
    textField_send_codec.setText("ILOVEYOUTOO");

    button_send_codec = new JButton("发送密文");
    button_send_codec.addMouseListener(
        new MouseAdapter() {
          @Override
          public void mouseClicked(MouseEvent e) {}
        });
    button_send_codec.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            // (1)先检查本地密钥 key_Codec_Local 是否已经设置 未设置时值为 "$"
            // if(network_Client.key_Codec_Local.equals("$"))
            if (network_Client.key_Codec_Local == null) {
              // network_Client.show_UI_Dialog("编码策略尚未设置,请在[更新用户信息]中设置并通告服务器");
              network_Client.show_Msg("", "编码策略尚未设置,请在[更新用户信息]中设置并通告服务器");
            } else {
              // (2)再检测接受者是否为空
              if (!get_ReceiverID_from_textArea_recieverID().equals("")) // 【接收者】不为空才发送消息
              {
                // (3)再检查密钥策略是否合法
                if (network_Client.codec.check_codepolicy(network_Client.key_Codec_Local)) {
                  // 这才能建立消息 msg_send
                  Msg msg_send = new Msg();
                  msg_send.msg_Type = Msg_Type.chat_codec;
                  msg_send.senderID = network_Client.login_Info.id_login;
                  msg_send.recieverID =
                      get_ReceiverID_from_textArea_recieverID(); // 此函数中【判断接收者是否为空】
                  msg_send.senderName = network_Client.client_Info_Local.Name;
                  msg_send.recieverName = get_ReceiverName_from_textArea_recieverID();
                  msg_send.key_Codec = network_Client.key_Codec_Local;

                  msg_send.msg_Content =
                      network_Client.codec.Code(
                          network_Client.key_Codec_Local,
                          textField_send_codec.getText()); // 编码里边有检测过滤信息内容的功能

                  // 先在本地显示
                  // String str_chat="["+msg_send.senderID+"]对["+msg_send.recieverID+"]说 :
                  // "+msg_send.msg_Content;
                  String str_chat =
                      "["
                          + msg_send.senderID
                          + ":"
                          + msg_send.senderName
                          + "]对["
                          + msg_send.recieverID
                          + ":"
                          + msg_send.recieverName
                          + "]说 : "
                          + textField_send_codec.getText()
                          + "[已加密]";

                  show(str_chat);
                  show("发送密文: " + msg_send.msg_Content);
                  show_Chat(str_chat);

                  // 再发送至服务器
                  network_Client.send_Msg(msg_send); // 发送聊天信息

                  // textField_send_codec.setText("");//输入框清空
                  textField_send_codec.requestFocusInWindow(); // 输入框获取焦点
                } else {
                  // network_Client.show_UI_Dialog("加密策略不合法");
                  network_Client.show_Msg("", "加密策略不合法");
                }
              } else {
                // 提示【接收者】为空//已经提示过了
                // network_Client.show_Inf_UI_Dialog("请指定消息接收对象");
              }
            }
            textField_send_codec.setText(""); // 输入框清空
            frame.getRootPane().setDefaultButton(button_send_codec); // 按钮获取焦点
          }
        });
    button_send_codec.setBounds(410, 360, 100, 30);
    frame.getContentPane().add(button_send_codec);

    textArea_recieverID = new JTextArea();
    textArea_recieverID.setEditable(false);
    textArea_recieverID.setBackground(Color.LIGHT_GRAY);
    textArea_recieverID.setAutoscrolls(true);
    textArea_recieverID.setBounds(520, 320, 220, 30);
    // textArea_recieverID.setText("接收者");
    frame.getContentPane().add(textArea_recieverID);
    button_Edit = new JButton("更新用户信息");
    button_Edit.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            network_Client.on_Btn_Edit();
          }
        });
    button_Edit.setBounds(520, 360, 220, 30);
    frame.getContentPane().add(button_Edit);
    // 初始状态让 [发送明文按钮]获取焦点
    frame.getRootPane().setDefaultButton(button_send); // 按钮获取焦点
  }
Ejemplo n.º 11
0
  public JChat() {
    this.setSize(500, 600);
    this.setResizable(false);
    this.setLayout(new BorderLayout());

    JPanel topPanel = new JPanel();
    topPanel.setLayout(new GridLayout(2, 1));

    // set up buttons
    openChat = new JButton("Open to chat");
    openChat.addActionListener(new OpenChat());
    chatWith = new JButton("Chat with");
    chatWith.addActionListener(new ChatWith());
    send = new JButton("send");
    send.addActionListener(new Send());
    send.setEnabled(false);
    InputMap inputMap = send.getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW);
    KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    inputMap.put(enter, "ENTER");
    send.getActionMap().put("ENTER", new ClickAction(send));

    // set up labels
    pickPort = new JLabel();
    pickPort.setText("Pick your port number:");
    desPort = new JLabel();
    desPort.setText("Or enter a destinaltion port number:");

    // set up text fields
    pickText = new JTextField();
    pickText.setPreferredSize(new Dimension(150, 30));
    desText = new JTextField();
    desText.setPreferredSize(new Dimension(150, 30));
    chatText = new JTextField();
    chatText.setPreferredSize(new Dimension(400, 30));
    chatText.setEnabled(false);

    JPanel top1 = new JPanel();
    top1.add(pickPort);
    top1.add(pickText);
    top1.add(openChat);

    JPanel top2 = new JPanel();
    top2.add(desPort);
    top2.add(desText);
    top2.add(chatWith);

    topPanel.add(top1);
    topPanel.add(top2);

    chatField = new JTextArea();
    chatField.setAutoscrolls(true);
    chatField.setDragEnabled(true);
    chatField.setEditable(false);
    chatField.setAlignmentY(TOP_ALIGNMENT);

    JPanel bottomPanel = new JPanel();
    bottomPanel.add(chatText);
    bottomPanel.add(send);

    this.add(topPanel, BorderLayout.NORTH);
    this.add(chatField, BorderLayout.CENTER);
    this.add(bottomPanel, BorderLayout.SOUTH);

    this.setVisible(true);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
Ejemplo n.º 12
0
  public TriUMQueryGUI(String fixUserId) {
    if (fixUserId == null || fixUserId.length() == 0) this.fixUserId = null;
    else this.fixUserId = fixUserId;

    JPanel mainPane = new JPanel();
    mainPane.setLayout(new BoxLayout(mainPane, BoxLayout.Y_AXIS));
    //
    mainPane.add(createRowPanel(new JLabel("ENTER NECESSARY PARAMETERS:"), new JLabel("")));
    //
    protocol = new JComboBox(new String[] {"rmi", "soap", "http", "socket"});
    protocol.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            String protocol = e.getItem().toString().toLowerCase();
            if (protocol.equals("rmi")) port.setText(String.valueOf(TriUMQuery.RMI_QUERY_PORT));
            else if (protocol.equals("soap"))
              port.setText(String.valueOf(TriUMQuery.SOAP_QUERY_PORT));
            else if (protocol.equals("http"))
              port.setText(String.valueOf(TriUMQuery.HTTP_SERVICE_PORT));
            else if (protocol.equals("socket"))
              port.setText(String.valueOf(TriUMQuery.COMMUNICATE_SOCKET_SERVICE_PORT));
          }
        });
    mainPane.add(createRowPanel(new JLabel("Protocol:"), protocol));
    //
    host = new JTextField(TEXT_FIELD_COLUMNS);
    host.setText("localhost");
    mainPane.add(createRowPanel(new JLabel("Host:"), host));
    //
    port = new JTextField(TEXT_FIELD_COLUMNS);
    port.setText(String.valueOf(TriUMQuery.RMI_QUERY_PORT));
    mainPane.add(createRowPanel(new JLabel("Port:"), port));
    //
    type =
        new JComboBox(
            new QueryType[] {
              new QueryType("personalinfo", "Personal Information"),
              new QueryType("conceptinfo", "Concept Information"),
              new QueryType("studytime", "Study Time"),
              new QueryType("overlay", "Overlay Model"),
              new QueryType("bayes", "Static Bayesian Model"),
              new QueryType("dynbayes", "Dynamic Bayesian Model"),
              new QueryType("learningstyle", "Learning Style"),
              new QueryType("prerecommend", "Pre-recommended Concepts"),
              new QueryType("postrecommend", "Post-recommended Concepts"),
              new QueryType("learningpath", "Learning Path"),
              new QueryType("community", "User Community"),
              new QueryType("interest", "User Interest"),
              new QueryType("userreport", "User Report"),
              new QueryType("feedbackreport", "Feedback Report"),
              new QueryType("totalreport", "Total Report"),
              new QueryType("mlreg", "Register Mailing List"),
              new QueryType("mlunreg", "Unregister Mailing List")
            });
    type.setSelectedIndex(0);
    mainPane.add(createRowPanel(new JLabel("Query type:"), type));
    //
    userid = new JTextField(TEXT_FIELD_COLUMNS);
    if (fixUserId == null) userid.setText("guest");
    else {
      userid.setText(fixUserId);
      userid.setEditable(false);
    }
    mainPane.add(createRowPanel(new JLabel("User ID:"), userid));
    //
    JPanel coursePanel = new JPanel();
    coursePanel.setLayout(new BoxLayout(coursePanel, BoxLayout.X_AXIS));
    course = new JComboBox();
    course.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            try {
              String course = e.getItem().toString().toLowerCase();
              TriUMQuery query =
                  TriUMQueryClientUtil.getTriUMQuery(
                      TriUMQuery.RMI_DEFAULT_QUERY_HOST, TriUMQuery.RMI_QUERY_PORT);
              ArrayList<String> conceptList = query.listBriefConcepts(course);
              concept.setModel(new DefaultComboBoxModel(conceptList.toArray()));
            } catch (RemoteException ex) {
              ex.printStackTrace();
            }
          }
        });
    JButton getCourseList =
        new JButton(
            new AbstractAction("Get") {
              private static final long serialVersionUID = 1L;

              public void actionPerformed(ActionEvent e) {
                try {
                  TriUMQuery query =
                      TriUMQueryClientUtil.getTriUMQuery(
                          TriUMQuery.RMI_DEFAULT_QUERY_HOST, TriUMQuery.RMI_QUERY_PORT);
                  ArrayList<String> courseList = query.listCourses();
                  course.setModel(new DefaultComboBoxModel(courseList.toArray()));
                  if (courseList.size() > 0) {
                    course.setSelectedIndex(0);
                    ArrayList<String> conceptList = query.listBriefConcepts(courseList.get(0));
                    concept.setModel(new DefaultComboBoxModel(conceptList.toArray()));
                  }
                } catch (RemoteException ex) {
                  ex.printStackTrace();
                }
              }
            });
    coursePanel.add(course);
    coursePanel.add(getCourseList);
    mainPane.add(createRowPanel(new JLabel("Course:"), coursePanel));
    //
    concept = new JComboBox();
    mainPane.add(createRowPanel(new JLabel("Concept:"), concept));
    //
    JButton query =
        new JButton(
            new AbstractAction("QUERY") {
              private static final long serialVersionUID = 1L;

              public void actionPerformed(ActionEvent e) {
                onQueryGUI();
              }
            });
    JButton clear =
        new JButton(
            new AbstractAction("CLEAR") {
              private static final long serialVersionUID = 1L;

              public void actionPerformed(ActionEvent e) {
                clearResult();
              }
            });
    mainPane.add(createRowPanel(query, clear));
    //
    knowledge = new JTextField(TEXT_FIELD_COLUMNS);
    knowledge.setAutoscrolls(true);
    knowledge.setEditable(false);
    mainPane.add(createRowPanel(new JLabel("Knowledge:"), knowledge));
    //
    ls = new JTextField(TEXT_FIELD_COLUMNS);
    ls.setAutoscrolls(true);
    ls.setEditable(false);
    mainPane.add(createRowPanel(new JLabel("Learning Style:"), ls));
    //
    prerec = new JTextField(TEXT_FIELD_COLUMNS);
    prerec.setAutoscrolls(true);
    prerec.setEditable(false);
    mainPane.add(createRowPanel(new JLabel("Pre-recommended Concepts:"), prerec));
    //
    postrec = new JTextField(TEXT_FIELD_COLUMNS);
    postrec.setAutoscrolls(true);
    postrec.setEditable(false);
    mainPane.add(createRowPanel(new JLabel("Post-recommended Concepts:"), postrec));
    //
    lp = new JTextField(TEXT_FIELD_COLUMNS);
    lp.setAutoscrolls(true);
    lp.setEditable(false);
    mainPane.add(createRowPanel(new JLabel("Learning Path:"), lp));
    //
    community = new JTextField(TEXT_FIELD_COLUMNS);
    community.setMaximumSize(new Dimension(400, 10));
    community.setAutoscrolls(true);
    community.setEditable(false);
    mainPane.add(createRowPanel(new JLabel("Community:"), community));
    //
    studytime = new JTextField(TEXT_FIELD_COLUMNS);
    studytime.setAutoscrolls(true);
    studytime.setEditable(false);
    mainPane.add(createRowPanel(new JLabel("Study Time:"), studytime));
    //
    docclass = new JTextField(TEXT_FIELD_COLUMNS);
    docclass.setAutoscrolls(true);
    docclass.setEditable(false);
    mainPane.add(createRowPanel(new JLabel("Interest/DocClass:"), docclass));
    //
    infoTable = new JTable();
    infoTable.setAutoscrolls(true);
    mainPane.add(createRowPanel(new JLabel("Info:"), new JScrollPane(infoTable)));

    // Msg
    msg = new JTextArea(10, TEXT_FIELD_COLUMNS);
    msg.setLineWrap(true);
    msg.setAutoscrolls(true);
    msg.setEditable(false);

    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    splitPane.setDividerLocation(500);
    splitPane.add(mainPane, JSplitPane.TOP);
    splitPane.add(new JScrollPane(msg), JSplitPane.BOTTOM);
    this.setLayout(new BorderLayout());
    this.add(splitPane, BorderLayout.CENTER);
    this.setSize(500, 650);
  }
Ejemplo n.º 13
0
  public void initComponents() {
    setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
    setBounds(100, 100, 902, 597);
    contentPane = new JPanel();
    contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
    setContentPane(contentPane);
    contentPane.setLayout(null);

    panel_4 = new JPanel();
    panel_4.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Geral",
            TitledBorder.LEFT,
            TitledBorder.TOP,
            null,
            null));
    panel_4.setBounds(10, 11, 426, 236);
    contentPane.add(panel_4);
    panel_4.setLayout(null);

    lblModeloDoAutomato = new JLabel("Defini\u00E7\u00E3o do Automato:");
    lblModeloDoAutomato.setBounds(10, 47, 125, 14);
    panel_4.add(lblModeloDoAutomato);

    JScrollPane scrollPane_2 = new JScrollPane();
    scrollPane_2.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane_2.setBounds(10, 72, 406, 124);
    panel_4.add(scrollPane_2);

    textArea = new JTextArea();
    textArea.setColumns(100);
    scrollPane_2.setColumnHeaderView(textArea);
    textArea.setAutoscrolls(true);
    textArea.setRows(9);

    JButton btnMinimizar = new JButton("Minimizar");
    btnMinimizar.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent arg0) {
            minimizarAutomato();
          }
        });
    btnMinimizar.setBounds(10, 207, 104, 23);
    panel_4.add(btnMinimizar);

    JPanel panel = new JPanel();
    panel.setBounds(10, 15, 250, 25);
    panel_4.add(panel);
    panel.setBorder(null);
    panel.setLayout(null);

    JLabel lblNome = new JLabel("Criar estado:");
    lblNome.setBounds(10, 5, 82, 14);
    panel.add(lblNome);
    lblNome.setHorizontalAlignment(SwingConstants.CENTER);

    isfinal = new JCheckBox("Final");
    isfinal.setBounds(98, 1, 56, 23);
    panel.add(isfinal);

    btnNovo = new JButton("Novo");
    btnNovo.setBounds(160, 1, 73, 23);
    panel.add(btnNovo);
    btnNovo.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            novoEstado();
          }
        });

    JPanel panel_5 = new JPanel();
    panel_5.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Visualiza\u00E7\u00E3o",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_5.setBounds(10, 258, 1310, 390);
    contentPane.add(panel_5);
    panel_5.setLayout(null);

    painelView = new JPanelVisualizacao(this);
    painelView.setBounds(10, 22, 1290, 357);
    panel_5.add(painelView);

    JPanel panel_2 = new JPanel();
    panel_2.setBounds(558, 11, 314, 251);
    contentPane.add(panel_2);
    panel_2.setLayout(null);

    lblNewLabel = new JLabel("Detalhes de ");
    lblNewLabel.setBounds(10, 11, 152, 14);
    panel_2.add(lblNewLabel);

    cbisFinal = new JCheckBox("Final");
    cbisFinal.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent arg0) {
            turnFinal();
          }
        });
    cbisFinal.setBounds(168, 7, 60, 23);
    panel_2.add(cbisFinal);

    btnExcluir = new JButton("Excluir");
    btnExcluir.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            excluirEstado();
          }
        });
    btnExcluir.setBounds(231, 7, 73, 23);
    panel_2.add(btnExcluir);

    panel_3 = new JPanel();
    panel_3.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Transi\u00E7\u00F5es",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_3.setBounds(10, 36, 294, 204);
    panel_2.add(panel_3);
    panel_3.setLayout(null);

    JLabel lblSimbolo = new JLabel("Simbolo:");
    lblSimbolo.setBounds(10, 29, 96, 14);
    panel_3.add(lblSimbolo);

    cbAlfabeto = new JComboBox();
    cbAlfabeto.setBounds(122, 26, 49, 20);
    panel_3.add(cbAlfabeto);

    JLabel lblEstadosDestinos = new JLabel("Estados Destinos:");
    lblEstadosDestinos.setBounds(10, 57, 96, 14);
    panel_3.add(lblEstadosDestinos);

    cbEstadosDestinos = new JComboBox();
    cbEstadosDestinos.setBounds(122, 54, 49, 20);
    panel_3.add(cbEstadosDestinos);

    JScrollPane scrollPane_1 = new JScrollPane();
    scrollPane_1.setBounds(10, 82, 274, 111);
    panel_3.add(scrollPane_1);

    tblTrans = new JTable();
    scrollPane_1.setViewportView(tblTrans);

    btnNova = new JButton("Nova");
    btnNova.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            novaTransicao();
          }
        });
    btnNova.setBounds(181, 25, 89, 23);
    panel_3.add(btnNova);

    btnRemover = new JButton("Remover");
    btnRemover.addActionListener(
        new ActionListener() {

          @Override
          public void actionPerformed(ActionEvent e) {
            removerTransicao();
          }
        });
    btnRemover.setBounds(181, 53, 89, 23);
    panel_3.add(btnRemover);

    JPanel panel_1 = new JPanel();
    panel_1.setBorder(
        new TitledBorder(
            new LineBorder(new Color(0, 0, 0)),
            "Estados",
            TitledBorder.LEADING,
            TitledBorder.TOP,
            null,
            null));
    panel_1.setBounds(446, 11, 102, 236);
    contentPane.add(panel_1);
    panel_1.setLayout(null);

    JScrollPane scrollPane = new JScrollPane();
    scrollPane.setBounds(10, 26, 82, 199);
    panel_1.add(scrollPane);

    tblEstados = new JTable();
    scrollPane.setViewportView(tblEstados);
    tblEstados.addMouseListener(
        new MouseAdapter() {

          @Override
          public void mouseClicked(MouseEvent arg0) {
            selecionaEstadoAtual(a.getEstados().get(tblEstados.getSelectedRow()));
          }
        });
    tblEstados.setAutoscrolls(true);
    tblEstados.add(new Scrollbar());
  }
Ejemplo n.º 14
0
  private void initializeComponents() {
    this.setTitle("Synchro - Kopierassistent");
    this.setBounds(0, 0, 550, 600);

    this.setResizable(true);
    this.setLayout(null);
    this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    this.addWindowListener(this);

    mainPanel = new JPanel();
    mainPanel.setBounds(0, 0, this.getWidth() - 20, 25);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    mainPanel.setLayout(null);

    btnBackup = new JButton("Backup");
    btnBackup.setBounds(this.getWidth() / 2, 0, this.getWidth() / 2 - 20, mainPanel.getHeight());
    btnBackup.addActionListener(this);
    mainPanel.add(btnBackup);

    this.add(mainPanel);

    fcPanel = new JPanel();
    fcPanel.setBounds(10, 40, this.getWidth(), 260);
    // fcPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    fcPanel.setLayout(null);

    quellLabel = new JLabel("Bitte Quellverzeichnis auswählen");
    quellLabel.setBounds(10, 5, 320, 20);
    fcPanel.add(quellLabel);

    quellListModel = new DefaultListModel<>();
    quellJList = new JList<ListItem>(quellListModel);
    quellJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    quellJList.setLayoutOrientation(JList.VERTICAL);
    quellJList.addListSelectionListener(this);

    listBoxScroller = new JScrollPane(quellJList);
    listBoxScroller.setBounds(0, 30, 315, 100);
    fcPanel.add(listBoxScroller);

    btnQAuswahl = new JButton("Quellverz. hinzufügen");
    btnQAuswahl.setBounds(320, 30, 200, 25);
    btnQAuswahl.addActionListener(this);
    fcPanel.add(btnQAuswahl);
    btnQEntfernen = new JButton("Quellverz. entfernen");
    btnQEntfernen.setBounds(320, 60, 200, 25);
    btnQEntfernen.addActionListener(this);
    fcPanel.add(btnQEntfernen);

    zielLabel = new JLabel("Bitte Zielverzeichnis auswählen");
    zielLabel.setBounds(10, 135, 320, 20);
    fcPanel.add(zielLabel);

    zielListModel = new DefaultListModel<>();
    zielJList = new JList<ListItem>(zielListModel);
    zielJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    zielJList.setLayoutOrientation(JList.VERTICAL);
    zielJList.addListSelectionListener(this);

    listBoxScroller2 = new JScrollPane(zielJList);
    listBoxScroller2.setBounds(0, 160, 315, 100);
    fcPanel.add(listBoxScroller2);

    btnZAuswahl = new JButton("Zielverz. hinzufügen");
    btnZAuswahl.setBounds(320, 160, 200, 25);
    btnZAuswahl.addActionListener(this);
    fcPanel.add(btnZAuswahl);
    btnZEntfernen = new JButton("Zielverz. entfernen");
    btnZEntfernen.setBounds(320, 190, 200, 25);
    btnZEntfernen.addActionListener(this);
    fcPanel.add(btnZEntfernen);
    this.add(fcPanel);

    ButtonGroup bGrp = new ButtonGroup();

    optionPanel = new JPanel();
    optionPanel.setBounds(10, 300 + 10, this.getWidth() - 40, 90);
    optionPanel.setPreferredSize(new Dimension(this.getWidth() - 40, 90));
    // optionPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    optionPanel.setLayout(new GridLayout(3, 1));

    nUebSchr = new JRadioButton("Keine Dateien überschreiben");
    nUebSchr.addItemListener(this);
    bGrp.add(nUebSchr);
    optionPanel.add(nUebSchr);

    ueSchr = new JRadioButton("Neuere Dateien überschreiben");
    ueSchr.addItemListener(this);
    bGrp.add(ueSchr);
    optionPanel.add(ueSchr);

    aUeSchr = new JRadioButton("Alle Dateien überschreiben");
    aUeSchr.addItemListener(this);
    bGrp.add(aUeSchr);
    optionPanel.add(aUeSchr);

    this.add(optionPanel);

    syncPanel = new JPanel();
    syncPanel.setBounds(
        10, optionPanel.getY() + optionPanel.getHeight() + 10, this.getWidth() - 30, 25);
    // syncPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
    syncPanel.setLayout(new BorderLayout());

    btnSync = new JButton("Sync it!");
    btnSync.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnSync.addActionListener(this);
    btnSync.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnSync.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    syncPanel.add(btnSync, BorderLayout.LINE_START);

    btnAbbruch = new JButton("Abbrechen");
    btnAbbruch.setBounds(0, 0, 150, (syncPanel.getHeight() / 3));
    btnAbbruch.addActionListener(this);
    btnAbbruch.setPreferredSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setMaximumSize(new Dimension(150, (syncPanel.getHeight() / 3)));
    btnAbbruch.setVisible(false);
    syncPanel.add(btnAbbruch, BorderLayout.LINE_END);

    progressBar = new JProgressBar(JProgressBar.HORIZONTAL);
    progressBar.setBorderPainted(true);
    progressBar.setPreferredSize(new Dimension(300, (syncPanel.getHeight() / 3)));
    progressBar.setForeground(Color.RED);
    progressBar.setStringPainted(true);
    progressBar.setVisible(true);
    syncPanel.add(progressBar, BorderLayout.CENTER);
    this.add(syncPanel);

    logPanel = new JPanel();
    logPanel.setBounds(
        10, syncPanel.getY() + syncPanel.getHeight() + 10, this.getWidth() - 30, 105);
    logPanel.setLayout(new BorderLayout());

    textArea = new JTextArea();
    textArea.setMargin(new Insets(3, 3, 3, 3));
    textArea.setBackground(Color.black);
    textArea.setForeground(Color.LIGHT_GRAY);
    textArea.setAutoscrolls(true);
    textArea.setFocusable(false);
    textAreaScroller = new JScrollPane(textArea);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    textAreaScroller.setBounds(0, 0, syncPanel.getWidth(), 50);

    logPanel.add(textAreaScroller, BorderLayout.CENTER);
    this.add(logPanel, BorderLayout.SOUTH);
  }
Ejemplo n.º 15
0
  public void setInputPanel() throws IOException {
    final String newline = "\n";
    final JTextArea log = new JTextArea(2, 28);

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    input.setLayout(gridbag);

    // Create the log first, because the action listeners
    // need to refer to it.

    log.setMargin(new Insets(1, 1, 1, 1));
    log.setEditable(false);
    JScrollPane logScrollPane = new JScrollPane(log);

    // Create a file chooser
    final JFileChooser fc = new JFileChooser();

    // Create the open button
    ImageIcon openIcon = new ImageIcon("Images/open.gif");
    JButton openButton = new JButton("Open a File...", openIcon);
    openButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int returnVal = fc.showOpenDialog(prologApplet.this);

            if (returnVal == JFileChooser.APPROVE_OPTION) {
              File file = fc.getSelectedFile();
              String name = file.getName();
              String path = file.getAbsolutePath();
              try {
                FileInputStream inps = new FileInputStream(path);
                ch = 0;
                ss = "";
                while (ch != -1) {
                  ch = inps.read();
                  ss = ss + (char) ch;
                }
                inps.close();
              } catch (Exception exc) {
                System.out.println("" + e);
              }
              code.selectAll();
              code.cut();
              code.append(ss);

              log.append("Opening: " + name + "." + newline);
            } else {
              log.append("Open command cancelled by user." + newline);
            }
          }
        });

    // Create the save button
    ImageIcon saveIcon = new ImageIcon("Images/save.gif");
    JButton saveButton = new JButton("Save a File...", saveIcon);
    saveButton.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            int returnVal = fc.showSaveDialog(prologApplet.this);

            if (returnVal == JFileChooser.APPROVE_OPTION) {
              File file = fc.getSelectedFile();
              // this is where a real application would save the file.
              log.append("Saving: " + file.getName() + "." + newline);
            } else {
              log.append("Save command cancelled by user." + newline);
            }
          }
        });

    // For layout purposes, put the buttons in a separate panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(openButton);
    buttonPanel.add(saveButton);

    // Explicitly set the focus sequence.
    // rimossi poichè deprecati
    // openButton.setNextFocusableComponent(saveButton);
    // saveButton.setNextFocusableComponent(openButton);

    // Add the buttons and the log to the frame
    // Container contentPane = getContentPane();
    // contentPane.add(buttonPanel, BorderLayout.NORTH);
    // contentPane.add(logScrollPane, BorderLayout.CENTER);

    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.NONE;
    gridbag.setConstraints(buttonPanel, c);
    input.add(buttonPanel);

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.NONE;
    gridbag.setConstraints(logScrollPane, c);
    input.add(logScrollPane);

    JLabel label1 = new JLabel("Codice:");
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.NONE;
    gridbag.setConstraints(label1, c);
    input.add(label1);

    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    gridbag.setConstraints(scrollPaneC, c);
    input.add(scrollPaneC);

    JLabel label2 = new JLabel("GOAL clause:");
    c.gridx = 0;
    c.gridy = 4;
    // c.weightx=1;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.NONE;
    gridbag.setConstraints(label2, c);
    input.add(label2);

    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    gridbag.setConstraints(gl, c);
    input.add(gl);

    c.gridx = 0;
    c.gridy = 6;
    c.weightx = 0.3;
    c.gridwidth = 1;
    gridbag.setConstraints(compile, c);
    input.add(compile);
    compile.addActionListener(this);

    c.gridx = 1;
    c.gridy = 6;
    c.weightx = 0.3;
    c.gridwidth = 1;
    gridbag.setConstraints(compileG, c);
    input.add(compileG);
    compileG.addActionListener(this);

    c.gridx = 2;
    c.gridy = 6;
    c.weightx = 0.3;
    c.gridwidth = 1;
    gridbag.setConstraints(run, c);
    input.add(run);
    run.addActionListener(this);

    Color c1 = new Color(166, 209, 241);
    code.setBackground(c1);
    code.setAutoscrolls(true);
    code.setEditable(true);

    /* mb1
     input.add(load);
     input.add(scrollPaneC); input.add(gl);
    */

    input.setBorder(BorderFactory.createEtchedBorder());
  }
Ejemplo n.º 16
-1
  private void initComponents() {
    accountNumberField = new JTextFieldEx();
    accountCodeField = new JIntegerField();
    nameField = new JTextFieldEx();
    bankIdField = new JTextFieldEx();
    nameField.setText(rb.getString("Word.Name"));
    descriptionField = new JTextFieldEx();
    descriptionField.setText(rb.getString("Word.Description"));
    currencyCombo = new CurrencyComboBox();
    securityButton = new JButton(rb.getString("Word.None"));

    // for preferred width so button does not force a wide layout
    securityButton.setPreferredSize(new Dimension(20, securityButton.getPreferredSize().height));

    accountTypeModel = new DefaultComboBoxModel<>(AccountType.values());
    accountTypeModel.removeElement(AccountType.ROOT);
    accountTypeCombo = new JComboBox<>(accountTypeModel);

    lockedCheckBox = new JCheckBox(rb.getString("Button.Locked"));
    placeholderCheckBox = new JCheckBox(rb.getString("Button.PlaceHolder"));
    hideCheckBox = new JCheckBox(rb.getString("Button.HideAccount"));
    excludeBudgetCheckBox = new JCheckBox(rb.getString("Button.ExcludeFromBudget"));
    parentButton = new JButton("Root");

    notesArea = new javax.swing.JTextArea();
    notesArea.setLineWrap(true);
    notesArea.setAutoscrolls(false);
    notesArea.setPreferredSize(new java.awt.Dimension(100, 80));

    accountTypeCombo.addActionListener(this);
    securityButton.addActionListener(this);
    parentButton.addActionListener(this);
  }