package com.iailab.netsdk.demo.frame; import com.sun.jna.Pointer; import com.iailab.netsdk.common.*; import com.iailab.netsdk.demo.module.*; import com.iailab.netsdk.lib.NetSDKLib; import com.iailab.netsdk.lib.ToolKits; import javax.swing.*; import javax.swing.border.EmptyBorder; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; import java.awt.*; import java.awt.event.*; import java.util.*; import java.util.List; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; /** * 人数统计事件 demo */ class HumanNumberStatisticFrame extends JFrame { private static final long serialVersionUID = 1L; /* * ç•Œé¢ã€SDKåˆå§‹åŒ–åŠç™»å½• */ public HumanNumberStatisticFrame() { setTitle(Res.string().getHumanNumberStatistic()); setLayout(new BorderLayout()); pack(); setSize(1080, 560); setResizable(false); setLocationRelativeTo(null); LoginModule.init(disConnectCB, haveReConnectCB); // 打开工程,SDKåˆå§‹åŒ–,注册æ–线和é‡è¿žå›žè°ƒå‡½æ•° try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } loginPanel = new LoginPanel(); humanStatisticPanel = new HumanStatisticPanel(); add(loginPanel, BorderLayout.NORTH); add(humanStatisticPanel, BorderLayout.CENTER); // 调用按钮登录事件 loginPanel.addLoginBtnActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (loginPanel.checkLoginText()) { if (login()) { mainFrame = ToolKits.getFrame(e); mainFrame.setTitle(Res.string().getHumanNumberStatistic() + " : " + Res.string().getOnline()); } } } }); // 调用按钮登出事件 loginPanel.addLogoutBtnActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { mainFrame.setTitle(Res.string().getHumanNumberStatistic()); logout(); } }); // 注册窗体清出事件 addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { RealPlayModule.stopRealPlay(m_hPlayHandle); // 退出å¥æŸ„ TargetRecognitionModule.renderPrivateData(m_hPlayHandle, 0); // å…³é—规则框 VideoStateSummaryModule.detachAllVideoStatSummary(); // 退订事件 LoginModule.logout(); // 退出 LoginModule.cleanup(); // å…³é—å·¥ç¨‹ï¼Œé‡Šæ”¾èµ„æº dispose(); // 返回主èœå• SwingUtilities.invokeLater(new Runnable() { public void run() { FunctionList demo = new FunctionList(); demo.setVisible(true); } }); } }); } /////////////////////////////// 登录相关 ////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // 设备æ–线通知回调 private static DisConnectCallBack disConnectCB = new DisConnectCallBack(); // 网络连接æ¢å¤ private static HaveReConnectCallBack haveReConnectCB = new HaveReConnectCallBack(); private Vector<String> chnList = new Vector<String>(); // 预览å¥æŸ„ public static NetSDKLib.LLong m_hPlayHandle = new NetSDKLib.LLong(0); // 设备æ–线回调: 通过 CLIENT_Init 设置该回调函数,当设备出现æ–线时,SDK会调用该函数 private static class DisConnectCallBack implements NetSDKLib.fDisConnect { public void invoke(NetSDKLib.LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) { System.out.printf("Device[%s] Port[%d] DisConnectCallBack!\n", pchDVRIP, nDVRPort); // æ–线æ示 SwingUtilities.invokeLater(new Runnable() { public void run() { mainFrame.setTitle(Res.string().getHumanNumberStatistic() + " : " + Res.string().getDisConnectReconnecting()); } }); } } // 网络连接æ¢å¤ï¼Œè®¾å¤‡é‡è¿žæˆåŠŸå›žè°ƒ // 通过 CLIENT_SetAutoReconnect 设置该回调函数,当已æ–线的设备é‡è¿žæˆåŠŸæ—¶ï¼ŒSDK会调用该函数 private static class HaveReConnectCallBack implements NetSDKLib.fHaveReConnect { public void invoke(NetSDKLib.LLong m_hLoginHandle, String pchDVRIP, int nDVRPort, Pointer dwUser) { System.out.printf("ReConnect Device[%s] Port[%d]\n", pchDVRIP, nDVRPort); // é‡è¿žæ示 SwingUtilities.invokeLater(new Runnable() { public void run() { mainFrame.setTitle(Res.string().getHumanNumberStatistic() + " : " + Res.string().getOnline()); } }); // æ–线åŽéœ€è¦é‡æ–°è®¢é˜… ExecutorService service = Executors.newSingleThreadExecutor(); service.execute(new Runnable() { @Override public void run() { if (b_RealPlay) { // 如果æ–å‰æ£åœ¨é¢„览 stopRealPlay(); // 退出预览 realPlay(); // é‡æ–°å¼€å¯é¢„览 } if (b_Attachment) { // 如果æ–å‰æ£åœ¨è®¢é˜… // é‡è®¢é˜…事件 VideoStateSummaryModule.reAttachAllVideoStatSummary(humanNumberStatisticCB); setAttachBtnTextEnable(); } } }); service.shutdown(); } } // 登录 public boolean login() { if (LoginModule.login(loginPanel.ipTextArea.getText(), Integer.parseInt(loginPanel.portTextArea.getText()), loginPanel.nameTextArea.getText(), new String(loginPanel.passwordTextArea.getPassword()))) { loginPanel.setButtonEnable(true); setButtonEnable(true); final int chanNum = LoginModule.m_stDeviceInfo.byChanNum; SwingUtilities.invokeLater(new Runnable() { public void run() { // 更新列表长度 int listSize = Math.max(chanNum, 32); groupListPanel.remove(scrollPane); groupListPanel.creatGroupInfoPanel(listSize); // 登陆æˆåŠŸï¼Œå°†é€šé“æ·»åŠ åˆ°æŽ§ä»¶ for (int i = 0; i < chanNum; i++) { chnList.add(Res.string().getChannel() + " " + String.valueOf(i + 1)); SummaryInfo summaryInfo = new SummaryInfo(); summaryInfo.nChannelID = i; EventDisplay.dataList.add(summaryInfo); } chnComboBox.setModel(new DefaultComboBoxModel(chnList)); setEnableAllInnerComponent(controlPanel, true); EventDisplay.setEventInfo(groupInfoTable, EventDisplay.dataList); } }); } else { JOptionPane.showMessageDialog(null, Res.string().getLoginFailed() + ", " + ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); return false; } return true; } // 登出 public void logout() { VideoStateSummaryModule.detachAllVideoStatSummary(); // 退订阅 stopRealPlay(); //退出æ’放 LoginModule.logout(); // 退出登录 chnList.clear(); // 清除通é“å·åˆ—表 EventDisplay.clearEventInfoList(); // æ¸…é™¤äº‹ä»¶åˆ—è¡¨æ•°æ® chnComboBox.setModel(new DefaultComboBoxModel()); loginPanel.setButtonEnable(false); setAttachBtnTextDisable(); setEnableAllInnerComponent(controlPanel, false); } /////////////////////////////// 人数统计事件 //////////////////////////////// //////////////////////////////////////////////////////////////////////////// private static boolean b_RealPlay = false; private static boolean b_Attachment = false; /* * 一级é¢æ¿ï¼šäººæ•°ç»Ÿè®¡æŽ§åˆ¶é¢æ¿ */ private class HumanStatisticPanel extends JPanel { private static final long serialVersionUID = 1L; public HumanStatisticPanel() { setLayout(new BorderLayout()); Dimension dim = getPreferredSize(); dim.width = 320; setPreferredSize(dim); humanStatisticAttachPanel = new HumanStatisticControlPanel(); // 人数统计控制é¢æ¿ realPanel = new RealPanel(); // 实时显示é¢å•Š groupListPanel = new GroupListPanel(); // 事件展示é¢æ¿ add(humanStatisticAttachPanel, BorderLayout.NORTH); add(realPanel, BorderLayout.EAST); add(groupListPanel, BorderLayout.CENTER); } } /* * 二级é¢æ¿ï¼š 控制é¢æ¿ 通é“ã€ç æµè®¾ç½®ï¼Œäº‹ä»¶è®¢é˜… */ private class HumanStatisticControlPanel extends JPanel { private static final long serialVersionUID = 1L; public HumanStatisticControlPanel() { BorderEx.set(this, Res.string().getHumanNumberStatisticAttach(), 2); setLayout(new FlowLayout()); /* 预览控制é¢æ¿ */ controlPanel = new Panel(); add(controlPanel); chnLabel = new JLabel(Res.string().getChannel()); chnComboBox = new JComboBox(); streamLabel = new JLabel(Res.string().getStreamType()); String[] stream = {Res.string().getMasterStream(), Res.string().getSubStream()}; streamComboBox = new JComboBox(stream); realPlayBtn = new JButton(Res.string().getStartRealPlay()); attachBtn = new JButton(Res.string().getAttach()); clearBtn = new JButton(Res.string().getHumanNumberStatisticEventClearOSD()); controlPanel.setLayout(new FlowLayout()); controlPanel.add(chnLabel); controlPanel.add(chnComboBox); controlPanel.add(streamLabel); controlPanel.add(streamComboBox); controlPanel.add(realPlayBtn); controlPanel.add(attachBtn); controlPanel.add(clearBtn); chnComboBox.setPreferredSize(new Dimension(90, 20)); streamComboBox.setPreferredSize(new Dimension(120, 20)); realPlayBtn.setPreferredSize(new Dimension(120, 20)); attachBtn.setPreferredSize(new Dimension(120, 20)); clearBtn.setPreferredSize(new Dimension(120, 20)); chnComboBox.setEnabled(false); streamComboBox.setEnabled(false); realPlayBtn.setEnabled(false); attachBtn.setEnabled(false); clearBtn.setEnabled(false); realPlayBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { realPlay(); } }); attachBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int channel = chnComboBox.getSelectedIndex(); if (!VideoStateSummaryModule.channelAttached(channel)) { if (VideoStateSummaryModule.attachVideoStatSummary(channel, humanNumberStatisticCB)) { setAttachBtnTextEnable(); } else { JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); } } else { if (VideoStateSummaryModule.detachVideoStatSummary(channel)) { setAttachBtnTextDisable(); SummaryInfo info = new SummaryInfo(); info.nChannelID = channel; EventDisplay.dataList.add(channel, info); EventDisplay.dataList.remove(channel + 1); EventDisplay.setEventInfo(groupInfoTable, EventDisplay.dataList); } else { JOptionPane.showMessageDialog(null, ToolKits.getErrorCodeShow(), Res.string().getErrorMessage(), JOptionPane.ERROR_MESSAGE); } } } }); // æ·»åŠ ä¸‹æ‹‰æ¡†äº‹ä»¶ç›‘å¬å™¨ chnComboBox.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { int channel = chnComboBox.getSelectedIndex(); if (VideoStateSummaryModule.channelAttached(channel)) { setAttachBtnTextEnable(); } else { setAttachBtnTextDisable(); } } } }); clearBtn.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { clearSummaryInfo(); } }); } } private static void setRealPlayBtnTextEnable() { b_RealPlay = true; realPlayBtn.setText(Res.string().getStopRealPlay()); } private static void setRealPlayBtnTextDisable() { b_RealPlay = false; realPlayBtn.setText(Res.string().getStartRealPlay()); } private static void setAttachBtnTextEnable() { b_Attachment = VideoStateSummaryModule.getM_hAttachMap().size() > 0; attachBtn.setText(Res.string().getDetach()); } private static void setAttachBtnTextDisable() { b_Attachment = VideoStateSummaryModule.getM_hAttachMap().size() > 0; attachBtn.setText(Res.string().getAttach()); } private static void setButtonEnable(boolean bln) { realPlayWindow.setEnabled(bln); chnComboBox.setEnabled(bln); streamComboBox.setEnabled(bln); realPlayBtn.setEnabled(bln); attachBtn.setEnabled(bln); clearBtn.setEnabled(bln); } // å¯ç”¨/ç¦ç”¨ Container 内所有组件 public static void setEnableAllInnerComponent(Component container, boolean enable) { for (Component component : getComponents(container)) { component.setEnabled(enable); } } // èŽ·å– Swing Container å†…æ‰€æœ‰çš„éž Container 组件 public static Component[] getComponents(Component container) { ArrayList<Component> list = null; try { list = new ArrayList<Component>(Arrays.asList( ((Container) container).getComponents())); for (int index = 0; index < list.size(); index++) { list.addAll(Arrays.asList(getComponents(list.get(index)))); } } catch (ClassCastException e) { list = new ArrayList<Component>(); } return list.toArray(new Component[0]); } private void clearSummaryInfo() { VideoStateSummaryModule.clearVideoStateSummary(chnComboBox.getSelectedIndex()); } /* * 二级é¢æ¿ï¼šé¢„览é¢æ¿ */ private class RealPanel extends JPanel { private static final long serialVersionUID = 1L; public RealPanel() { BorderEx.set(this, Res.string().getRealplay(), 2); Dimension dim = this.getPreferredSize(); dim.width = 420; this.setPreferredSize(dim); this.setLayout(new BorderLayout()); realPlayPanel = new JPanel(); add(realPlayPanel, BorderLayout.CENTER); /************ 预览é¢æ¿ **************/ realPlayPanel.setLayout(new BorderLayout()); realPlayPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); realPlayWindow = new Panel(); realPlayWindow.setBackground(Color.GRAY); realPlayWindow.setSize(480, 480); realPlayPanel.add(realPlayWindow, BorderLayout.CENTER); } } // 预览 public static void realPlay() { if (!b_RealPlay) { m_hPlayHandle = RealPlayModule.startRealPlay( chnComboBox.getSelectedIndex(), streamComboBox.getSelectedIndex() == 0 ? 0 : 3, realPlayWindow); if (m_hPlayHandle.longValue() != 0) { // æ£å¸¸çŠ¶æ€ä¸‹å¥æŸ„ä¸ä¸ºç©º TargetRecognitionModule.renderPrivateData(m_hPlayHandle, 1); // å¼€å¯è§„则框 realPlayWindow.repaint(); chnComboBox.setEnabled(false); streamComboBox.setEnabled(false); setRealPlayBtnTextEnable(); } } else { stopRealPlay(); } } public static void stopRealPlay() { RealPlayModule.stopRealPlay(m_hPlayHandle); // ä¸ºç©ºåˆ™è¯´æ˜Žå¤±è´¥ï¼Œé€€å‡ºæ‹‰æµ TargetRecognitionModule.renderPrivateData(m_hPlayHandle, 0); // å…³é—规则框 realPlayWindow.repaint(); chnComboBox.setEnabled(true); streamComboBox.setEnabled(true); setRealPlayBtnTextDisable(); } // æœç´¢æ•°æ®åˆ—表 public class GroupListPanel extends JPanel { private Object[][] statisticData = null; // 人脸库列表 private final String[] groupName = { Res.string().getHumanNumberStatisticEventChannel(), Res.string().getHumanNumberStatisticEventTime(), Res.string().getHumanNumberStatisticEventHourIn(), Res.string().getHumanNumberStatisticEventTodayIn(), Res.string().getHumanNumberStatisticEventTotalIn(), Res.string().getHumanNumberStatisticEventHourOut(), Res.string().getHumanNumberStatisticEventTodayOut(), Res.string().getHumanNumberStatisticEventTotalOut() }; private DefaultTableModel groupInfoModel; public GroupListPanel() { BorderEx.set(this, Res.string().getHumanNumberStatisticEventTitle(), 2); setLayout(new BorderLayout()); statisticData = new Object[32][9]; creatGroupInfoPanel(32); } private void creatGroupInfoPanel(int listSize) { statisticData = new Object[listSize][9]; // 人脸库列表集åˆä¿®æ”¹ groupInfoModel = new DefaultTableModel(statisticData, groupName); groupInfoTable = new JTable(groupInfoModel) { @Override // ä¸å¯ç¼–辑 public boolean isCellEditable(int row, int column) { return false; } }; groupInfoTable.getColumnModel().getColumn(0).setPreferredWidth(10); groupInfoTable.getColumnModel().getColumn(1).setPreferredWidth(80); groupInfoTable.getColumnModel().getColumn(2).setPreferredWidth(10); groupInfoTable.getColumnModel().getColumn(3).setPreferredWidth(10); groupInfoTable.getColumnModel().getColumn(4).setPreferredWidth(10); groupInfoTable.getColumnModel().getColumn(5).setPreferredWidth(10); groupInfoTable.getColumnModel().getColumn(6).setPreferredWidth(10); groupInfoTable.getColumnModel().getColumn(7).setPreferredWidth(10); groupInfoTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); // åªèƒ½é€‰ä¸ä¸€è¡Œ // åˆ—è¡¨æ˜¾ç¤ºå±…ä¸ DefaultTableCellRenderer dCellRenderer = new DefaultTableCellRenderer(); dCellRenderer.setHorizontalAlignment(JLabel.CENTER); groupInfoTable.setDefaultRenderer(Object.class, dCellRenderer); scrollPane = new JScrollPane(groupInfoTable); this.add(scrollPane, BorderLayout.CENTER); } } // 人数统计回调事件 public static fHumanNumberStatisticCallBack humanNumberStatisticCB = fHumanNumberStatisticCallBack.getInstance(); public static class fHumanNumberStatisticCallBack implements NetSDKLib.fVideoStatSumCallBack { private static fHumanNumberStatisticCallBack instance = new fHumanNumberStatisticCallBack(); public static fHumanNumberStatisticCallBack getInstance() { return instance; } private EventTaskCommonQueue eventTaskQueue = new EventTaskCommonQueue(); public fHumanNumberStatisticCallBack() { eventTaskQueue.init(); } public void invoke(NetSDKLib.LLong lAttachHandle, NetSDKLib.NET_VIDEOSTAT_SUMMARY stVideoState, int dwBufLen, Pointer dwUser) { SummaryInfo summaryInfo = new SummaryInfo( stVideoState.nChannelID, stVideoState.stuTime.toStringTime(), stVideoState.stuEnteredSubtotal.nToday, stVideoState.stuEnteredSubtotal.nHour, stVideoState.stuEnteredSubtotal.nTotal, stVideoState.stuExitedSubtotal.nToday, stVideoState.stuExitedSubtotal.nHour, stVideoState.stuExitedSubtotal.nTotal); System.out.printf("Channel[%d] GetTime[%s]\n" + "People In Information[Total[%d] Hour[%d] Today[%d]]\n" + "People Out Information[Total[%d] Hour[%d] Today[%d]]\n", summaryInfo.nChannelID, summaryInfo.eventTime, summaryInfo.enteredTotal, summaryInfo.enteredHour, summaryInfo.enteredToday, summaryInfo.exitedTotal, summaryInfo.exitedHour, summaryInfo.exitedToday); eventTaskQueue.addEvent(new EventDisplay(summaryInfo)); } } private static class SummaryInfo { public int nChannelID; public String eventTime; public int enteredToday; public int enteredHour; public int enteredTotal; public int exitedToday; public int exitedHour; public int exitedTotal; public SummaryInfo() { } public SummaryInfo(int nChannelID, String eventTime, int enteredToday, int enteredHour, int enteredTotal, int exitedToday, int exitedHour, int exitedTotal) { this.nChannelID = nChannelID; this.eventTime = eventTime; this.enteredToday = enteredToday; this.enteredHour = enteredHour; this.enteredTotal = enteredTotal; this.exitedToday = exitedToday; this.exitedHour = exitedHour; this.exitedTotal = exitedTotal; } } private static class EventDisplay implements EventTaskHandler { private static List<SummaryInfo> dataList = new LinkedList<SummaryInfo>(); private int getMaxSize() { int channelNum = LoginModule.m_stDeviceInfo.byChanNum; return Math.max(channelNum, 32); } private static final Object lockObj = new Object(); private final SummaryInfo summaryInfo; public EventDisplay(SummaryInfo Info) { this.summaryInfo = Info; } @Override public void eventTaskProcess() { InsertOrUpdateEventInfo(summaryInfo); } private void InsertOrUpdateEventInfo(SummaryInfo summaryInfo) { synchronized (lockObj) { dataList.add(summaryInfo.nChannelID, summaryInfo); dataList.remove(summaryInfo.nChannelID + 1); if (dataList.size() > getMaxSize()) { dataList.remove(getMaxSize()); } setEventInfo(groupInfoTable, dataList); } } private static void setEventInfo(JTable groupInfoTable, List<SummaryInfo> dataList) { clearTableModel(groupInfoTable); for (int i = 0; i < dataList.size(); i++) { groupInfoTable.setValueAt(dataList.get(i).nChannelID + 1, i, 0); groupInfoTable.setValueAt(dataList.get(i).eventTime, i, 1); groupInfoTable.setValueAt(dataList.get(i).enteredHour, i, 2); groupInfoTable.setValueAt(dataList.get(i).enteredToday, i, 3); groupInfoTable.setValueAt(dataList.get(i).enteredTotal, i, 4); groupInfoTable.setValueAt(dataList.get(i).exitedHour, i, 5); groupInfoTable.setValueAt(dataList.get(i).exitedToday, i, 6); groupInfoTable.setValueAt(dataList.get(i).exitedTotal, i, 7); } } // 清空 DefaultTableModel public static void clearTableModel(JTable jTableModel) { int rowCount = jTableModel.getRowCount(); int columnCount = jTableModel.getColumnCount(); //清空DefaultTableModelä¸çš„内容 for (int i = 0; i < rowCount; i++)//è¡¨æ ¼ä¸çš„行数 { for (int j = 0; j < columnCount; j++) {//è¡¨æ ¼ä¸çš„列数 jTableModel.setValueAt(" ", i, j);//é€ä¸ªæ¸…空 } } } private static void clearEventInfoList() { synchronized (lockObj) { dataList.clear(); setEventInfo(groupInfoTable, dataList); } } } /////////////////////////////// ç•Œé¢æŽ§ä»¶å®šä¹‰ //////////////////////////////// //////////////////////////////////////////////////////////////////////////// /********************************************************************** * 主界é¢çª—å£(mainFrame): mainFrame * 1) 登录(login): loginPanel * 2) 人数事件统计(humanStatistic): humanStatisticPanel * (1) 控制é¢æ¿(HumanStatisticAttach): HumanStatisticControlPanel * (2) 预览(realPlay): realPanel * (3) 事件信æ¯å±•ç¤ºé¢æ¿(eventInfo): groupListPanel **********************************************************************/ ///////////////////// 主é¢æ¿ ///////////////////// private static JFrame mainFrame = new JFrame(); ///////////////////// 一级é¢æ¿ ///////////////////// /* 登录é¢æ¿ */ private LoginPanel loginPanel; /* 人数统计é¢æ¿ */ private HumanStatisticPanel humanStatisticPanel; ///////////////////// 二级é¢æ¿ ///////////////////// /* 人数统计é¢æ¿ */ private HumanStatisticControlPanel humanStatisticAttachPanel; private Panel controlPanel; private JLabel chnLabel; private static JComboBox chnComboBox; private JLabel streamLabel; private static JComboBox streamComboBox; private static JButton realPlayBtn; private static JButton attachBtn; private static JButton clearBtn; /* 实时预览é¢æ¿ */ private RealPanel realPanel; private JPanel realPlayPanel; private static Panel realPlayWindow; /* 事件数æ®å±•ç¤ºé¢æ¿ */ private static JTable groupInfoTable; private GroupListPanel groupListPanel; private JScrollPane scrollPane; } public class HumanNumberStatistic { public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { HumanNumberStatisticFrame demo = new HumanNumberStatisticFrame(); demo.setVisible(true); } }); } }