public Cliente(Socket s) { super("OPERACIONES CON BD"); socket = s; try { salida = new DataOutputStream(socket.getOutputStream()); inObjeto = new ObjectInputStream(socket.getInputStream()); } catch (IOException e) { e.printStackTrace(); System.exit(0); } setLayout(null); etiqueta.setBounds(10, 10, 200, 30); add(etiqueta); empconsultar.setBounds(210, 10, 50, 30); add(empconsultar); textarea1 = new JTextArea(); scrollpane1 = new JScrollPane(textarea1); scrollpane1.setBounds(10, 50, 400, 300); add(scrollpane1); boton.setBounds(420, 10, 100, 30); add(boton); desconectar.setBounds(420, 50, 100, 30); add(desconectar); textarea1.setEditable(false); boton.addActionListener(this); desconectar.addActionListener(this); setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); }
private void initComponent() { // Create the logger first, because the action listeners // need to refer to it. logger = new JTextArea(8, 50); logger.setMargin(new Insets(5, 5, 5, 5)); logger.setEditable(false); JScrollPane logScrollPane = new JScrollPane(logger); // Create a file chooser fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // Create the open button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). openButton = new JButton("Chose NetBeans ...", createImageIcon("images/open.gif")); openButton.addActionListener(GuiFriendlizerApp.this); // Create the save button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). patchButton = new JButton("Do Patch", createImageIcon("images/patch.gif")); patchButton.addActionListener(GuiFriendlizerApp.this); patchButton.setEnabled(false); // For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); // use FlowLayout buttonPanel.add(openButton); buttonPanel.add(patchButton); // Add the buttons and the logger to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); }
// Initialize all the GUI components and display the frame private static void initGUI() { // Set up the status bar statusField = new JLabel(); statusField.setText(statusMessages[DISCONNECTED]); statusColor = new JTextField(1); statusColor.setBackground(Color.red); statusColor.setEditable(false); statusBar = new JPanel(new BorderLayout()); statusBar.add(statusColor, BorderLayout.WEST); statusBar.add(statusField, BorderLayout.CENTER); // Set up the options pane JPanel optionsPane = initOptionsPane(); // Set up the chat pane JPanel chatPane = new JPanel(new BorderLayout()); chatText = new JTextArea(10, 20); chatText.setLineWrap(true); chatText.setEditable(false); chatText.setForeground(Color.blue); JScrollPane chatTextPane = new JScrollPane( chatText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); chatLine = new JTextField(); chatLine.setEnabled(false); chatLine.addActionListener( new ActionAdapter() { public void actionPerformed(ActionEvent e) { String s = chatLine.getText(); if (!s.equals("")) { appendToChatBox("OUTGOING: " + s + "\n"); chatLine.selectAll(); // Send the string sendString(s); } } }); chatPane.add(chatLine, BorderLayout.SOUTH); chatPane.add(chatTextPane, BorderLayout.CENTER); chatPane.setPreferredSize(new Dimension(200, 200)); // Set up the main pane JPanel mainPane = new JPanel(new BorderLayout()); mainPane.add(statusBar, BorderLayout.SOUTH); mainPane.add(optionsPane, BorderLayout.WEST); mainPane.add(chatPane, BorderLayout.CENTER); // Set up the main frame mainFrame = new JFrame("Simple TCP Chat"); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainFrame.setContentPane(mainPane); mainFrame.setSize(mainFrame.getPreferredSize()); mainFrame.setLocation(200, 200); mainFrame.pack(); mainFrame.setVisible(true); }
public DistributedTextEditor() { area1.setFont(new Font("Monospaced", Font.PLAIN, 12)); area2.setFont(new Font("Monospaced", Font.PLAIN, 12)); ((AbstractDocument) area1.getDocument()).setDocumentFilter(dec); area2.setEditable(false); Container content = getContentPane(); content.setLayout(new BoxLayout(content, BoxLayout.Y_AXIS)); JScrollPane scroll1 = new JScrollPane( area1, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); content.add(scroll1, BorderLayout.CENTER); JScrollPane scroll2 = new JScrollPane( area2, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); content.add(scroll2, BorderLayout.CENTER); content.add(ipaddress, BorderLayout.CENTER); content.add(portNumber, BorderLayout.CENTER); JMenuBar JMB = new JMenuBar(); setJMenuBar(JMB); JMenu file = new JMenu("File"); JMenu edit = new JMenu("Edit"); JMB.add(file); JMB.add(edit); file.add(Listen); file.add(Connect); file.add(Disconnect); file.addSeparator(); file.add(Save); file.add(SaveAs); file.add(Quit); edit.add(Copy); edit.add(Paste); edit.getItem(0).setText("Copy"); edit.getItem(1).setText("Paste"); Save.setEnabled(false); SaveAs.setEnabled(false); Disconnect.setEnabled(false); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); area1.addKeyListener(k1); area1.addMouseListener(m1); setTitle("Disconnected"); setVisible(true); area1.insert("Welcome to Hjortehandlerne's distributed text editor. \n", 0); this.addWindowListener(w1); }
public LicenseDialog(Component parent) { setTitle("Licensing information"); pnlButtons.add(bttnOk); cbLang.addItem("English"); cbLang.addItem("Eesti"); FlowLayout fl = new FlowLayout(); fl.setAlignment(FlowLayout.LEFT); pnlHeader.setLayout(fl); pnlHeader.add(lblLang); pnlHeader.add(cbLang); pnlMain.setLayout(new BorderLayout()); pnlMain.add(pnlHeader, BorderLayout.NORTH); pnlMain.add(scrollPane, BorderLayout.CENTER); pnlMain.add(pnlButtons, BorderLayout.SOUTH); taLicenseText.setText(getLicenseText()); taLicenseText.setCaretPosition(0); taLicenseText.setLineWrap(true); taLicenseText.setEditable(false); taLicenseText.setWrapStyleWord(true); getContentPane().add(pnlMain); setPreferredSize(new Dimension(500, 600)); setLocationRelativeTo(parent); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); bttnOk.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent evt) { if (evt.getSource() == bttnOk) { dispose(); } } // end actionPerformed }); // end bttnOk Action Listener cbLang.addItemListener( new ItemListener() { public void itemStateChanged(final ItemEvent event) { if (event.getSource() == cbLang && event.getStateChange() == ItemEvent.SELECTED && cbLang.getItemCount() > 0) { taLicenseText.setText(getLicenseText()); taLicenseText.setCaretPosition(0); } } }); // end cbLang item listener pack(); setVisible(true); } // PortPropertiesDialog
public void setOutputPanel() { BoxLayout box = new BoxLayout(output, BoxLayout.Y_AXIS); output.setLayout(box); Color c1 = new Color(166, 209, 241); Color c2 = new Color(204, 210, 211); JLabel label3 = new JLabel("Messaggi interni:"); output.add(label3); outp.setBackground(c1); outp.setAutoscrolls(true); outp.setEditable(false); intmsg.setBackground(c2); intmsg.setAutoscrolls(true); intmsg.setEditable(false); output.add(scrollPaneM); JLabel label4 = new JLabel("Output:"); output.add(label4); output.add(scrollPaneO); output.setBorder(BorderFactory.createEtchedBorder()); }
public ShowComp() throws InterruptedException, IOException { super("CONNECTED COMPUTERS"); int x = 0, d = 20; mb = new JMenuBar(); File = new JMenu("File"); mb.add(File); exit = new JMenuItem("Exit"); exit.addActionListener(this); File.add(exit); ta = new JTextArea(); ta.setBounds(20, 30, 315, 470); ta.setEditable(false); add(ta); setJMenuBar(mb); sel = new JLabel("The connected computers are.."); sel.setBounds(15, 5, 300, 30); add(sel); b1 = new JButton("<< BACK"); b1.setBounds(140, 510, 100, 30); b1.setToolTipText("Back to main page"); b1.addActionListener(this); add(b1); setLayout(null); while (x < 360) { x = x + d; setBounds(675, 50, x, 600); this.show(); } // setVisible(true); String s = "192.168.0.", temp = null; Printer printer = new Printer(); printer.start(); Connector connector = new Connector(printer); connector.start(); LinkedList targets = new LinkedList(); for (int i = 1; i <= 255; i++) { temp = s + Integer.toString(i); Target t = new Target(temp); targets.add(t); connector.add(t); } Thread.sleep(2000); connector.shutdown(); connector.join(); for (Iterator i = targets.iterator(); i.hasNext(); ) { Target t = (Target) i.next(); if (!t.shown) t.show(); } setDefaultCloseOperation(DISPOSE_ON_CLOSE); }
boolean initControlCenter(String title) { this.setTitle(title); // set up content pane Container content = this.getContentPane(); content.setLayout(new BorderLayout()); panelAbout.setLayout(new BorderLayout()); JTextArea textArea = new JTextArea( "PlayStation 2 Virtual File System release 1.0 \n\nSpecials thanks to our betatester\nPS2Linux Betatester: Mrbrown and Sarah\nPS2 betatester: Oobles, Caveman, Gamebytes, Ping^Spike, Josekenshin, Padawan, pakor, SandraThx and Rolando\n\nAdded little gui in java swing\nAdded feature to choose directory for media files\nAdded support for properties files\nCheck for updates at ps2dev.org\n\nRelease 1.2\n\nRewrite io with java NIO\nadded console mode support\n"); textArea.setEditable(false); JScrollPane areaScrollPane = new JScrollPane(textArea); areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); areaScrollPane.setPreferredSize(new Dimension(250, 250)); TitledBorder aboutBorder = BorderFactory.createTitledBorder("Change log and Greets"); aboutBorder.setTitleColor(Color.blue); panelAbout.setBorder(aboutBorder); panelAbout.add(areaScrollPane); // set up tabbed pane content.add(jtpMain); jtpMain.addTab("Configure", panelChooser); jtpMain.addTab("About", panelAbout); // set up display area // jtaDisplay.setEditable(false); // jtaDisplay.setLineWrap(true); // jtaDisplay.setMargin(new Insets(5, 5, 5, 5)); // jtaDisplay.setFont( // new Font("Monospaced", Font.PLAIN, iDEFAULT_FontSize)); // jspDisplay.setViewportView(jtaDisplay); // jspDisplay.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS ); // panelConsole.add(jspDisplay, BorderLayout.CENTER); // panelConsole.add(jtfCommand, BorderLayout.SOUTH); // panelConsole.add(jtaDisplay, BorderLayout.CENTER); // listener: window closer this.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); this.vResize(); return true; }
/** Initialisation */ private void initComponents() { setBackground(new java.awt.Color(114, 159, 255)); addWindowListener( new java.awt.event.WindowAdapter() { public void windowClosing(java.awt.event.WindowEvent evt) { closeDialog(); } }); getContentPane().setLayout(new java.awt.BorderLayout()); JPanel actionPanel = new JPanel(); actionPanel.setLayout(new java.awt.GridLayout(1, 0)); detailedArea.setEditable(false); detailedArea.setVisible(true); detailedArea.setSize(500, 300); detailedArea.setFont(new java.awt.Font("Arial", java.awt.Font.PLAIN, 11)); StringWriter opDetail = new StringWriter(); actionPrint(new PrintWriter(opDetail)); detailedArea.setText(new String(opDetail.getBuffer())); JScrollPane scroll = new JScrollPane(detailedArea); actionPanel.add(scroll); getContentPane().add(actionPanel, "Center"); northToolBar = new javax.swing.JToolBar(); northToolBar.setLayout(new java.awt.FlowLayout()); northToolBar.setFloatable(false); jbn_Print = new javax.swing.JButton(); jbn_Print.setText(" Print "); jbn_Print.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbn_PrintActionPerformed(); } }); northToolBar.add(jbn_Print); jbn_OK = new javax.swing.JButton(); jbn_OK.setText(" Close "); jbn_OK.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jbn_OKActionPerformed(); } }); northToolBar.add(jbn_OK); getContentPane().add(northToolBar, "South"); }
public HelpFrame(JFrame f) { super("Help menu"); setSize(320, 240); setLocationRelativeTo(f); setResizable(false); JTextArea message = new JTextArea(); message.setEditable(false); message.setText( "Default keybindings:\n -Cmd+e to toggle terminal\n -Cmd+k to run\n -Cmd+/ to show help\n -Cmd+o for options\n\n" + "Special keywords: \n -'import' can be typed anywhere \n -'method' and then a method will compile\n\n" + "Other: \n -You can also use this for normal Java editing!"); add(message, "Center"); setVisible(true); }
private void buildInterface() { // Panel p to hold the label and text field JPanel panelInput = new JPanel(); panelInput.setLayout(new BorderLayout()); panelInput.add(buttonSelect, BorderLayout.EAST); panelInput.add(textFolder, BorderLayout.CENTER); textFolder.setEditable(false); textFolder.setText(System.getProperty("user.home") + "\\"); // Set default save location setLayout(new BorderLayout()); add(panelInput, BorderLayout.NORTH); add(new JScrollPane(textArea), BorderLayout.CENTER); textArea.setEditable(false); buttonSelect.setToolTipText(TOOL_TIP_SELECT_FOLDER); buttonSelect.addActionListener(new ButtonListener()); // Register listener }
public GeneralGUI(Whois whois) { super("Internic Whois"); this.server = whois; Container pane = this.getContentPane(); // whois.internic.net assumes a monospaced font, 72 columns across Font f = new Font("Monospaced", Font.PLAIN, 12); names.setFont(f); names.setEditable(false); JPanel CenterPanel = new JPanel(); CenterPanel.setLayout(new GridLayout(1, 1, 10, 10)); JScrollPane jsp = new JScrollPane(names); CenterPanel.add(jsp); pane.add("Center", CenterPanel); // You don't want the buttons in the south and north // to fill the entire sections so add Panels there // and use FlowLayouts in the Panel JPanel NorthPanel = new JPanel(); JPanel NorthPanelTop = new JPanel(); NorthPanelTop.setLayout(new FlowLayout(FlowLayout.LEFT)); NorthPanelTop.add(new JLabel("Whois: ")); NorthPanelTop.add("North", searchString); NorthPanelTop.add(exactMatch); NorthPanelTop.add(findButton); NorthPanel.setLayout(new BorderLayout(2, 1)); NorthPanel.add("North", NorthPanelTop); JPanel NorthPanelBottom = new JPanel(); NorthPanelBottom.setLayout(new GridLayout(1, 3, 5, 5)); NorthPanelBottom.add(initRecordType()); NorthPanelBottom.add(initSearchFields()); NorthPanelBottom.add(initServerChoice()); NorthPanel.add("Center", NorthPanelBottom); JPanel SouthPanel = new JPanel(); pane.add("North", NorthPanel); ActionListener al = new LookupNames(); findButton.addActionListener(al); searchString.addActionListener(al); }
/** * Creates a new instance of ListInputPanel with initialized components. * * @param file_parser An object that can bring up a file chooser, parse selected files and append * the extracted contents to this object's text area. The Load button is disabled if this is * null. */ public ListInputPanel(ListInputParser file_parser) { // Call superclass constructor super(new BorderLayout(4, 4)); // Store the file parser this.file_parser = file_parser; // Initialize layout settings int horizontal_gap = 4; int vertical_gap = 4; // Set up the button panel and attach action listeners to the buttons JPanel button_panel = new JPanel(new GridLayout(1, 4)); load_button = new JButton("Load"); save_button = new JButton("Save"); clear_button = new JButton("Clear"); organize_button = new JButton("Organize"); button_panel.add(load_button); button_panel.add(save_button); button_panel.add(clear_button); button_panel.add(organize_button); save_button.addActionListener(this); load_button.addActionListener(this); clear_button.addActionListener(this); organize_button.addActionListener(this); // Disable the load button if appropriate if (file_parser == null) load_button.setEnabled(false); // Prepare text_area text_area = new JTextArea(); text_area.setLineWrap(false); text_area.setEditable(true); text_area.setText(""); // Make scrollable JScrollPane scroll_pane = new JScrollPane(text_area); // Add contents to this JPanel add(button_panel, BorderLayout.NORTH); add(scroll_pane, BorderLayout.CENTER); }
public FileChooserDemo() { super(new BorderLayout()); // Create the log first, because the action listeners // need to refer to it. log = new JTextArea(5, 20); log.setMargin(new Insets(5, 5, 5, 5)); log.setEditable(false); JScrollPane logScrollPane = new JScrollPane(log); // Create a file chooser fc = new JFileChooser(); // Uncomment one of the following lines to try a different // file selection mode. The first allows just directories // to be selected (and, at least in the Java look and feel, // shown). The second allows both files and directories // to be selected. If you leave these lines commented out, // then the default mode (FILES_ONLY) will be used. // // fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); // Create the open button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). openButton = new JButton("Open a File...", createImageIcon("images/Open16.gif")); openButton.addActionListener(this); // Create the save button. We use the image from the JLF // Graphics Repository (but we extracted it from the jar). saveButton = new JButton("Save a File...", createImageIcon("images/Save16.gif")); saveButton.addActionListener(this); // For layout purposes, put the buttons in a separate panel JPanel buttonPanel = new JPanel(); // use FlowLayout buttonPanel.add(openButton); buttonPanel.add(saveButton); // Add the buttons and the log to this panel. add(buttonPanel, BorderLayout.PAGE_START); add(logScrollPane, BorderLayout.CENTER); }
/** 创建对话框面板 */ private void createPanel() { textArea = new JTextArea(); textArea.setEditable(false); textArea.setFont(new Font("aFont", Font.PLAIN, 12)); receiveTxt(); JPanel panel = new JPanel(); JButton button = new JButton("确定"); panel.add(button); add(textArea, BorderLayout.CENTER); add(panel, BorderLayout.SOUTH); button.addActionListener( (ActionEvent e) -> { setVisible(false); }); }
/** * Builds the components from the file and displays it. * * @param strFile the file to be read. */ public void build(int nType, String strFile, String strhelpfile) { m_nType = nType; m_strPath = (strFile != null) ? FileUtil.openPath(strFile) : ""; m_strHelpFile = strhelpfile; boolean bValidate = false; boolean bChecksum = false; if (nType == CONFIG) { setTitle("Configuration"); buildConfig(); } else { JComponent compDisplay = null; if (nType == DEFAULT) { m_pnlAccPolicy = new AccPolicyPanel(m_strPath); compDisplay = m_pnlAccPolicy; setTitle("Password Configuration"); } else if (nType == CHECKSUM) { m_pnlChecksum = new ChecksumPanel(m_strPath); compDisplay = m_pnlChecksum; setTitle("Checksum Configuration"); bValidate = true; bChecksum = true; } else { setTitle("Perform System Validation"); compDisplay = new JTextArea(); ((JTextArea) compDisplay).setEditable(false); bValidate = true; doBlink(); } m_pnlDisplay.removeAll(); m_pnlDisplay.setLayout(new BorderLayout()); m_pnlDisplay.add(compDisplay, BorderLayout.CENTER); setVisible(true); } validateButton.setVisible(bValidate); // abandonButton.setVisible(!bValidate); setAbandonEnabled(bValidate); m_btnChecksum.setVisible(bChecksum); }
/** Creates the GUI. */ public void majorLayout() { // // Setup Menu // JMenuBar menuBar = new JMenuBar(); JMenu file = new JMenu(ResourceHandler.getMessage("menu.file")); file.setMnemonic(ResourceHandler.getAcceleratorKey("menu.file")); file.add(exitMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.exit"))); exitMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.exit")); exitMenuItem.addActionListener(this); menuBar.add(file); JMenu edit = new JMenu(ResourceHandler.getMessage("menu.edit")); edit.setMnemonic(ResourceHandler.getAcceleratorKey("menu.edit")); edit.add(optionMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.option"))); optionMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.option")); optionMenuItem.addActionListener(this); menuBar.add(edit); JMenu help = new JMenu(ResourceHandler.getMessage("menu.help")); help.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help")); help.add(helpMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.help"))); helpMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.help")); help.add(new JSeparator()); help.add(aboutMenuItem = new JMenuItem(ResourceHandler.getMessage("menu.about"))); aboutMenuItem.setMnemonic(ResourceHandler.getAcceleratorKey("menu.about")); helpMenuItem.addActionListener(this); aboutMenuItem.addActionListener(this); menuBar.add(help); setJMenuBar(menuBar); // // Setup main GUI // dirLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel0")); dirTF = new JTextField(); dirBttn = new JButton(ResourceHandler.getMessage("button.browse.dir")); dirBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.dir")); matchingLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel1")); matchingTF = new JTextField(ResourceHandler.getMessage("converter_gui.lablel2")); recursiveCheckBox = new JCheckBox(ResourceHandler.getMessage("converter_gui.lablel3")); recursiveCheckBox.setMnemonic(ResourceHandler.getAcceleratorKey("converter_gui.lablel3")); backupLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel5")); backupTF = new JTextField(); backupBttn = new JButton(ResourceHandler.getMessage("button.browse.backup")); backupBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.browse.backup")); templateLabel = new JLabel(ResourceHandler.getMessage("converter_gui.lablel7")); templateCh = new TemplateFileChoice(); staticVersioningLabel = new JLabel(ResourceHandler.getMessage("static.versioning.label")); String version = System.getProperty("java.version"); if (version.indexOf("-") > 0) { version = version.substring(0, version.indexOf("-")); } int dotIndex = version.indexOf("."); dotIndex = version.indexOf(".", dotIndex + 1); String familyVersion = version.substring(0, dotIndex); MessageFormat formatter = new MessageFormat(ResourceHandler.getMessage("static.versioning.radio.button")); staticVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {version})); staticVersioningRadioButton.setMnemonic( ResourceHandler.getAcceleratorKey("static.versioning.radio.button")); formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.radio.button")); dynamicVersioningRadioButton = new JRadioButton(formatter.format(new Object[] {familyVersion})); dynamicVersioningRadioButton.setMnemonic( ResourceHandler.getAcceleratorKey("dynamic.versioning.radio.button")); staticVersioningTextArea = new JTextArea(ResourceHandler.getMessage("static.versioning.text")); formatter = new MessageFormat(ResourceHandler.getMessage("dynamic.versioning.text")); dynamicVersioningTextArea = new JTextArea(formatter.format(new Object[] {familyVersion})); ButtonGroup versioningButtonGroup = new ButtonGroup(); versioningButtonGroup.add(staticVersioningRadioButton); versioningButtonGroup.add(dynamicVersioningRadioButton); runBttn = new JButton(ResourceHandler.getMessage("button.convert")); runBttn.setMnemonic(ResourceHandler.getAcceleratorKey("button.convert")); recursiveCheckBox.setOpaque(false); staticVersioningRadioButton.setOpaque(false); dynamicVersioningRadioButton.setOpaque(false); staticVersioningTextArea.setEditable(false); staticVersioningTextArea.setLineWrap(true); staticVersioningTextArea.setWrapStyleWord(true); dynamicVersioningTextArea.setEditable(false); dynamicVersioningTextArea.setLineWrap(true); dynamicVersioningTextArea.setWrapStyleWord(true); staticVersioningPanel.setLayout(new BorderLayout()); staticVersioningPanel.add(staticVersioningTextArea, "Center"); staticVersioningPanel.setBorder(new LineBorder(Color.black)); dynamicVersioningPanel.setLayout(new BorderLayout()); dynamicVersioningPanel.add(dynamicVersioningTextArea, "Center"); dynamicVersioningPanel.setBorder(new LineBorder(Color.black)); if (converter.isStaticVersioning()) { staticVersioningRadioButton.setSelected(true); } else { dynamicVersioningRadioButton.setSelected(true); } addListeners(); final int buf = 10, // Buffer (between components and form) sp = 10, // Space between components vsp = 5, // Vertical space indent = 20; // Indent between form (left edge) and component GridBagConstraints gbc = new GridBagConstraints(); GridBagLayout gbl = new GridBagLayout(); getContentPane().setLayout(gbl); // // Setup top panel // GridBagLayout topLayout = new GridBagLayout(); JPanel topPanel = new JPanel(); topPanel.setOpaque(false); topPanel.setLayout(topLayout); topLayout.setConstraints( dirLabel, new GridBagConstraints( 0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( dirTF, new GridBagConstraints( 1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( dirBttn, new GridBagConstraints( 2, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, sp, 0, 0), 0, 0)); topLayout.setConstraints( matchingLabel, new GridBagConstraints( 0, 1, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( matchingTF, new GridBagConstraints( 1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( recursiveCheckBox, new GridBagConstraints( 2, 1, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( backupLabel, new GridBagConstraints( 0, 3, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( backupTF, new GridBagConstraints( 1, 3, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( backupBttn, new GridBagConstraints( 2, 3, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(10, sp, 0, 0), 0, 0)); topLayout.setConstraints( templateLabel, new GridBagConstraints( 0, 4, 1, 1, 0, 0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( templateCh, new GridBagConstraints( 1, 4, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(vsp, 2, 0, 0), 0, 0)); topLayout.setConstraints( sep1, new GridBagConstraints( 0, 5, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0)); topLayout.setConstraints( staticVersioningLabel, new GridBagConstraints( 0, 6, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0)); topLayout.setConstraints( staticVersioningRadioButton, new GridBagConstraints( 0, 7, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( staticVersioningPanel, new GridBagConstraints( 0, 8, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(vsp, 25, 10, 0), 0, 0)); topLayout.setConstraints( dynamicVersioningRadioButton, new GridBagConstraints( 0, 9, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(vsp, 10, 0, 0), 0, 0)); topLayout.setConstraints( dynamicVersioningPanel, new GridBagConstraints( 0, 10, GridBagConstraints.REMAINDER, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(vsp, 25, 0, 0), 0, 0)); topLayout.setConstraints( sep2, new GridBagConstraints( 0, 11, GridBagConstraints.REMAINDER, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 0, 10), 0, 0)); invisibleBttn = new JButton(); invisibleBttn.setVisible(false); topLayout.setConstraints( invisibleBttn, new GridBagConstraints( 2, 6, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.CENTER, new Insets(indent, sp, 0, 0), 0, 0)); topPanel.add(dirLabel); topPanel.add(dirTF); topPanel.add(dirBttn); topPanel.add(matchingLabel); topPanel.add(matchingTF); topPanel.add(recursiveCheckBox); topPanel.add(backupLabel); topPanel.add(backupTF); topPanel.add(backupBttn); topPanel.add(templateLabel); topPanel.add(templateCh); topPanel.add(sep1); topPanel.add(staticVersioningLabel); topPanel.add(staticVersioningRadioButton); topPanel.add(staticVersioningPanel); topPanel.add(dynamicVersioningRadioButton); topPanel.add(dynamicVersioningPanel); topPanel.add(sep2); topPanel.add(invisibleBttn); // // Setup bottom panel // GridBagLayout buttomLayout = new GridBagLayout(); JPanel buttomPanel = new JPanel(); buttomPanel.setOpaque(false); buttomPanel.setLayout(buttomLayout); buttomLayout.setConstraints( runBttn, new GridBagConstraints( 3, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(sp, 0, 0, 0), 0, 0)); buttomPanel.add(runBttn); // // Setup main panel // GridBagLayout mainLayout = new GridBagLayout(); JPanel mainPanel = new JPanel(); mainPanel.setOpaque(false); mainPanel.setLayout(mainLayout); mainLayout.setConstraints( topPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(buf, buf, 0, buf), 0, 0)); mainLayout.setConstraints( buttomPanel, new GridBagConstraints( 0, 1, 1, 1, 1, 1, GridBagConstraints.SOUTH, GridBagConstraints.HORIZONTAL, new Insets(0, buf, buf, buf), 0, 0)); mainPanel.add(topPanel); mainPanel.add(buttomPanel); Border border = BorderFactory.createEtchedBorder(); mainPanel.setBorder(border); GridBagLayout layout = new GridBagLayout(); getContentPane().setLayout(layout); layout.setConstraints( mainPanel, new GridBagConstraints( 0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); getContentPane().add(mainPanel); pack(); setResizable(false); }
public EchoAWT() throws UnknownHostException { super("채팅 프로그램"); // 각종 정의 h = new JPanel(new GridLayout(2, 3)); m = new JPanel(new BorderLayout()); f = new JPanel(new BorderLayout()); s = new JPanel(new BorderLayout()); login = new JPanel(new BorderLayout()); // name = new JLabel(" 사용자 이름 "); name = new JLabel(" 메세지 입력 "); jta = new JTextArea(); // clientList = new JTextArea(0, 10); clientList = new JList(); jsp = new JScrollPane(jta); list = new JScrollPane(clientList); jtf = new JTextField("입력하세요."); hi = new JTextField("HOST IP 입력"); pi = new JTextField("PORT 입력"); localport = new JTextField("원하는 PORT 입력"); lid = new JTextField("ID를 입력하세요."); lpw = new JTextField("PW를 입력하세요."); serveropen = new JButton("서버 오픈"); textin = new JButton("입력"); clientin = new JButton("서버 접속"); conf = new JButton("로그인"); join = new JButton("회원가입"); addr = InetAddress.getLocalHost(); // 사용자 해상도 및 창 크기 설정 및 가져오기. Toolkit tk = Toolkit.getDefaultToolkit(); Dimension screenSize = tk.getScreenSize(); setSize(500, 500); Dimension d = getSize(); // 각종 버튼 및 텍스트 필드 리스너 jtf.addActionListener(this); hi.addActionListener(this); pi.addActionListener(this); localport.addActionListener(this); lid.addActionListener(this); lpw.addActionListener(this); conf.addActionListener(this); join.addActionListener(this); serveropen.addActionListener(this); clientin.addActionListener(this); textin.addActionListener(this); jtf.addFocusListener(this); hi.addFocusListener(this); pi.addFocusListener(this); localport.addFocusListener(this); lid.addFocusListener(this); lpw.addFocusListener(this); // 서버 접속 h.add(hi); h.add(pi); h.add(clientin); // 서버 생성 h.add(new JLabel("IP : " + addr.getHostAddress(), (int) CENTER_ALIGNMENT)); h.add(localport); h.add(serveropen); // 채팅글창 글 작성 막기 jta.setEditable(false); // 접속자 리스트 width 제한 clientList.setFixedCellWidth(d.width / 3); // 입력 창 f.add(name, "West"); f.add(jtf, "Center"); f.add(textin, "East"); // 접속자 확인창 s.add(new JLabel("접속자", (int) CENTER_ALIGNMENT), "North"); s.add(list, "Center"); // clientList.setEditable(false); // 메인 창 m.add(jsp, "Center"); m.add(s, "East"); // 프레임 설정 add(h, "North"); add(m, "Center"); add(f, "South"); // 로그인 다이얼로그 jd = new JDialog(); jd.setTitle("채팅 로그인"); jd.add(login); jd.setSize(200, 200); Dimension dd = jd.getSize(); jd.setLocation(screenSize.width / 2 - (dd.width / 2), screenSize.height / 2 - (dd.height / 2)); jd.setVisible(true); // 로그인창 JPanel lm = new JPanel(new GridLayout(4, 1)); lm.add(lid); lm.add(new Label()); lm.add(lpw); lm.add(new Label()); JPanel bt = new JPanel(); bt.add(conf); bt.add(join); login.add(new Label(), "North"); login.add(new Label(), "West"); login.add(new Label(), "East"); login.add(lm, "Center"); login.add(bt, "South"); // 창의 위치, 보임, EXIT 단추 활성화. setLocation(screenSize.width / 2 - (d.width / 2), screenSize.height / 2 - (d.height / 2)); setVisible(false); setDefaultCloseOperation(EXIT_ON_CLOSE); }
/** Creates a ComponentTree, loading the Components from the file at <code>path</code>. */ public ComponentTree(String path) { this.path = path; ttCount++; jTextArea = new JTextArea(); textArea = new JTextArea(); redirectSystemStreams(); frame = createFrame(); Container cPane = frame.getContentPane(); JMenuBar mb = createMenuBar(); TreeTableModel model = createModel(path); cPane.setLayout(new BorderLayout(5, 5)); Dimension dim = new Dimension(600, 600); cPane.setPreferredSize(dim); try { textArea.read(new FileReader(path), null); } catch (IOException e) { e.printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } treeTable = createTreeTable(model); textArea.setEditable(false); JScrollPane tp = new JScrollPane( textArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); JScrollPane sp = new JScrollPane( treeTable, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); JScrollPane cp = new JScrollPane( jTextArea, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); sp.getViewport().setBackground(Color.white); Dimension scrDim = new Dimension(300, 600); Dimension dime = new Dimension(300, 400); Dimension dimc = new Dimension(300, 200); sp.setLocation(0, 0); sp.setPreferredSize(dime); tp.setLocation(300, 0); tp.setPreferredSize(scrDim); cp.setLocation(0, 400); cp.setPreferredSize(dimc); cPane.add(sp, BorderLayout.LINE_START); cPane.add(tp, BorderLayout.CENTER); cPane.add(cp, BorderLayout.PAGE_END); cPane.setPreferredSize(dim); // frame.add(cPane); frame.setJMenuBar(mb); // frame.pack(); frame.setVisible(true); }
private void initComponents() { try { for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (Exception e) { // If Nimbus is not available, you can set the GUI to another look and feel. } usernameLabel = new JLabel(); usernameField = new JTextField(); chatroomScrollPane = new JScrollPane(); chatroomArea = new JTextArea(); chatMsgLabel = new JLabel(); chatMsgField = new JTextField(); chatIPLabel = new JLabel(); chatIPField = new JTextField(); portLabel = new JLabel(); portField = new JTextField(); joinButton = new JToggleButton(); sendButton = new JButton(); leaveButton = new JButton(); exitButton = new JButton(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); usernameLabel.setText("Username:"******" "); chatroomArea.setEditable(false); chatroomArea.setColumns(20); chatroomArea.setRows(5); chatroomScrollPane.setViewportView(chatroomArea); chatMsgLabel.setText("Chat Message:"); chatIPLabel.setText("Chat Group IP"); chatIPField.setText("224.27.43.188"); portLabel.setText("Port"); portField.setText("4001"); joinButton.setText("JOIN CHAT"); joinButton.addActionListener(this); sendButton.setText("SEND MESSAGE"); sendButton.addActionListener(this); leaveButton.setText("LEAVE CHAT"); leaveButton.addActionListener(this); exitButton.setText("EXIT"); exitButton.addActionListener(this); GroupLayout layout = new GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( GroupLayout.Alignment.TRAILING, layout .createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(usernameLabel) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addComponent( usernameField, GroupLayout.PREFERRED_SIZE, 83, GroupLayout.PREFERRED_SIZE)) .addComponent(chatroomScrollPane) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addComponent(chatMsgLabel) .addPreferredGap( LayoutStyle.ComponentPlacement.RELATED) .addComponent( chatMsgField, GroupLayout.PREFERRED_SIZE, 296, GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createSequentialGroup() .addGroup( layout .createParallelGroup( GroupLayout.Alignment.TRAILING, false) .addComponent( chatIPField, GroupLayout.Alignment.LEADING) .addComponent( chatIPLabel, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addComponent( portField, GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE) .addComponent( portLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(18, 18, 18) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addGroup( layout .createSequentialGroup() .addComponent(leaveButton) .addGap(18, 18, 18) .addComponent( exitButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup( layout .createSequentialGroup() .addComponent( joinButton, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(sendButton))))) .addGap(0, 8, Short.MAX_VALUE))) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING, false) .addComponent(usernameField) .addComponent( usernameLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(3, 3, 3) .addComponent( chatroomScrollPane, GroupLayout.PREFERRED_SIZE, 178, GroupLayout.PREFERRED_SIZE) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent( chatMsgLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( chatMsgField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(chatIPLabel) .addComponent(portLabel)) .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent( chatIPField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent( portField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))) .addGroup( layout .createSequentialGroup() .addGap(16, 16, 16) .addGroup( layout .createParallelGroup( GroupLayout.Alignment.LEADING, false) .addComponent( joinButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( sendButton, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGap(8, 8, 8) .addGroup( layout .createParallelGroup(GroupLayout.Alignment.BASELINE) .addComponent(leaveButton) .addComponent(exitButton)))) .addGap(17, 17, 17))); pack(); setVisible(true); }
/** * The constructor creates the NodeTable and DirectedGraph taken the information from files * lines-gbg.txt and stops-gbg.txt and makes itself visible. */ public ShortRoute(String file) { // try to convert to UTF-8 across plattforms to make Swedish chars work // System.out.println("charset = " + java.nio.charset.Charset.defaultCharset()); // MacRoman macintosh Windows-1252 ISO 8859-1 UTF-8 try { // convert whatever this file is encoded in to UTF-8, // kill the exception (can't happen) introText = new String( introText.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8"); felTextStart = new String( felTextStart.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8"); felTextSlut = new String( felTextSlut.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8"); frome = new String(frome.getBytes(java.nio.charset.Charset.defaultCharset().toString()), "UTF-8"); } catch (UnsupportedEncodingException e) { System.exit(0); } // read the graph and draw it in a separate window // creates the graph and fills the p-queue "names" karta.setLocation(50, 250); if (file == null) { readAndDrawGraph(); } else { readAndDrawBIGGraph(file); } System.out.println("Version with sorting fixed"); // debug // now to the graphics in the Frame // Left part // select is a panel for structuring the left part // i.e label, textfield for "from", label, textfield for "to" JPanel select = new JPanel(new GridLayout(4, 1)); select.setBackground(Color.yellow); select.add(new JLabel("Ange startpunkt !", JLabel.CENTER)); select.add(from); select.add(new JLabel("Ange slutpunkt !", JLabel.CENTER)); select.add(to); from.setBackground(Color.white); from.setForeground(Color.blue); to.setBackground(Color.white); to.setForeground(Color.blue); from.addActionListener(this); to.addActionListener(this); // Middle part // route is the middle text area part where messages are displayed // give the middle text area a scrollbar to the right route = new JTextArea(introText, 12, 40); route.setEditable(false); JScrollPane routeScrollPane = new JScrollPane(route); routeScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); route.setBackground(Color.white); route.setForeground(Color.blue); // Rigth part JLabel head = new JLabel(" **** Alternativ ***** "); head.setForeground(Color.red); // add all stations to the right scrollpane // tanken är att dom skall vara valbara men det fungerar inte än // En JList vill ha en ListModel som parameter // En ListModel är ett interface som implementeras av klassen AbstractListModel // DefaultListModel ärver AbstractListModel DefaultListModel<String> valList = new DefaultListModel<String>(); JList<String> alternativ = new JList<String>(valList); alternativ.setBackground(Color.white); alternativ.setForeground(Color.blue); // add a scroll pane to the station list in alternativ stationList = new JScrollPane(alternativ); // read names from p-queue and load them into the list while (!names.isEmpty()) valList.addElement(names.poll()); // panel for structure JPanel valPanel = new JPanel(new BorderLayout()); valPanel.setBackground(Color.white); valPanel.add(head, "North"); valPanel.add(stationList, "Center"); // put it all together in the frame add(select, "West"); add(routeScrollPane, "Center"); add(valPanel, "East"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack(); setVisible(true); } // end ShortRoute
public GUI() { // Frame frame = new JFrame("HardwareSwap Notifier"); // Panels panel = new JPanel(); group1 = new JPanel(); group2 = new JPanel(); group3 = new JPanel(); group4 = new JPanel(); group5 = new JPanel(); group6 = new JPanel(); group7 = new JPanel(); group8 = new JPanel(); // Menu Bar menus = new JMenuBar(); fileMenu = new JMenu("File"); clearCurrent = new JMenuItem("Clear"); quitItem = new JMenuItem("Quit"); load = new JMenuItem("Load"); saveCurrent = new JMenuItem("Save All"); clearSaved = new JMenuItem("Clear Saved"); removeItem = new JMenuItem("Remove Item"); removePhone = new JMenuItem("Remove Phone"); saveCurrent = new JMenuItem("Save Current"); helpMenu = new JMenu("Help"); help = new JMenuItem("How To Use"); about = new JMenuItem("About"); // Buttons add1 = new JButton("Add"); add2 = new JButton("Add"); start = new JButton("Start"); stop = new JButton("Stop"); save1 = new JButton("Add/Save"); save2 = new JButton("Add/Save"); show = new JButton("Display Data"); add1.setFocusPainted(false); add2.setFocusPainted(false); start.setFocusPainted(false); stop.setFocusPainted(false); save1.setFocusPainted(false); save2.setFocusPainted(false); show.setFocusPainted(false); stop.setEnabled(false); // CheckBox remove = new JCheckBox("Remove items when found"); remove.setFocusable(false); // Listener ButtonListener listener = new ButtonListener(); add1.addActionListener(listener); add2.addActionListener(listener); start.addActionListener(listener); stop.addActionListener(listener); load.addActionListener(listener); save1.addActionListener(listener); save2.addActionListener(listener); saveCurrent.addActionListener(listener); show.addActionListener(listener); quitItem.addActionListener(listener); clearCurrent.addActionListener(listener); clearSaved.addActionListener(listener); saveCurrent.addActionListener(listener); help.addActionListener(listener); about.addActionListener(listener); removePhone.addActionListener(listener); removeItem.addActionListener(listener); remove.addActionListener(listener); // Carrier Selection options = new String[10]; options[0] = "AT&T"; options[1] = "Boost Mobile"; options[2] = "Cellular One"; options[3] = "Nextel"; options[4] = "T-Mobile"; options[5] = "Tracfone"; options[6] = "US Cellular"; options[7] = "Sprint"; options[8] = "Verizon"; options[9] = "Virgin Mobile"; carriers = new JComboBox<String>(options); // Text Fields searchName = new JTextField(15); item = new JTextField(15); phone = new JTextField(15); interval2 = new JTextField(15); results = new JTextArea(10, 20); JScrollPane scrollPane = new JScrollPane(results); results.setEditable(false); // Interval intOptions = new SpinnerNumberModel(5, 1, 60, 1); interval = new JSpinner(intOptions); JFormattedTextField tf = ((JSpinner.DefaultEditor) interval.getEditor()).getTextField(); tf.setHorizontalAlignment(JFormattedTextField.LEFT); // Background panelBackground = new Color(237, 237, 237); panel.setBackground(panelBackground); searchName.setBackground(panelBackground); item.setBackground(panelBackground); phone.setBackground(panelBackground); interval.setBackground(panelBackground); // Panel Layouts panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); group1.setLayout(new BoxLayout(group1, BoxLayout.PAGE_AXIS)); group2.setLayout(new BoxLayout(group2, BoxLayout.X_AXIS)); group3.setLayout(new BoxLayout(group3, BoxLayout.PAGE_AXIS)); group4.setLayout(new BoxLayout(group4, BoxLayout.X_AXIS)); group5.setLayout(new BoxLayout(group5, BoxLayout.X_AXIS)); group6.setLayout(new BoxLayout(group6, BoxLayout.X_AXIS)); group7.setLayout(new BoxLayout(group7, BoxLayout.X_AXIS)); group8.setLayout(new BoxLayout(group8, BoxLayout.X_AXIS)); // Borders searchName.setBorder( BorderFactory.createTitledBorder( null, "Search Name", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); item.setBorder( BorderFactory.createTitledBorder( null, "Item", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); phone.setBorder( BorderFactory.createTitledBorder( null, "Cell Phone", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); group5.setBorder( BorderFactory.createTitledBorder( null, "Check Interval (mins)", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_JUSTIFICATION, null, Color.DARK_GRAY)); // Sizes panel.setPreferredSize(new Dimension(200, 0)); searchName.setMaximumSize(new Dimension(190, 50)); item.setMaximumSize(new Dimension(190, 50)); phone.setMaximumSize(new Dimension(185, 50)); carriers.setMaximumSize(new Dimension(175, 20)); group5.setPreferredSize(new Dimension(190, 47)); group5.setMaximumSize(new Dimension(190, 47)); add1.setMaximumSize(new Dimension(90, 20)); save1.setMaximumSize(new Dimension(90, 20)); add2.setMaximumSize(new Dimension(90, 20)); save2.setMaximumSize(new Dimension(90, 20)); start.setMaximumSize(new Dimension(90, 20)); stop.setMaximumSize(new Dimension(90, 20)); show.setMaximumSize(new Dimension(120, 20)); // Add file menu items fileMenu.add(clearCurrent); fileMenu.add(clearSaved); fileMenu.add(load); fileMenu.add(removeItem); fileMenu.add(removePhone); fileMenu.add(saveCurrent); fileMenu.add(quitItem); // Add help menu items helpMenu.add(help); helpMenu.add(about); // Add to menu bar menus.add(fileMenu); menus.add(helpMenu); // Add items to panel group1.add(searchName); group1.add(item); group2.add(add1); group2.add(Box.createHorizontalStrut(10)); group2.add(save1); group6.add(remove); group3.add(phone); group3.add(Box.createVerticalStrut(10)); group3.add(carriers); group4.add(add2); group4.add(Box.createHorizontalStrut(10)); group4.add(save2); group5.add(interval); group7.add(show); group8.add(start); group8.add(Box.createHorizontalStrut(10)); group8.add(stop); panel.add(Box.createVerticalStrut(10)); panel.add(group1); panel.add(Box.createVerticalStrut(10)); panel.add(group2); panel.add(Box.createVerticalStrut(40)); panel.add(group3); panel.add(Box.createVerticalStrut(10)); panel.add(group4); panel.add(Box.createVerticalStrut(40)); panel.add(group5); panel.add(Box.createVerticalStrut(30)); panel.add(group6); panel.add(Box.createVerticalStrut(40)); panel.add(group7); panel.add(Box.createVerticalStrut(10)); panel.add(group8); panel.add(Box.createVerticalStrut(10)); // Setup frame frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setJMenuBar(menus); frame.add(scrollPane); frame.add(BorderLayout.EAST, panel); frame.pack(); frame.setSize(new Dimension(670, 620)); frame.setVisible(true); }
public JChat() { this.setSize(500, 600); this.setResizable(false); this.setLayout(new BorderLayout()); JPanel topPanel = new JPanel(); topPanel.setLayout(new GridLayout(2, 1)); // set up buttons openChat = new JButton("Open to chat"); openChat.addActionListener(new OpenChat()); chatWith = new JButton("Chat with"); chatWith.addActionListener(new ChatWith()); send = new JButton("send"); send.addActionListener(new Send()); send.setEnabled(false); InputMap inputMap = send.getInputMap(JButton.WHEN_IN_FOCUSED_WINDOW); KeyStroke enter = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0); inputMap.put(enter, "ENTER"); send.getActionMap().put("ENTER", new ClickAction(send)); // set up labels pickPort = new JLabel(); pickPort.setText("Pick your port number:"); desPort = new JLabel(); desPort.setText("Or enter a destinaltion port number:"); // set up text fields pickText = new JTextField(); pickText.setPreferredSize(new Dimension(150, 30)); desText = new JTextField(); desText.setPreferredSize(new Dimension(150, 30)); chatText = new JTextField(); chatText.setPreferredSize(new Dimension(400, 30)); chatText.setEnabled(false); JPanel top1 = new JPanel(); top1.add(pickPort); top1.add(pickText); top1.add(openChat); JPanel top2 = new JPanel(); top2.add(desPort); top2.add(desText); top2.add(chatWith); topPanel.add(top1); topPanel.add(top2); chatField = new JTextArea(); chatField.setAutoscrolls(true); chatField.setDragEnabled(true); chatField.setEditable(false); chatField.setAlignmentY(TOP_ALIGNMENT); JPanel bottomPanel = new JPanel(); bottomPanel.add(chatText); bottomPanel.add(send); this.add(topPanel, BorderLayout.NORTH); this.add(chatField, BorderLayout.CENTER); this.add(bottomPanel, BorderLayout.SOUTH); this.setVisible(true); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
public void makeGUI() { frm = new JFrame(); c = frm.getContentPane(); btnImport = new JButton("Import"); btnImport.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureImport(); } }); btnMove = new JButton("Move"); btnMove.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureMove(); } }); btnDelete = new JButton("Delete"); btnDelete.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureDelete(); } }); btnAnalyse = new JButton("Analyse"); btnAnalyse.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent arg0) { secureAnalysis(); } }); tblItems = new JTable(store); tblItems.setRowSorter(tableSorter); tblItems.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); tblItems.setFillsViewportHeight(true); tblItems.getRowSorter().toggleSortOrder(Storage.COL_DATE); tblItems.addMouseListener( new MouseListener() { public void mouseClicked(MouseEvent e) { if (e.getButton() == MouseEvent.BUTTON3) { tblItems.setRowSelectionInterval( e.getY() / tblItems.getRowHeight(), e.getY() / tblItems.getRowHeight()); } if (e.getClickCount() > 1 || e.getButton() == MouseEvent.BUTTON3) { int idx = tblItems.convertRowIndexToModel(tblItems.getSelectedRow()); secureExport(idx); } } public void mouseEntered(MouseEvent arg0) {} public void mouseExited(MouseEvent arg0) {} public void mousePressed(MouseEvent arg0) {} public void mouseReleased(MouseEvent arg0) {} }); txaStatus = new JTextArea(TXA_HEIGHT, TXA_WIDTH); txaStatus.setEditable(false); txaStatus.setBorder(BorderFactory.createTitledBorder("Status")); txaSearch = new JTextArea(4, TXA_WIDTH); txaSearch.setBorder(BorderFactory.createTitledBorder("Search")); txaSearch.addKeyListener( new KeyListener() { public void keyPressed(KeyEvent arg0) {} public void keyReleased(KeyEvent arg0) { filterBase(txaSearch.getText()); // EXPORT settings here, as in mass export (export everything) if (allowExport && txaSearch.getText().equalsIgnoreCase(CMD_EXPORT)) { // txaSearch.setText(""); if (JOptionPane.showConfirmDialog( frm, "Do you really want to export the whole secure base?", "Confirm Export", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) { totalExport(); } } // LOST X IMPORT asin look through the store for files not listed if (txaSearch.getText().equalsIgnoreCase(CMD_STOCKTAKE)) { for (int i = 0; i < storeLocs.size(); i++) { if (store.stockTake(i)) needsSave = true; } } } public void keyTyped(KeyEvent arg0) {} }); JPanel pnlTop = new JPanel(new GridLayout(1, 4)); JPanel pnlEast = new JPanel(new BorderLayout()); JPanel pnlCenterEast = new JPanel(new BorderLayout()); JScrollPane jspItems = new JScrollPane(tblItems); pnlTop.add(btnImport); pnlTop.add(btnMove); pnlTop.add(btnDelete); pnlTop.add(btnAnalyse); pnlCenterEast.add(txaStatus, BorderLayout.CENTER); pnlCenterEast.add(txaSearch, BorderLayout.NORTH); // pnlEast.add(pswPass, BorderLayout.NORTH); pnlEast.add(pnlCenterEast, BorderLayout.CENTER); c.setLayout(new BorderLayout()); c.add(pnlTop, BorderLayout.NORTH); c.add(pnlEast, BorderLayout.EAST); c.add(jspItems, BorderLayout.CENTER); frm.setContentPane(c); }
/** * Method generated by IntelliJ IDEA GUI Designer >>> IMPORTANT!! <<< DO NOT edit this method OR * call it in your code! * * @noinspection ALL */ private void $$$setupUI$$$() { rootPanel = new JPanel(); rootPanel.setLayout(new GridLayoutManager(3, 1, new Insets(0, 0, 0, 0), -1, -1)); final JToolBar toolBar1 = new JToolBar(); rootPanel.add( toolBar1, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_FIXED, null, new Dimension(-1, 20), null, 0, false)); openSrcButton = new JButton(); openSrcButton.setText("Open Src"); openSrcButton.setToolTipText("Open source file"); toolBar1.add(openSrcButton); openBinButton = new JButton(); openBinButton.setEnabled(true); openBinButton.setText("Open Bin"); openBinButton.setToolTipText("Open and disassemble binaries"); toolBar1.add(openBinButton); saveSrcButton = new JButton(); saveSrcButton.setEnabled(true); saveSrcButton.setText("Save Src"); saveSrcButton.setToolTipText("Save sources"); toolBar1.add(saveSrcButton); saveBinButton = new JButton(); saveBinButton.setEnabled(true); saveBinButton.setText("Save Bin"); saveBinButton.setToolTipText("Save assembled binary"); toolBar1.add(saveBinButton); final JToolBar.Separator toolBar$Separator1 = new JToolBar.Separator(); toolBar1.add(toolBar$Separator1); asmButton = new JButton(); asmButton.setText("Asm"); asmButton.setToolTipText("Assemble sources"); toolBar1.add(asmButton); final JToolBar.Separator toolBar$Separator2 = new JToolBar.Separator(); toolBar1.add(toolBar$Separator2); hardResetButton = new JButton(); hardResetButton.setEnabled(true); hardResetButton.setText("Hard Reset"); hardResetButton.setToolTipText("Hard Reset - zeroize memory and reupload binary"); toolBar1.add(hardResetButton); resetButton = new JButton(); resetButton.setEnabled(true); resetButton.setText("Reset"); resetButton.setToolTipText("Reset CPU (registers to zero)"); toolBar1.add(resetButton); execButton = new JButton(); execButton.setEnabled(true); execButton.setText("Exec"); execButton.setToolTipText("Run forever"); toolBar1.add(execButton); pauseButton = new JButton(); pauseButton.setEnabled(false); pauseButton.setText("Pause"); pauseButton.setToolTipText("Pause execution"); toolBar1.add(pauseButton); runButton = new JButton(); runButton.setEnabled(true); runButton.setText("Run"); runButton.setToolTipText("Run until breakpoint/reserved"); toolBar1.add(runButton); stepButton = new JButton(); stepButton.setEnabled(true); stepButton.setText("Step"); stepButton.setToolTipText("Execute one instruction"); toolBar1.add(stepButton); final JToolBar.Separator toolBar$Separator3 = new JToolBar.Separator(); toolBar1.add(toolBar$Separator3); breakpointButton = new JButton(); breakpointButton.setEnabled(true); breakpointButton.setText("Breakpoint"); breakpointButton.setToolTipText("Toggle breakpoint on instruction address"); toolBar1.add(breakpointButton); final JPanel panel1 = new JPanel(); panel1.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); rootPanel.add( panel1, new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); final JLabel label1 = new JLabel(); label1.setText("Source"); panel1.add( label1, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label2 = new JLabel(); label2.setText("Memory"); panel1.add( label2, new GridConstraints( 0, 1, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final JLabel label3 = new JLabel(); label3.setText("Registers"); panel1.add( label3, new GridConstraints( 0, 2, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); memoryScrollPane = new JScrollPane(); panel1.add( memoryScrollPane, new GridConstraints( 1, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(600, -1), null, 0, false)); memoryTable = new JTable(); memoryScrollPane.setViewportView(memoryTable); final JScrollPane scrollPane1 = new JScrollPane(); panel1.add( scrollPane1, new GridConstraints( 1, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(100, -1), null, 0, false)); registersTable = new JTable(); scrollPane1.setViewportView(registersTable); sourceScrollPane = new JScrollPane(); panel1.add( sourceScrollPane, new GridConstraints( 1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(500, 400), null, 0, false)); sourceTextarea = new JTextArea(); sourceTextarea.setFont(new Font("Courier New", sourceTextarea.getFont().getStyle(), 12)); sourceTextarea.setText( "; Input your program here\n set a, 1\n add a, 1\n ife a, 2\n set a, 3\n:mainloop\n ife [message + I], 0\n set pc, end\n set a, [message + I]\n add a, 0xA100\n set [0x8000 + I], a\n add i, 1\n set pc, mainloop\n:message dat \"Hello, world!\", 0\n:end set pc, end"); sourceScrollPane.setViewportView(sourceTextarea); final JPanel panel2 = new JPanel(); panel2.setLayout(new GridLayoutManager(2, 3, new Insets(0, 0, 0, 0), -1, -1)); panel2.setVisible(false); rootPanel.add( panel2, new GridConstraints( 2, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null, 0, false)); consoleTextarea = new JTextArea(); consoleTextarea.setEditable(true); panel2.add( consoleTextarea, new GridConstraints( 1, 0, 1, 3, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, GridConstraints.SIZEPOLICY_WANT_GROW, GridConstraints.SIZEPOLICY_WANT_GROW, null, new Dimension(150, 200), null, 0, false)); final JLabel label4 = new JLabel(); label4.setText("Console"); panel2.add( label4, new GridConstraints( 0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_FIXED, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); clearButton = new JButton(); clearButton.setText("Clear"); panel2.add( clearButton, new GridConstraints( 0, 1, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null, 0, false)); final Spacer spacer1 = new Spacer(); panel2.add( spacer1, new GridConstraints( 0, 2, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_HORIZONTAL, GridConstraints.SIZEPOLICY_WANT_GROW, 1, null, null, null, 0, false)); }
/** * Inizialize frame components * * @throws CMSException * @throws FileNotFoundException * @throws IOException * @throws GeneralSecurityException */ private void initComponents() throws CMSException, FileNotFoundException, IOException, GeneralSecurityException { // ********************************* panel4 = new JPanel(); label2 = new JLabel(); textPane1 = new JTextPane(); panel5 = new JPanel(); textArea1 = new JTextArea(); textArea2 = new JTextArea(); progressBar = new JProgressBar(); textPane2 = new JTextPane(); textField1 = new JTextField(); button1 = new JButton(); panel6 = new JPanel(); button2 = new JButton(); button3 = new JButton(); button4 = new JButton(); GridBagConstraints gbc; // ======== this ======== Container contentPane = getContentPane(); contentPane.setLayout(new GridBagLayout()); ((GridBagLayout) contentPane.getLayout()).columnWidths = new int[] {165, 0, 0}; ((GridBagLayout) contentPane.getLayout()).rowHeights = new int[] {105, 50, 0}; ((GridBagLayout) contentPane.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4}; ((GridBagLayout) contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4}; // ======== panel4 ======== { panel4.setBackground(Color.white); panel4.setLayout(new GridBagLayout()); ((GridBagLayout) panel4.getLayout()).columnWidths = new int[] {160, 0}; ((GridBagLayout) panel4.getLayout()).rowHeights = new int[] {0, 0, 0}; ((GridBagLayout) panel4.getLayout()).columnWeights = new double[] {0.0, 1.0E-4}; ((GridBagLayout) panel4.getLayout()).rowWeights = new double[] {1.0, 1.0, 1.0E-4}; // ---- label2 ---- label2.setIcon( new ImageIcon( "images" + System.getProperty("file.separator") + "logo-freesigner-piccolo.png")); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets.bottom = 5; panel4.add(label2, gbc); // ---- textPane1 ---- textPane1.setFont(new Font("Verdana", Font.BOLD, 12)); textPane1.setText("Lettura\ncertificati\nda token"); textPane1.setEditable(false); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.anchor = GridBagConstraints.NORTHWEST; panel4.add(textPane1, gbc); } gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; gbc.insets.bottom = 5; gbc.insets.right = 5; contentPane.add(panel4, gbc); // ======== panel5 ======== { panel5.setBackground(Color.white); panel5.setLayout(new GridBagLayout()); ((GridBagLayout) panel5.getLayout()).columnWidths = new int[] {0, 205, 0, 0}; ((GridBagLayout) panel5.getLayout()).rowHeights = new int[] {100, 0, 30, 30, 0}; ((GridBagLayout) panel5.getLayout()).columnWeights = new double[] {1.0, 0.0, 1.0, 1.0E-4}; ((GridBagLayout) panel5.getLayout()).rowWeights = new double[] {0.0, 0.0, 1.0, 1.0, 1.0E-4}; // ---- textArea1 ---- textArea1.setFont(new Font("Verdana", Font.BOLD, 14)); textArea1.setText("Lettura certificati da token"); textArea1.setEditable(false); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.VERTICAL; gbc.insets.bottom = 5; panel5.add(textArea1, gbc); // ---- textArea2 ---- textArea2.setFont(new Font("Verdana", Font.PLAIN, 12)); textArea2.setText("Ricerca certificati...\n"); textArea2.setEditable(false); textArea2.setColumns(30); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 1; gbc.gridwidth = 3; gbc.fill = GridBagConstraints.BOTH; panel5.add(textArea2, gbc); progressBar.setValue(0); progressBar.setMaximum(1); progressBar.setStringPainted(true); progressBar.setBounds(0, 0, 300, 150); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 2; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets.bottom = 5; gbc.insets.right = 5; gbc.gridwidth = 3; panel5.add(progressBar, gbc); } gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 0; gbc.fill = GridBagConstraints.BOTH; gbc.insets.bottom = 5; contentPane.add(panel5, gbc); // ======== panel6 ======== { panel6.setBackground(Color.white); panel6.setLayout(new GridBagLayout()); ((GridBagLayout) panel6.getLayout()).columnWidths = new int[] {0, 0, 0, 0}; ((GridBagLayout) panel6.getLayout()).rowHeights = new int[] {0, 0}; ((GridBagLayout) panel6.getLayout()).columnWeights = new double[] {1.0, 1.0, 1.0, 1.0E-4}; ((GridBagLayout) panel6.getLayout()).rowWeights = new double[] {1.0, 1.0E-4}; // ---- button2 ---- button2.setText("Indietro"); gbc = new GridBagConstraints(); gbc.gridx = 0; gbc.gridy = 0; gbc.insets.right = 5; button2.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent e) { frame.hide(); FreeSignerSignApplet nuovo = new FreeSignerSignApplet(); } }); // panel6.add(button2, gbc); // ---- button4 ---- button4.setText("Annulla"); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = 0; // panel6.add(button4, gbc); } gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.gridy = 1; gbc.fill = GridBagConstraints.BOTH; contentPane.add(panel6, gbc); contentPane.setBackground(Color.white); frame = new JFrame(); frame.setContentPane(contentPane); frame.setTitle("Freesigner"); frame.setSize(300, 150); frame.setResizable(false); frame.pack(); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((d.width - frame.getWidth()) / 2, (d.height - frame.getHeight()) / 2); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); timer = new Timer( 10, new ActionListener() { public void actionPerformed(ActionEvent evt) { frame.show(); if (task.getMessage() != null) { String s = new String(); s = task.getMessage(); s = s.substring(0, Math.min(60, s.length())); textArea2.setText(s + " "); progressBar.setValue(task.getStatus()); } if (task.isDone()) { timer.stop(); // Finalizzo la cryptoki, onde evitare // successivi errori PKCS11 "cryptoki alreadi initialized" if ((task != null)) task.libFinalize(); ArrayList slotInfos = task.getSlotInfos(); if ((slotInfos == null) || slotInfos.isEmpty()) { frame.show(); JOptionPane.showMessageDialog( frame, "Controllare la presenza sul sistema\n" + "della libreria PKCS11 impostata.", "Nessun lettore rilevato", JOptionPane.WARNING_MESSAGE); frame.hide(); } else { String st = task.getCRLerror(); if (st.length() > 0) { timer.stop(); JOptionPane.showMessageDialog( frame, "C'è stato un errore nella verifica CRL.\n" + st, "Errore verifica CRL", JOptionPane.ERROR_MESSAGE); frame.hide(); FreeSignerSignApplet nuovo = new FreeSignerSignApplet(); } if (task.getDifferentCerts() == 0) { if (task.getCIr() != null) { JOptionPane.showMessageDialog( frame, "La carta " + task.getCardDescription() + " nel lettore " + conf.getReader() + " non contiene certificati", "Attenzione", JOptionPane.WARNING_MESSAGE); } else JOptionPane.showMessageDialog( frame, task.getMessage(), "Errore:", JOptionPane.ERROR_MESSAGE); } frame.hide(); // confFrame.createTreeAndTokenNodes(task.getSlotInfos()); } } } }); }
public helpMenu() { helpMenuPanel = new JPanel(); back = new JButton(); back = new JButton("back"); // ----------------------------------------- The instructions that will be displayed String str = new String( "MOVIE DATABASE\n" + "This program is to allow you to personally keep track of movies \n" + "This functionalities of this database are\n" + "- Adding a new record\n" + "- Editing a record\n" + "- Deleting a record\n" + "- Sorting records\n" + "- Searching records\n" + "- Saving and Loading the data of the database\n" + "\n" + "To make a NEW RECORD\n" + "Click ‘new record’ on the top left of the screen\n" + "a new window will pop up where you can fill in information about the movie.\n" + "Make sure to fill in the name of the movie, this is the piece of information that MUST be filled in\n" + "\n" + "To EDIT A RECORD\n" + "\n" + "Click ‘edit record’ on the top left of the screen\n" + "A window will appear where you can enter the ID Number of the record you want to edit.\n" + "Another window will appear with the information of that record. At this point, you can begin editing\n" + "the information of that record\n" + "\n" + "To DELETE RECORD\n" + "\n" + "Click 'delete record’ on the top left of the screen\n" + "A Window will appear where you can enter the ID Number of the record you want to delete\n" + "After entering the ID Number of the record you want to delete, you can press okay and that record will\n" + "be deleted\n" + "\n" + "To SORT RECORDS\n" + "\n" + "The column name of each field is also a Button.\n" + "By pressing any of the column labels, you sort the records by the label you clicked\n" + "e.g. if you want to sort the records by release year, you would click the release year header\n" + "\n" + "NOTE: If you have searched through records and want to sort the records again, you have to click the\n" + "“Clear Parameters button”. This will allow you to see all the records again and allow the sort\n" + "functions to work again.\n" + "\n" + "To SEARCH RECORDS\n" + "\n" + "There is a text field above each field name. Over the field you can type in what you want to search\n" + "for in that field. e.g. if you wanted to search for movies that were made in 1999, you would type 1999\n" + "in the textfield above release year\n" + "Afterwards, click the Search Button and the program will return all of the records\n" + "that match your search.\n" + "\n" + "This search is also capable of searching with multiple parameters,e.g. if you wanted to search for movies \n" + "with the word 'the' in it, that also have a movie rating of R, you would type in 'the' in the textfield \n" + "above the moviename header and a 'R' in the textfield above movie rating. After clicking search This will \n" + "return all movies rated R with a 'the' in the name of its movie"); TextArea = new JTextArea(str, 35, 55); // sets up the text area where the intructions will be TextArea.setEditable(false); Scroll = new JScrollPane(TextArea); // set up the text area so that you can scroll up and down it Scroll.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); // ----------------------------------------- adds the components to the Panel helpMenuPanel.add(Scroll); helpMenuPanel.add(back); helpFrame = new JFrame("HELP"); back.addActionListener( new ActionListener() { /* back * the method will make the instructions window invisible as if the user exit out of it * Pre: the user clicks back in the instructions window * Post: the instructions window will become invisible */ public void actionPerformed(ActionEvent e) { // this is executed when the button is pressed helpFrame.setVisible(false); } }); helpFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); // frame.setResizable(false); helpFrame.add(helpMenuPanel); // frame.setSize(200, 300); helpFrame.setVisible(true); helpFrame.pack(); }
// Constructor connection receiving a socket number public ClientGUI(String host, int port, int udpPort) { super("Clash of Clans"); defaultPort = port; defaultUDPPort = udpPort; defaultHost = host; // the server name and the port number JPanel serverAndPort = new JPanel(new GridLayout(1, 5, 1, 3)); tfServer = new JTextField(host); tfPort = new JTextField("" + port); tfPort.setHorizontalAlignment(SwingConstants.RIGHT); // CHAT COMPONENTS chatStatus = new JLabel("Please login first", SwingConstants.LEFT); chatField = new JTextField(18); chatField.setBackground(Color.WHITE); JPanel chatControls = new JPanel(); chatControls.add(chatStatus); chatControls.add(chatField); chatControls.setBounds(0, 0, 200, 50); chatArea = new JTextArea("Welcome to the Chat room\n", 80, 80); chatArea.setEditable(false); JScrollPane jsp = new JScrollPane(chatArea); jsp.setBounds(0, 50, 200, 550); JPanel chatPanel = new JPanel(null); chatPanel.setSize(1000, 600); chatPanel.add(chatControls); chatPanel.add(jsp); // LOGIN COMPONENTS mainLogin = new MainPanel(); mainLogin.add(new JLabel("Main Login")); usernameField = new JTextField("user", 15); passwordField = new JTextField("password", 15); login = new CButton("Login"); login.addActionListener(this); sideLogin = new SidePanel(new FlowLayout(FlowLayout.LEFT)); sideLogin.add(usernameField); sideLogin.add(passwordField); sideLogin.add(login); // MAIN MENU COMPONENTS mainMenu = new MainPanel(); mmLabel = new JLabel("Main Menu"); timer = new javax.swing.Timer(1000, this); mainMenu.add(mmLabel); sideMenu = new SidePanel(new FlowLayout(FlowLayout.LEFT)); cmButton = new CButton("Customize Map"); tmButton = new CButton("Troop Movement"); gsButton = new CButton("Game Start"); logout = new CButton("Logout"); cmButton.addActionListener(this); tmButton.addActionListener(this); gsButton.addActionListener(this); logout.addActionListener(this); sideMenu.add(cmButton); // sideMenu.add(tmButton); sideMenu.add(gsButton); sideMenu.add(logout); // CM COMPONENTS mainCM = new MainPanel(new GridLayout(mapSize, mapSize)); tiles = new Tile[mapSize][mapSize]; int tileSize = mainCM.getWidth() / mapSize; for (int i = 0; i < mapSize; i++) { tiles[i] = new Tile[mapSize]; for (int j = 0; j < mapSize; j++) { tiles[i][j] = new Tile(i, j); tiles[i][j].setPreferredSize(new Dimension(tileSize, tileSize)); tiles[i][j].setSize(tileSize, tileSize); tiles[i][j].addActionListener(this); if ((i + j) % 2 == 0) tiles[i][j].setBackground(new Color(102, 255, 51)); else tiles[i][j].setBackground(new Color(51, 204, 51)); mainCM.add(tiles[i][j]); } } sideCM = new SidePanel(new FlowLayout(FlowLayout.LEFT)); cmBack = new CButton("Main Menu"); cmBack.setSize(150, 30); cmBack.setPreferredSize(new Dimension(150, 30)); cmBack.addActionListener(this); sideCM.add(cmBack); // TM COMPONENTS mainTM = new MainPanel(null); mapTM = new Map(600); mapTM.setPreferredSize(new Dimension(600, 600)); mapTM.setSize(600, 600); mapTM.setBounds(0, 0, 600, 600); mainTM.add(mapTM); sideTM = new SidePanel(new FlowLayout(FlowLayout.LEFT)); tmBack = new CButton("Main Menu"); tmBack.setSize(150, 30); tmBack.setPreferredSize(new Dimension(150, 30)); tmBack.addActionListener(this); sideTM.add(tmBack); JRadioButton button; ButtonGroup group; ub = new ArrayList<JRadioButton>(); group = new ButtonGroup(); button = new JRadioButton("Barbarian"); button.addActionListener(this); ub.add(button); sideTM.add(button); group.add(button); button = new JRadioButton("Archer"); button.addActionListener(this); ub.add(button); sideTM.add(button); group.add(button); createBuildings(); bb = new ArrayList<JRadioButton>(); group = new ButtonGroup(); JRadioButton removeButton = new JRadioButton("Remove Building"); bb.add(removeButton); sideCM.add(removeButton); group.add(removeButton); for (int i = 0; i < bList.size(); i++) { button = new JRadioButton(bList.get(i).getName() + '-' + bList.get(i).getQuantity()); bb.add(button); sideCM.add(button); group.add(button); } mainPanels = new MainPanel(new CardLayout()); mainPanels.add(mainLogin, "Login"); mainPanels.add(mainMenu, "Menu"); mainPanels.add(mainCM, "CM"); mainPanels.add(mainTM, "TM"); sidePanels = new SidePanel(new CardLayout()); sidePanels.add(sideLogin, "Login"); sidePanels.add(sideMenu, "Menu"); sidePanels.add(sideCM, "CM"); sidePanels.add(sideTM, "TM"); JPanel mainPanel = new JPanel(null); mainPanel.setSize(1000, 600); mainPanel.add(sidePanels); mainPanel.add(mainPanels); mainPanel.add(chatPanel); add(mainPanel, BorderLayout.CENTER); try { setIconImage(ImageIO.read(new File("images/logo.png"))); } catch (IOException exc) { exc.printStackTrace(); } setDefaultCloseOperation(EXIT_ON_CLOSE); setSize(1000, 600); setVisible(true); setResizable(false); chatField.requestFocus(); }
public void launchChess() { mainWindow = new JFrame("网络黑白棋 作者:张炀"); jpWest = new JPanel(); jpEast = new JPanel(); jpNorth = new JPanel(); jpSouth = new JPanel(); jpCenter = new JPanel(); turnLabel = new JLabel(); blackNumberLabel = new JLabel("黑棋:\n" + black + " "); whiteNumberLabel = new JLabel("白棋:\n" + white + " "); timeLabel = new JLabel("时间: " + time + " s"); noticeLabel = new JLabel(); noticeLabel = new JLabel("请选择:"); numberPane = new JPanel(); readyPane = new JPanel(); jt1 = new JTextField(18); // 发送信息框 jt2 = new JTextArea(3, 30); // 显示信息框 js = new JScrollPane(jt2); jt2.setLineWrap(true); jt2.setEditable(false); // jt1.setLineWrap(true); send = new JButton("发送"); cancel = new JButton("取消"); regret = new JButton("悔棋"); submit = new JButton("退出"); begin = new JButton("开始"); save = new JButton("存盘"); save.setEnabled(true); begin.setEnabled(true); fighter = new JRadioButton("下棋"); audience = new JRadioButton("观看"); group = new ButtonGroup(); group.add(audience); group.add(fighter); group.add(AIPlayer); submit.addActionListener(this); begin.addActionListener(this); save.addActionListener(this); send.addActionListener(this); cancel.addActionListener(this); regret.addActionListener(this); fighter.addActionListener(this); audience.addActionListener(this); jpNorth.setLayout(new BorderLayout()); jpNorth.add(turnLabel, BorderLayout.NORTH); jpNorth.add(jpCenter, BorderLayout.CENTER); jpSouth.add(js); jpSouth.add(jt1); jpSouth.add(send); jpSouth.add(cancel); jpEast.setLayout(new GridLayout(3, 1)); submit.setBackground(new Color(130, 251, 241)); panel x = new panel(); jpEast.add(x); jpEast.add(numberPane); jpEast.add(readyPane); numberPane.add(blackNumberLabel); numberPane.add(whiteNumberLabel); numberPane.add(timeLabel); numberPane.add(submit); numberPane.add(begin); numberPane.add(save); numberPane.add(regret); readyPane.add(noticeLabel); readyPane.add(fighter); readyPane.add(audience); // readyPane.add(save); // readyPane.add(regret); jpCenter.setSize(400, 400); jmb = new JMenuBar(); document = new JMenu("游戏 "); edit = new JMenu("设置 "); insert = new JMenu("棋盘 "); help = new JMenu("帮助 "); jmb.add(document); jmb.add(edit); jmb.add(insert); jmb.add(help); // mainWindow.setJMenuBar(jmb); mainWindow.setBounds(80, 80, 600, 600); mainWindow.setResizable(false); jsLeft = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, jpNorth, jpSouth); jsBase = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, jsLeft, jpEast); mainWindow.add(jsBase); mainWindow.setVisible(true); mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jsBase.setDividerLocation(0.7); jsLeft.setDividerLocation(0.78); jpCenter.setLayout(new GridLayout(8, 8, 0, 0)); ImageIcon key = new ImageIcon("chess1.jpg"); for (int i = 0; i < cell.length; i++) for (int j = 0; j < cell.length; j++) { cell[i][j] = new ChessBoard(i, j); cell[i][j].addMouseListener(this); jpCenter.add(cell[i][j]); } cell[3][3].state = cell[4][4].state = '黑'; cell[4][3].state = cell[3][4].state = '白'; cell[3][3].taken = cell[4][4].taken = true; cell[4][3].taken = cell[3][4].taken = true; RememberState(); new Thread(new TurnLabel(this)).start(); file = new File("D:/" + myRole); try { fout = new FileOutputStream(file); out = new ObjectOutputStream(fout); } catch (IOException e1) { e1.printStackTrace(); } Connect(); try { out99 = new ObjectOutputStream(socket99.getOutputStream()); in99 = new ObjectInputStream(socket99.getInputStream()); out66 = new ObjectOutputStream(socket66.getOutputStream()); in66 = new ObjectInputStream(socket66.getInputStream()); out88 = new DataOutputStream(socket88.getOutputStream()); } catch (IOException e) { e.printStackTrace(); } new Thread(new Client9999(this)).start(); new Thread(new Client6666(this)).start(); }
public void go() { frame = new JFrame("Quiz Card Player"); JPanel mainPanel = new JPanel(); Font bigFont = new Font("sanserif", Font.BOLD, 24); display = new JTextArea(10, 20); display.setFont(bigFont); display.setLineWrap(true); display.setEditable(false); JScrollPane qScroller = new JScrollPane(display); qScroller.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); qScroller.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); nextButton = new JButton("Show Questions"); nextButton.addActionListener(new NextCardListener()); mainPanel.add(qScroller); mainPanel.add(nextButton); JMenuBar menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem loadMenuItem = new JMenuItem("Load Card Set"); loadMenuItem.addActionListener(new OpenMenuListener()); fileMenu.add(loadMenuItem); menuBar.add(fileMenu); frame.setJMenuBar(menuBar); frame.getContentPane().add(BorderLayout.CENTER, mainPanel); frame.setSize(640, 500); frame.setVisible(true); }