package relloc;
|
import java.awt.Color;
|
import java.awt.Container;
|
import java.awt.Dimension;
|
import java.awt.Font;
|
import java.awt.Toolkit;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowListener;
|
import javax.swing.ComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.JComboBox;
|
import javax.swing.JDialog;
|
import javax.swing.JPanel;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTextArea;
|
import javax.swing.JTextField;
|
import ColorAndFont.ChooseFont;
|
import ColorAndFont.UIColor;
|
import JNADell.Dell_usetaganchor;
|
import Method.ControTag;
|
import Method.GetNowTime;
|
import PbuliClass.JButtonModel;
|
import PbuliClass.ShowMessage;
|
import tag.Tag;
|
import tag.Tag_Dell;
|
import urt.Control_urt;
|
public class Sendmessage extends JDialog implements WindowListener {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
JTextField text=null;//Îı¾¿ò
|
JPanel mb=null;//ÉêÃ÷Ò»¸öÃæ°å
|
JButtonModel serch=null;//²éÕÒ±êÇ©
|
boolean sou=false;
|
JComboBox<String> tagAll=null;//ËùÓбêÇ©µÄ¼¯ºÏ
|
JTextArea textArea=null;
|
JScrollPane gd2=null;
|
|
/**»ñÈ¡¶Ô»°¿ò·½·¨*/
|
public Sendmessage(String title) {
|
super();
|
this.setAlwaysOnTop(true);//×ÜÊÇÖö¥
|
this.setTitle(title);
|
Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü
|
Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС
|
int width = (int) (screenSize.width* 0.5);// ¼ÆËã´°Ìåпí¶È
|
int height = (int) (screenSize.height * 0.5);// ¼ÆËã´°Ìåпí¶È
|
int w=500;
|
int h=350;
|
int x0=width-w/2;//´°Ìåx0×ø±ê
|
int y0=height-h/2;//´°Ìåy0×ø±ê
|
Container rq=getContentPane();
|
rq.add(getMb());
|
this.setBounds(x0, y0,w,h);
|
this.addWindowListener((WindowListener) this);
|
this.setVisible(true);
|
}
|
|
/**»ñÈ¡Ãæ°å*/
|
public JPanel getMb() {
|
if(mb==null){
|
mb=new JPanel();
|
mb.setLayout(null);
|
mb.setBackground(Color.white);
|
mb.add(gettext());
|
mb.add(getTagAll());
|
mb.add(getGd2());
|
int x=10;
|
int y=20;
|
int height=30;
|
tagAll.setBounds(x, y,100, height);
|
text.setBounds(x+120, y,250, height);
|
mb.add(getserch());
|
serch.setBounds(x+373, y,80, height);
|
gd2.setBounds(x, y+50,460, 200);
|
|
}
|
return mb;
|
}
|
|
public JTextField gettext() {
|
if(text==null) {
|
text=new JTextField(10);
|
text.setFont(ChooseFont.getFont(14));
|
text.setForeground(Color.red);
|
}
|
return text;
|
}
|
|
/**ËÑË÷°´Å¥*/
|
public JButtonModel getserch() {
|
if(serch==null) {
|
serch=new JButtonModel("·¢ËÍ");
|
serch.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
String tagid=(String) tagAll.getSelectedItem();
|
String message=text.getText();
|
if(message.length()<1) {
|
ShowMessage.zidingyi("Ï·¢ÄÚÈݲ»ÄÜΪ¿Õ");
|
return;
|
}
|
String a=GetNowTime.now2()+":"+tagid+","+message;
|
Tag tag=Tag_Dell.get_tag(tagid);
|
if(tag==null) {
|
ShowMessage.zidingyi(tagid+"²»´æÔÚgetserch");
|
return;
|
}
|
String tagtype=tag.getTagtype();
|
if(tagid.equals("ËùÓбêÇ©")) {
|
Dell_usetaganchor.alltagtomessge(message,"ϵͳĬÈÏ");
|
}else {
|
if(tagtype.equals("ÐÄÂÊ´øÆÁ")) {
|
Dell_usetaganchor.message_to_oled(tagid, message,"ϵͳĬÈÏ");
|
}else if(tagtype.equals("³µÔØ´øÆÁ")) {
|
Dell_usetaganchor.USERINFO(tagid, message);
|
}else if(tagtype.equals("ϵͳĬÈÏ")) {
|
ControTag.konghzitag(10, tagid,(byte)0x10,"Õñ¶¯","SendmessageÕð¶¯");
|
}else if(tagtype.equals("URT+CO")) {
|
Control_urt.say_voice(tagid, message,1,3);
|
}else if(tagtype.equals("ÈÚºÏÖÕ¶Ë")) {
|
Control_urt.say_voice(tagid, message,1,3);
|
ControTag.konghzitag(10, tagid,(byte)0x10,"Õñ¶¯","SendmessageÕð¶¯");
|
}else if (tagtype.equals("¹¤ÅÆ´øÆÁ")){
|
Dell_usetaganchor.message_to_Lora(tagid,message,"¹¤ÅÆ´øÆÁ","66");
|
}
|
else {
|
ControTag.konghzitag(10, tagid,(byte)0x10,"Õñ¶¯","SendmessageÕð¶¯");
|
}
|
}
|
textArea.append(a+"£¬±êÇ©ÀàÐÍ"+tagtype+"\n");
|
textArea.setCaretPosition(textArea.getText().length());
|
}
|
});
|
}
|
return serch;
|
}
|
|
|
@Override
|
public void windowOpened(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
|
}
|
|
@Override
|
public void windowClosing(WindowEvent e) {
|
|
}
|
|
@Override
|
public void windowClosed(WindowEvent e) {
|
|
|
}
|
|
@Override
|
public void windowIconified(WindowEvent e) {
|
}
|
|
@Override
|
public void windowDeiconified(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
|
}
|
|
@Override
|
public void windowActivated(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
|
}
|
|
@Override
|
public void windowDeactivated(WindowEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
|
}
|
|
public JComboBox<String> getTagAll() {
|
if(tagAll==null) {
|
tagAll=new JComboBox<String>() ;
|
tagAll.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
|
ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(Tag_Dell.GetTagAllstr());//ÏÂÀÁбíÄ£ÐÍ
|
tagAll.setModel(coModel);
|
tagAll.setEnabled(true);
|
//ÏÂÀ¿ò¿ÉÒÔÊäÈë
|
tagAll.setEditable(true);
|
}
|
return tagAll;
|
}
|
|
public JTextArea get_text_area() {
|
if(textArea==null) {
|
textArea=new JTextArea(10,10);
|
textArea.setBackground(UIColor.getNorth_color());
|
textArea.setForeground(UIColor.getTable_font());
|
textArea.setFont(ChooseFont.getFont(13));
|
}
|
return textArea;
|
}
|
|
/**»ñÈ¡¹ö¶¯Ãæ°å*/
|
public JScrollPane getGd2() {
|
if(gd2==null) {
|
gd2=new JScrollPane(get_text_area());
|
}
|
return gd2;
|
}
|
}
|