public GUI() { String[] keys = {"no Quotation found"}; if (tryDir(".") || tryDir("BLM305") || tryDir("CSE470")) keys = Q.keySet().toArray(keys); menu = new JComboBox<String>(keys); if (Q.size() > 0) setMessage(0); JPanel pan = new JPanel(); pan.setLayout(new BorderLayout(GAP, GAP - 4)); pan.setBorder(new javax.swing.border.EmptyBorder(GAP, GAP, GAP, GAP)); pan.setBackground(COLOR); pan.add(topPanel(), "North"); txt.setFont(LARGE); txt.setEditable(false); txt.setRows(5); txt.setColumns(30); txt.setWrapStyleWord(true); txt.setLineWrap(true); txt.setDragEnabled(true); pan.add(new JScrollPane(txt), "Center"); ref.setFont(SMALL); ref.setEditable(false); ref.setColumns(35); ref.setDragEnabled(true); pan.add(ref, "South"); pan.setToolTipText("A project realized collectively by the class"); menu.setToolTipText("Quotation classes"); who.setToolTipText("author()+year()"); txt.setToolTipText("text()"); ref.setToolTipText("reference()"); frm.setContentPane(pan); frm.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frm.setLocation(scaled(120), scaled(90)); frm.pack(); frm.setVisible(true); }
public PlayerSideBar(JPanel panel, final PlayerMedia frame) { this.contentPane = panel; this.frame = frame; // ******************** Button for listening to text entered ********** btnListen = new JButton("Listen"); btnListen.setEnabled(false); btnListen.setBackground(Color.GRAY); btnListen.setForeground(Color.WHITE); // ActionListener to perform the speaking when pressed btnListen.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { // disable listen button so speak only one thing at a time btnListen.setEnabled(false); ListenBG ListenWorker = new ListenBG(frame); // execute SwingWorker ListenWorker.execute(); } }); btnListen.setBounds(750, 192, 135, 40); contentPane.add(btnListen); // ****************************************************************** // ********************** Create mp3 (TTS) ***************************** btnCreateMp = new JButton("Create mp3"); btnCreateMp.setEnabled(false); btnCreateMp.setBackground(Color.GRAY); btnCreateMp.setForeground(Color.WHITE); // ActionListener: Creates mp3 from text entered TTS btnCreateMp.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { // ask user to enter desired output name final String output = JOptionPane.showInputDialog(null, "Enter Mp3 Name: "); File f = new File(output + ".mp3"); if (output != null && output.length() > 0) { if (f.exists() && !f.isDirectory()) { // ask if user would want to overwrite existing file int reply = JOptionPane.showConfirmDialog( null, "File already exists, overwrite?", "Overwrite?", JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { CreateMp3BG maker = new CreateMp3BG(frame, output); maker.execute(); } } else { CreateMp3BG maker = new CreateMp3BG(frame, output); maker.execute(); } } } }); btnCreateMp.setBounds(905, 192, 142, 40); contentPane.add(btnCreateMp); // ****************************************************************** // *************Button to combined selected audio and video files************* btnAddCom = new JButton("Merge Video/Audio\n"); btnAddCom.setBackground(Color.GRAY); btnAddCom.setForeground(Color.WHITE); btnAddCom.setFont(new Font("Dialog", Font.BOLD, 22)); btnAddCom.setBounds(750, 334, 297, 100); btnAddCom.setEnabled(false); btnAddCom.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { // pick a name for the output file final String comOutName = JOptionPane.showInputDialog("Enter New Video Name: "); File f = new File(comOutName + ".avi"); if (comOutName != null && comOutName.length() > 0) { if (f.exists() && !f.isDirectory()) { // ask if user would want to overwrite existing file int reply = JOptionPane.showConfirmDialog( null, "File already exists, overwrite?", "Overwrite?", JOptionPane.YES_NO_OPTION); if (reply == JOptionPane.YES_OPTION) { // generate swingworker instance AddCommentaryBG adder = new AddCommentaryBG(frame, comOutName); adder.execute(); } } else { // generate swingworker instance AddCommentaryBG adder = new AddCommentaryBG(frame, comOutName); adder.execute(); } } } }); contentPane.add(btnAddCom); // Label to indicate how many characters are remaining lblChars = new JLabel("200/200"); lblChars.setForeground(Color.WHITE); lblChars.setBounds(980, 170, 70, 15); contentPane.add(lblChars); // *************************************************************************** // *****************simple text area for the user to enter text ****************** txtArea = new JTextArea(); txtArea.setText("Add Text Here"); txtArea.setWrapStyleWord(true); txtArea.setRows(5); txtArea.setToolTipText("Enter text for text to speech. "); txtArea.setFont(new Font("Dialog", Font.PLAIN, 15)); txtArea.setLineWrap(true); txtArea.setBounds(551, 41, 302, 122); txtArea.setDocument(docfilt); contentPane.add(txtArea); // ****** Scroll pane which allow text area to scroll ************************** scrollPane = new JScrollPane(txtArea); scrollPane.setBounds(750, 41, 297, 122); contentPane.add(scrollPane); JLabel textLabel = new JLabel("Enter text for text-to-speech"); scrollPane.setColumnHeaderView(textLabel); // **************** Document Filter to count characters ************************ // set the maximum character to 200 so the festival voice doesn't die docfilt.setDocumentFilter(new DocumentSizeFilter(200)); // add a listener to show user how many characters remaining docfilt.addDocumentListener( new DocumentListener() { @Override public void changedUpdate(DocumentEvent e) { charCount(); } @Override public void insertUpdate(DocumentEvent e) { charCount(); } @Override public void removeUpdate(DocumentEvent e) { charCount(); } }); // ****************************************************************** // *************** Button to open window for eiditing commentary ***************** btnEdit = new JButton("Add Audio Files To Merge"); btnEdit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { edit.setVisible(true); } }); btnEdit.setForeground(Color.WHITE); btnEdit.setFont(new Font("Dialog", Font.BOLD, 18)); btnEdit.setBackground(Color.GRAY); btnEdit.setBounds(750, 244, 297, 78); contentPane.add(btnEdit); // ********************************************************************************* }
/** * Component initialization. * * @throws java.lang.Exception */ private void jbInit() throws Exception { contentPane = (JPanel) getContentPane(); contentPane.setLayout(null); this.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); setSize(new Dimension(400, 621)); setTitle("实时通讯模块测试程序"); jButton1.setBounds(new Rectangle(11, 412, 82, 26)); jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton1.setText("召测接口"); jButton1.addActionListener(new RealTimeTestFrame_jButton1_actionAdapter(this)); jButton2.setBounds(new Rectangle(10, 366, 83, 26)); jButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton2.setText("创建对象"); jButton2.addActionListener(new RealTimeTestFrame_jButton2_actionAdapter(this)); jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel1.setText("接入IP:"); jLabel1.setBounds(new Rectangle(23, 22, 63, 16)); jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel2.setText("接入端口:"); jLabel2.setBounds(new Rectangle(23, 67, 63, 16)); jTextField1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jTextField1.setText("172.19.74.13"); txt_port.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_port.setText("3000"); txt_port.setBounds(new Rectangle(84, 64, 88, 22)); jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel3.setText("AppID:"); jLabel3.setBounds(new Rectangle(23, 113, 63, 16)); contentPane.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel4.setText("ZDLJDZ:"); jLabel4.setBounds(new Rectangle(23, 158, 63, 16)); jLabel5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel5.setText("规约号:"); jLabel5.setBounds(new Rectangle(23, 186, 63, 16)); jLabel6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel6.setText("发送内容:"); jLabel6.setBounds(new Rectangle(23, 333, 63, 16)); jLabel7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel7.setText("通讯方式:"); jLabel7.setBounds(new Rectangle(21, 219, 63, 16)); txt_AppID.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_AppID.setText("25"); txt_AppID.setBounds(new Rectangle(84, 110, 83, 22)); txt_zdljdz.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_zdljdz.setText("91010022"); txt_zdljdz.setBounds(new Rectangle(84, 155, 88, 22)); txt_gyh.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_gyh.setText("100"); txt_gyh.setBounds(new Rectangle(84, 183, 63, 22)); txt_txfs.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_txfs.setText("40"); txt_txfs.setBounds(new Rectangle(84, 218, 63, 22)); jTextField7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_ip.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); InetAddress localhost = java.net.InetAddress.getLocalHost(); String hostIP = localhost.getHostAddress(); txt_ip.setText(hostIP); txt_ip.setBounds(new Rectangle(84, 19, 159, 22)); txt_content.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_content.setText("6000000100111107"); txt_content.setBounds(new Rectangle(84, 330, 298, 22)); txt_content.addActionListener(new RealTimeTestFrame_txt_content_actionAdapter(this)); jButton3.setBounds(new Rectangle(200, 412, 89, 26)); jButton3.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton3.setText("发送短信"); jButton3.addActionListener(new RealTimeTestFrame_jButton3_actionAdapter(this)); jButton4.setBounds(new Rectangle(295, 366, 96, 26)); jButton4.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton4.setText("自定义命令"); jButton4.addActionListener(new RealTimeTestFrame_jButton4_actionAdapter(this)); lab_yxj.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); lab_yxj.setText("优先级:"); lab_yxj.setBounds(new Rectangle(23, 287, 61, 16)); txt_gnm.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_gnm.setText("0D"); txt_gnm.setBounds(new Rectangle(84, 251, 63, 22)); jLabel9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel9.setText("手机号码:"); jLabel9.setBounds(new Rectangle(190, 67, 67, 16)); txt_sjhm.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_sjhm.setText("13800571505"); txt_sjhm.setBounds(new Rectangle(250, 64, 111, 22)); jLabel10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel10.setText("命令序号:"); jLabel10.setBounds(new Rectangle(190, 112, 73, 16)); txt_mlxh.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_mlxh.setText("1"); txt_mlxh.setBounds(new Rectangle(250, 109, 110, 22)); jButton5.setBounds(new Rectangle(105, 366, 83, 26)); jButton5.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton5.setText("连接"); jButton5.addActionListener(new RealTimeTestFrame_jButton5_actionAdapter(this)); jButton6.setBounds(new Rectangle(200, 366, 83, 26)); jButton6.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton6.setText("断开连接"); jButton6.addActionListener(new RealTimeTestFrame_jButton6_actionAdapter(this)); jLabel11.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel11.setText("终端逻辑地址:"); jLabel11.setBounds(new Rectangle(164, 199, 87, 16)); txt_listterminal.setText("12041234"); txt_listterminal.setBounds(new Rectangle(252, 196, 130, 22)); jButton8.setBounds(new Rectangle(170, 248, 90, 26)); jButton8.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton8.setText("加入队列"); jButton8.addActionListener(new RealTimeTestFrame_jButton8_actionAdapter(this)); jButton9.setBounds(new Rectangle(283, 248, 85, 26)); jButton9.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton9.setText("在线状态"); jButton9.addActionListener(new RealTimeTestFrame_jButton9_actionAdapter(this)); memo1.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); memo1.setToolTipText(""); memo1.setEditable(false); memo1.setLineWrap(true); memo1.setWrapStyleWord(true); memo1.setBounds(new Rectangle(17, 451, 361, 154)); jButton7.setBounds(new Rectangle(226, 289, 92, 26)); jButton7.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton7.setText("设置掉线"); jButton7.addActionListener(new RealTimeTestFrame_jButton7_actionAdapter(this)); jButton10.setBounds(new Rectangle(192, 155, 90, 23)); jButton10.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton10.setText("手工建档"); jButton10.addActionListener(new RealTimeTestFrame_jButton10_actionAdapter(this)); jLabel12.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jLabel12.setText("功能码:"); jLabel12.setBounds(new Rectangle(23, 254, 61, 16)); txt_yxj.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); txt_yxj.setText("08"); txt_yxj.setBounds(new Rectangle(84, 283, 63, 22)); jButton11.setBounds(new Rectangle(105, 412, 82, 26)); jButton11.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton11.setActionCommand(""); jButton11.setText("获取结果"); jButton11.addActionListener(new RealTimeTestFrame_jButton11_actionAdapter(this)); jButton12.setBounds(new Rectangle(301, 412, 87, 26)); jButton12.setFont(new java.awt.Font("宋体", Font.PLAIN, 12)); jButton12.setText("批量测试"); jButton12.addActionListener(new RealTimeTestFrame_jButton12_actionAdapter(this)); contentPane.add(jLabel1); contentPane.add(jLabel2); contentPane.add(txt_port); contentPane.add(jLabel3); contentPane.add(jLabel4); contentPane.add(jTextField1); contentPane.add(txt_AppID); contentPane.add(txt_zdljdz); contentPane.add(jTextField7); contentPane.add(txt_ip); contentPane.add(txt_content); contentPane.add(jLabel6); contentPane.add(jLabel9); contentPane.add(txt_sjhm); contentPane.add(jLabel10); contentPane.add(txt_mlxh); contentPane.add(txt_listterminal); contentPane.add(jLabel11); contentPane.add(jButton8); contentPane.add(jButton9); contentPane.add(memo1); contentPane.add(jButton7); contentPane.add(jButton10); contentPane.add(txt_gnm); contentPane.add(txt_txfs); contentPane.add(txt_gyh); contentPane.add(jLabel5); contentPane.add(jLabel7); contentPane.add(jLabel12); contentPane.add(lab_yxj); contentPane.add(txt_yxj); contentPane.add(jButton2); contentPane.add(jButton5); contentPane.add(jButton6); contentPane.add(jButton4); contentPane.add(jButton1); contentPane.add(jButton11); contentPane.add(jButton3); contentPane.add(jButton12); }
/** * Constructor for the 2D view, creates JPanel within a frame and initializes the list of * listeners (input and drawable) */ public View2D() { super(); drawList = new ArrayList<Drawable2D>(); mainWindow = new JFrame("World of the Nameless"); mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // mainWindow.setBounds(100, 100, 730, 480); mainWindow.setResizable(false); mainWindow.setLayout(new BorderLayout()); mainWindow.setVisible(true); drawArea = new Drawable2DArea(); drawArea.addMouseListener(this); mapArea = new MapPanel(); JPanel buttonPanel = new JPanel(new GridLayout(2, 4)); inventoryButton = new JButton("Inventory"); inventoryButton.addActionListener(this); characterButton = new JButton("Character"); characterButton.addActionListener(this); helpButton = new JButton("Help"); helpButton.addActionListener(this); quitButton = new JButton("Quit"); quitButton.addActionListener(this); undoButton = new JButton("Undo"); undoButton.addActionListener(this); redoButton = new JButton("Redo"); redoButton.addActionListener(this); saveButton = new JButton("Save"); saveButton.addActionListener(this); buttonPanel.add(inventoryButton); buttonPanel.add(characterButton); buttonPanel.add(undoButton); buttonPanel.add(redoButton); buttonPanel.add(helpButton); buttonPanel.add(quitButton); buttonPanel.add(saveButton); textAreaPanel = new JPanel(new BorderLayout()); textArea = new JTextArea(); textArea.setEditable(false); textArea.setToolTipText("What is happening to me"); // JScrollPane scrollPane = new JScrollPane(textArea); JPanel inputFieldPane = new JPanel(new BorderLayout()); inputField = new JTextField(); inputField.addActionListener(this); inputField.setToolTipText("Input Text commands here"); JLabel inputLabel = new JLabel(" >"); inputFieldPane.add(inputLabel, BorderLayout.WEST); inputFieldPane.add(inputField, BorderLayout.CENTER); textAreaPanel.add(textArea, BorderLayout.CENTER); textAreaPanel.add(inputFieldPane, BorderLayout.SOUTH); JPanel infoPanel = new JPanel(new GridLayout(2, 1)); infoPanel.add(mapArea); infoPanel.add(textAreaPanel); JPanel gameContent = new JPanel(new GridLayout(1, 2)); gameContent.add(drawArea); gameContent.add(infoPanel); gameContent.setToolTipText("Game Visuals"); mainWindow.add(gameContent, BorderLayout.CENTER); mainWindow.add(buttonPanel, BorderLayout.SOUTH); mainWindow.pack(); }