Mercurial > hg > Members > riono > TreeVNC_ja_comment
diff src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java @ 403:3a7d02844cfe
Enable AdvancedMenu to RootSelectionPanel
author | Tatsuki IHA <e125716@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 19 Oct 2015 17:35:07 +0900 |
parents | 94c520535ef1 |
children | aad75cd6d9e2 |
line wrap: on
line diff
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java Thu Oct 15 04:45:16 2015 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeVncRootSelectionPanel.java Mon Oct 19 17:35:07 2015 +0900 @@ -17,10 +17,9 @@ private static final long serialVersionUID = 1L; private final FindRoot findRoot; private JPanel panel = new JPanel(); - private JButton button = new JButton("Connect"); - private JButton startRootButton = new JButton("Start as TreeVNC Root"); - private JButton startDisplayButton = new JButton("Start Display Mode"); - private TextField t1; + private JButton button = new JButton("Start"); + private JComboBox advancedMenu = new JComboBox(); + private TextField t1; private TextField t2; private double width = 750; private double height = 500; @@ -38,29 +37,20 @@ this.findRoot = findRoot; setTitle("TreeVNC Root Address"); setResizable(false); - setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - panel.add(startRootButton); - panel.add(startDisplayButton); - startRootButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - cp.setRootMode(); - cp.restart(); - unVisible(); - } - }); - startDisplayButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - cp.setDisplayMode(); - cp.restart(); - unVisible(); - } - }); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setAdvancedMenu(); + setButton(); + } + + private void setAdvancedMenu() { + advancedMenu.addItem("Connect to TreeVNC"); + advancedMenu.addItem("Start as TreeVNC Root"); + advancedMenu.addItem("Start Display Mode"); + panel.add(advancedMenu); contentPane.add(panel, BorderLayout.CENTER); } - public void ipRegister() { + public void ipRegister() { setSize(); setText(); setButton(); @@ -135,31 +125,43 @@ } public void actionPerformed(ActionEvent e) { - flag = true; - for (int t = 0; t < counter; t++) { - int ipv4AddressLength = 3; - int ipv6AddressLength = 17; - String port = null; - String hostAddress = null; - String rootAddress = null; - if (check[t].getState()) { - System.out.println(check[t].getLabel()); - String str = check[t].getLabel(); - String[] temp = str.split(":"); - if (temp.length == ipv4AddressLength) { - // IPv4 Address - port = temp[0]; - hostAddress = temp[1]; - rootAddress = temp[2]; - } else if (temp.length == ipv6AddressLength) { - // IPv6 Address - port = temp[0]; - hostAddress = temp[1] + ":" + temp[2] + ":" + temp[3] + ":" + temp[4] + ":" + temp[5] + ":" + temp[6] + ":" + temp[7] + ":" + temp[8]; - rootAddress = temp[9] + ":" + temp[10] + ":" + temp[11] + ":" + temp[12] + ":" + temp[13] + ":" + temp[14] + ":" + temp[15] + ":" + temp[16]; - } - cp.setHostName(hostAddress,Integer.parseInt(port),rootAddress); - unVisible(); + if (advancedMenu.getSelectedIndex() == 0) { + flag = true; + for (int t = 0; t < counter; t++) { + int ipv4AddressLength = 3; + int ipv6AddressLength = 17; + String port = null; + String hostAddress = null; + String rootAddress = null; + if (check[t].getState()) { + System.out.println(check[t].getLabel()); + String str = check[t].getLabel(); + String[] temp = str.split(":"); + if (temp.length == ipv4AddressLength) { + // IPv4 Address + port = temp[0]; + hostAddress = temp[1]; + rootAddress = temp[2]; + } else if (temp.length == ipv6AddressLength) { + // IPv6 Address + port = temp[0]; + hostAddress = temp[1] + ":" + temp[2] + ":" + temp[3] + ":" + temp[4] + ":" + temp[5] + ":" + temp[6] + ":" + temp[7] + ":" + temp[8]; + rootAddress = temp[9] + ":" + temp[10] + ":" + temp[11] + ":" + temp[12] + ":" + temp[13] + ":" + temp[14] + ":" + temp[15] + ":" + temp[16]; + } + cp.setHostName(hostAddress, Integer.parseInt(port), rootAddress); + unVisible(); + } } + } else if (advancedMenu.getSelectedIndex() == 1) { + // selected "Start as TreeVNC Root" + cp.setRootMode(); + cp.restart(); + unVisible(); + } else if (advancedMenu.getSelectedIndex() == 2) { + // selected "Start Display Mode" + cp.setDisplayMode(); + cp.restart(); + unVisible(); } }