Details of this Paper

2 small java assignments

Description

solution


Question

;;Assignment 1 due: Small JAVA debugging exercise (Understanding Error Messages)needed before 11:55am Nov. 24, 2013 (CST).;Assignment 2 due: Small JAVA interactive program (Creating an Assignment Data File) needed before 11:55am Nov. 31, 2013 (CST).;Begin of Assignment 1;Understanding Error Messages;Using TextPad, open the file named Connections from the Chapter07 folder of the Data Disk that accompanies this book (see below for complete source). Use the Replace command on the Search menu to replace all occurrences of the word, Connections, with the word, Modems. Save the file as a Java source code file with the file name Modems. Then, compile the program.When TextPad displays errors in the Command Results window, double-click the first line of the first error message to return to that line in the TextPad coding window. Fix the error. Insert a comment line in your code identifying what caused the error. Compile again and repeat the process until the program is error free. Submit your source code to your instructor.;--- begin import of Connections.java ---;/*;Chapter 7: Connections;Programmer;Date;Filename: Connections.java;Purpose: This program creates a Swing interface Modem Connections;*/;importjava.awt.*;importjava.awt.event.*;importjavax.swing.*;importjavax.swing.text.*;public class Connections extendsJFrameimplementsActionListener;//construct components;JComboBoxfirstCombo = new JComboBox();JComboBoxsecondCombo = new JComboBox();JTextPanetextPane = new JTextPane();//construct instance of Connections;public Connections();//create the menu system;publicJMenuBarcreateMenuBar();//create an instance of the menu;setJMenuBar(mnuBar);//construct and populate the File menu;JMenumnuFile =new JMenu("File", true);mnuFile.setDisplayedMnemonicIndex(0);mnuBar.add(mnuFile);JMenuItemmnuFileExit = new JMenuItem("Exit");mnuFileExit.setDisplayedMnemonicIndex(1);mnuFile.add(mnuFileExit);mnuFileExit.setActionCommand("Exit");mnuFileExit.addActionListener(this);//construct and populate the Edit menu;JMenumnuEdit = new JMenu("Edit", true);mnuEdit.setDisplayedMnemonicIndex(0);mnuBar.add(mnuEdit);JMenuItemmnuEditInsert = new JMenuItem("Insert New Connections");mnuEditInsert.setDisplayedMnemonicIndex(0);mnuEdit.add(mnuEditInsert);mnuEditInsert.setActionCommand("Insert");mnuEditInsert.addActionListener(this);JMenumnuEditSearch = new JMenu("Search");mnuEditSearch.setDisplayedMnemonicIndex(3);mnuEdit.add(mnuEditSearch);JMenuItemmnuEditSearchByConnection = new JMenuItem("by Connection");mnuEditSearchByConnection.setDisplayedMnemonicIndex(3);mnuEditSearch.add(mnuEditSearchByConnection);mnuEditSearchByConnection.setActionCommand("title");mnuEditSearchByConnection.addActionListener(this);JMenuItemmnuEditSearchBySpeed = new JMenuItem("by Speed");mnuEditSearchBySpeed.setDisplayedMnemonicIndex(3);mnuEditSearch.add(mnuEditSearchBySpeed);mnuEditSearchBySpeed.setActionCommand("studio");mnuEditSearchBySpeed.addActionListener(this);JMenuItemmnuEditSearchByProtocol = new JMenuItem("by Protocol");mnuEditSearchByProtocol.setDisplayedMnemonicIndex(3);mnuEditSearch.add(mnuEditSearchByProtocol);mnuEditSearchByProtocol.setActionCommand("year");mnuEditSearchByProtocol.addActionListener(this);returnmnuBar;//create the content pane;public Container createContentPane();//populate the JComboBox;fieldCombo.addItem("Dial-Up");fieldCombo.addItem("DSL");fieldCombo.addItem("Cable");fieldCombo.addItem("Satellite");fieldCombo.addActionListener(this);fieldCombo.setToolTip("Click the drop down arrow to display connection types.");//populate the JComboBox;secondCombo.addItem("57600");secondCombo.addItem("2304000");secondCombo.addItem("460800");secondCombo.addItem("921600");secondCombo.addActionListener(this);secondCombo.setEditable(true);//construct and populate the north panel;JPanelnorthPanel = new JPanel();northPanel.setLayout(new FlowLayout());//northPanel.add(sortPrompt);northPanel.add(fieldCombo);northPanel.add(secondCombo);//create the JTextPane and center panel;JPanelcenterPanel = new JPanel();setTabsAndStyles(textPane);JTextPaneinternalTextPane = addTextToTextPane();JScrollPanepaneScrollPane = new JScrollPane(internalTextPane);paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);paneScrollPane.setPreferredSize(new Dimension(500, 200));centerPanel.add(paneScrollPane);//create Container and set attributes;Container c = getContentPane();c.setLayout(new BorderLayout(10,10));c.add(northPanel,BorderLayout.NORTH);c.add(centerPanel,BorderLayout.CENTER);return c;//method to create tab stops and set font styles;protected void setTabsAndStyles(JTextPanetextPane);//create Tab Stops;TabStop[] tabs = new TabStop[2];tabs[0] = new TabStop(200, TabStop.ALIGN_LEFT, TabStop.LEAD_NONE)

 

Paper#71253 | Written in 18-Jul-2015

Price : $27
SiteLock