📄 graphicalclient.java
字号:
/* * Created on 24-feb-2004 * * To change the template for this generated file go to Window - Preferences - * Java - Code Generation - Code and Comments */package javatunnel.gui;import java.awt.*;import java.awt.event.*;import java.io.*;import javatunnel.*;import javax.swing.*;/** * @author utopio * * To change the template for this generated type comment go to Window - * Preferences - Java - Code Generation - Code and Comments */public class GraphicalClient { static JFrame mainFrame; static JSplitPane splitPane; static JList list; //Component detail; static JMenuBar menu; static JToolBar toolbar; static JTextArea console; static JPopupMenu popupMenu; static MenuHandler handler; static private void initControls() { mainFrame = new JFrame(); mainFrame.setTitle("JavaTunnel"); mainFrame.setSize(800, 600); mainFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); Engine.cleanHostsFile(); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { Engine.cleanHostsFile(); System.exit(0); } }); Container content = mainFrame.getContentPane(); handler = new MenuHandler(mainFrame); //Init Menu initMenu(); //Layout content.setLayout(new BorderLayout()); content.add(new JLabel("Aqui van los botones"), BorderLayout.NORTH); list = new JList(); list.setModel(new DefaultListModel()); popupMenu = new JPopupMenu(); JMenuItem popupStop = popupMenu.add("Stop"); popupStop.addActionListener(handler); list.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent me) { // if right mouse button clicked over selection show popupMenu if (SwingUtilities.isRightMouseButton(me) && !list.isSelectionEmpty() && list.locationToIndex(me.getPoint()) == list.getSelectedIndex()) { popupMenu.show(list, me.getX(), me.getY()); } } }); list.addListSelectionListener(new ListHandler()); splitPane = new JSplitPane( JSplitPane.HORIZONTAL_SPLIT, list, new JButton("Detalles")); //200px for List 400px screen for details splitPane.setDividerLocation(200); content.add(splitPane, BorderLayout.CENTER); initConsole(); mainFrame.show(); } static private void initMenu() { menu = new JMenuBar(); JMenu archiveMenu = new JMenu("File"); JMenu newMenu = new JMenu("New..."); JMenuItem newRedirect = new JMenuItem("Redirect"); JMenuItem newSSLProxy = new JMenuItem("SSL Proxy"); newRedirect.addActionListener(handler); newSSLProxy.addActionListener(handler); newMenu.add(newRedirect); newMenu.add(newSSLProxy); JMenuItem itemExit = new JMenuItem("Exit"); itemExit.addActionListener(handler); archiveMenu.add(newMenu); archiveMenu.add(itemExit); menu.add(archiveMenu); JMenu actionsMenu = new JMenu("Actions"); JMenuItem stop = new JMenuItem("Stop"); stop.addActionListener(handler); actionsMenu.add(stop); menu.add(actionsMenu); mainFrame.setJMenuBar(menu); } private static void initConsole() { console = new JTextArea(); console.setRows(10); JScrollPane scroll = new JScrollPane(console); mainFrame.getContentPane().add(scroll, BorderLayout.SOUTH); PrintStream stream = new PrintStream(new Logger(new ByteArrayOutputStream(), console)); System.setOut(stream); } public static void main(String args[]) { initControls(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -