/** Creates new form NewJFrame */ public NewJFrame() { initcomponents(); initblogsearch(); //initializes Index List box }

Similar documents
* To change this license header, choose License Headers in Project Properties.

Answer on question #61311, Programming & Computer Science / Java

* To change this license header, choose License Headers in Project Properties.

Java Programming Summer 2008 LAB. Thursday 8/21/2008

Travel Agency. Khateeb Engineering Classes. Mini Project. Khateeb Engineering Classes: / Technology to be used

I.1 Introduction Matisse GUI designer I.2 GroupLayout Basics Sequential and Parallel Arrangements sequential horizontal orientation

CHAPTER 8 INFERENCE. The concept of Inference would be explained in the following chapter, as the CTBN

INSTITUTO POLITÉCNICO NACIONAL ESCUELA SUPERIOR DE CÓMPUTO

JAVA CODE JAVA CODE: BINOMIAL TREES OPTION PRICING BINOMIALTREE CLASS PAGE 1

グラフを表すデータ構造 JAVA での実装

DAFTAR LAMPIRAN. Source Code Java Aplikasi Keyword to Image Renamer Split

TECHNICAL DOCUMENTATION

Appendix I: Software Coding

privateint m, n, smithitemcount, raitaitemcount;

Role-Coll Role Based Collaboration Software

jlabel14 = new javax.swing.jlabel(); jlabel15 = new javax.swing.jlabel(); jlabel16 = new javax.swing.jlabel(); jlabel17 = new javax.swing.

Hanley s Survival Guide for Visual Applications with NetBeans 2.0 Last Updated: 5/20/2015 TABLE OF CONTENTS

Project Helpine Report BANQUET HALL BOOKING

/* * MoraDrill.java * Version last updated 6 April 2010 * Written by John K. Estell * Created on November 30, 2008, 10:22 PM */

Input from Files. Buffered Reader

Exercice G09 (v3) File: Shape.java Project: G09-MiniDraw_v3 1GGE

Exercice G02 (v2) File: MovingBall.java Project: G02-Smileys_v2 1GGE

Chapter 2. Network Chat

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

A sample print out is: is is -11 key entered was: w

Goals. Lecture 7 More GUI programming. The application. The application D&D 12. CompSci 230: Semester JFrame subclass: ListOWords

We have several alternatives now, which we need to address. Here is a list of them: 1. How to get HTML interpreted correctly.

Lab 5: Java IO 12:00 PM, Feb 21, 2018

SampleApp.java. Page 1

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Swing - JTextField. Adding a text field to the main window (with tooltips and all)

Lampiran A. SOURCE CODE PROGRAM

Classes Basic Overview

file:///home/joans/documents/docencia/es2/curs...

COMP16121 Sample Code Lecture 1

Today. Book-keeping. File I/O. Subscribe to sipb-iap-java-students. Inner classes. Debugging tools

//Initializes the variables that will hold the eventual final new versions of the string String pluralextension; String secondwordextension;

CSCI 201L Midterm Written Summer % of course grade

JAVA Programming Language Homework VI: Threads & I/O

COMP-202: Foundations of Programming. Lecture 12: Linked List, and File I/O Sandeep Manjanna, Summer 2015

Systems Programming. Bachelor in Telecommunication Technology Engineering Bachelor in Communication System Engineering Carlos III University of Madrid

The class definition is not a program by itself. It can be used by other programs in order to create objects and use them.

LAMPIRAN PERANGKAT LUNAK

Java in 21 minutes. Hello world. hello world. exceptions. basic data types. constructors. classes & objects I/O. program structure.

A Simple Text Editor Application

Multiple Choice Questions: Identify the choice that best completes the statement or answers the question. (15 marks)

CISC 323 (Week 9) Design of a Weather Program & Java File I/O

IT101. File Input and Output

package As7BattleShip;

Engineering Abstractions in Model Checking and Testing. Michael Achenbach Klaus Ostermann

Java Input/Output. 11 April 2013 OSU CSE 1

COMP-202: Foundations of Programming. Lecture 22: File I/O Jackie Cheung, Winter 2015

1 Using the NetBeans IDE

CSCI 201L Midterm Written SOLUTION Summer % of course grade

File IO. Computer Science and Engineering College of Engineering The Ohio State University. Lecture 20

CMP 326 Final Spring There is a blank page at the end of the exam if you need more room to answer a question.

1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004

Swing - JLabel. Adding a text (and HTML) labels to a GUI

CSCI 136 Written Exam #1 Fundamentals of Computer Science II Spring 2014

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

COMP 202 File Access. CONTENTS: I/O streams Reading and writing text files. COMP 202 File Access 1

CSCD 330 Network Programming

Graphical User Interface

17 GUI API: Container 18 Hello world with a GUI 19 GUI API: JLabel 20 GUI API: Container: add() 21 Hello world with a GUI 22 GUI API: JFrame: setdefau

I/O in Java I/O streams vs. Reader/Writer. HW#3 due today Reading Assignment: Java tutorial on Basic I/O

2018/2/5 话费券企业客户接入文档 语雀

CSE 143 Sp03 Midterm 2 Sample Solution Page 1 of 7. Question 1. (2 points) What is the difference between a stream and a file?

COE318 Lecture Notes Week 10 (Nov 7, 2011)

Page 1 of 16. Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Midterm assessment - MAKEUP Fall 2010

// autor igre Ivan Programerska sekcija package mine;

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

CSCD 330 Network Programming

pre-emptive non pre-emptive

Do not turn to the next page until the start of the exam.

Full file at Chapter 2 - Inheritance and Exception Handling

Lecture 4: Exceptions. I/O

COMP-202 Unit 9: Exceptions

Program 20: //Design an Applet program to handle Mouse Events. import java.awt.*; import java.applet.*; import java.awt.event.*;

Exceptions vs. Errors Exceptions vs. RuntimeExceptions try...catch...finally throw and throws

Introduction IS

CSCD 330 Network Programming

Give one example where you might wish to use a three dimensional array

CS 51 Laboratory # 12

Module 6: Binary Trees

Java, Swing, and Eclipse: The Calculator Lab.

File Operations in Java. File handling in java enables to read data from and write data to files

6O03 project report. Main points for the solution. Build a combination possibility tableau. Problem: Page 5, the prime number problem

1.00 Introduction to Computers and Engineering Problem Solving. Final Examination - May 18, 2005

Quiz 1. In class on Tuesday (April 14) Review learning goals (from lecture) Review lectures 1 4, PSA 1 You should be able to:

Our first program is a simple calculator, which will carry out the arithmetic operations of adding, subtracting, multiplying and dividing numbers.

Special error return Constructors do not have a return value What if method uses the full range of the return type?

Darshan Institute of Engineering & Technology for Diploma Studies

Question 1. (2 points) What is the difference between a stream and a file?

Proctors are unable to respond to queries about the interpretation of exam questions. Do your best to answer exam questions as written.

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

1.00/ Introduction to Computers and Engineering Problem Solving. Final / December 13, 2004

File Processing in Java

Recitation 3 Class and Objects

Implementacja: /* * JFrame.java */ /** tkubik */

Transcription:

/* * To change this template, choose Tools Templates * and open the template in the editor. */ /* * NewJFrame.java * * Created on Apr 17, 2011, 1:13:13 PM */ /** * * @author Kelli */ import java.io.*; public class NewJFrame extends javax.swing.jframe { static String srcdir = "file:wpblogs\\"; String Titles2Blogs[] = new String [100]; // Array allows for 100 blog titles per Term; string allows direct use of filename static BufferedReader inbread = new BufferedReader (new InputStreamReader(System.in)); /** Creates new form NewJFrame */ public NewJFrame() { initcomponents(); initblogsearch(); //initializes Index List box public void initblogsearch() { readfromindexfile("index_terms.txt"); //puts all elements from Index Terms into the Index List //END initblogsearch{ /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="generated Code">//GEN-BEGIN:initComponents private void initcomponents() { buttongroup1 = new javax.swing.buttongroup(); buttongroup2 = new javax.swing.buttongroup(); jscrollpane1 = new javax.swing.jscrollpane(); ShowBlog_textPane = new javax.swing.jtextpane();

Index_Listbox = new java.awt.list(); Title_Listbox = new java.awt.list(); IndexSelect_button = new javax.swing.jbutton(); TitleSelect_button = new javax.swing.jbutton(); jlabel1 = new javax.swing.jlabel(); jlabel2 = new javax.swing.jlabel(); setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close); settitle("kelli's Metadata WordPress Blog Search"); ShowBlog_textPane.setBorder(javax.swing.BorderFactory.createTitledBord er(null, "Blog", javax.swing.border.titledborder.default_justification, javax.swing.border.titledborder.default_position, new java.awt.font("kalinga", 1, 14), new java.awt.color(0, 0, 204))); // NOI18N ShowBlog_textPane.setToolTipText("Full text of the desired blog will show here."); jscrollpane1.setviewportview(showblog_textpane); Index_Listbox.setCursor(new java.awt.cursor(java.awt.cursor.default_cursor)); Index_Listbox.setFont(new java.awt.font("kalinga", 0, 18)); // NOI18N Index_Listbox.setForeground(new java.awt.color(0, 51, 153)); Index_Listbox.addActionListener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { Index_ListboxActionPerformed(evt); ); Title_Listbox.setFont(new java.awt.font("kalinga", 0, 18)); // NOI18N Title_Listbox.setForeground(new java.awt.color(0, 0, 102)); Title_Listbox.addActionListener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { Title_ListboxActionPerformed(evt); ); IndexSelect_button.setFont(new java.awt.font("kalinga", 0, 14)); IndexSelect_button.setText("1. Select Search Term to See Titles"); IndexSelect_button.setActionCommand("1. Select Search Term to See Titles"); IndexSelect_button.setAutoscrolls(true);

IndexSelect_button.setBorder(javax.swing.BorderFactory.createEtchedBor der()); IndexSelect_button.addActionListener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { IndexSelect_buttonActionPerformed(evt); ); TitleSelect_button.setFont(new java.awt.font("kalinga", 0, 14)); TitleSelect_button.setText("2. Select Title to See Full Blog"); TitleSelect_button.setBorder(javax.swing.BorderFactory.createEtchedBor der(new java.awt.color(153, 153, 255), null)); TitleSelect_button.addActionListener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { TitleSelect_buttonActionPerformed(evt); ); jlabel1.setfont(new java.awt.font("kalinga", 0, 14)); // NOI18N jlabel1.settext("indexing Search Terms:"); jlabel1.settooltiptext("highlight desired term and double-click or hit \"1\" button."); jlabel2.setfont(new java.awt.font("kalinga", 0, 14)); // NOI18N jlabel2.settext("blog Titles (for the search term selected above):"); jlabel2.settooltiptext("highlight desired title and double-click or hit \"2\" button."); javax.swing.grouplayout layout = new javax.swing.grouplayout(getcontentpane()); getcontentpane().setlayout(layout); layout.sethorizontalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addcontainergap().addgroup(layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addcomponent(titleselect_button, javax.swing.grouplayout.preferred_size, 213,.addComponent(jLabel2, javax.swing.grouplayout.default_size, 420, Short.MAX_VALUE).addComponent(Title_Listbox,

javax.swing.grouplayout.preferred_size, 333,.addGap(29, 29, 29)).addComponent(IndexSelect_button, javax.swing.grouplayout.preferred_size, 258,.addGap(104, 104, 104)).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel1, javax.swing.grouplayout.default_size, 317, Short.MAX_VALUE).addComponent(Index_Listbox, javax.swing.grouplayout.preferred_size, 162,.addGap(101, 101, 101))).addGap(103, 103, 103))).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(jScrollPane1, javax.swing.grouplayout.preferred_size, 382,.addContainerGap()) ); layout.setverticalgroup( layout.createparallelgroup(javax.swing.grouplayout.alignment.leading).addcontainergap().addgroup(layout.createparallelgroup(javax.swing.grouplayout.alignment.leading, false).addgap(33, 33, 33).addComponent(Index_Listbox, javax.swing.grouplayout.preferred_size, 147,.addGap(25, 25, 25).addComponent(IndexSelect_button, javax.swing.grouplayout.preferred_size, 48,.addGap(11, 11, 11).addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(Title_Listbox, javax.swing.grouplayout.preferred_size, 269,

.addpreferredgap(javax.swing.layoutstyle.componentplacement.related).addcomponent(titleselect_button, javax.swing.grouplayout.default_size, javax.swing.grouplayout.default_size, Short.MAX_VALUE)).addComponent(jLabel1).addGap(18, 18, 18).addComponent(jScrollPane1, javax.swing.grouplayout.preferred_size, 585, )).addcontainergap(javax.swing.grouplayout.default_size, Short.MAX_VALUE)) ); pack(); // </editor-fold>//gen-end:initcomponents //makes clickable list of index terms private void Index_ListboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Index_ListboxActionPerformed if (null!= Index_Listbox.getSelectedItem()) //prevents Exception from showing in Title_Listbox: must have a list readfromtitlefile(index_listbox.getselecteditem());//calls method - passes in selected Index item //GEN-LAST:event_Index_ListboxActionPerformed //makes clickable list of Blog Titles to retrieve selected blog private void Title_ListboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Title_ListboxActionPerformed String filename = ""; //initialized filename try { //goes int wblogs folder and retrieves/displays the file name filename = srcdir + Titles2Blogs[Title_Listbox.getSelectedIndex()]; ShowBlog_textPane.setPage(filename); catch (Exception ex) { Title_Listbox.add("No File "+filename+" to read: \n "+ex); //GEN-LAST:event_Title_ListboxActionPerformed //allows button to be used if user cannot double-click (accessibility issues) private void IndexSelect_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_IndexSelect_buttonActionPerformed Index_ListboxActionPerformed( evt); //GEN-LAST:event_IndexSelect_buttonActionPerformed //allows button to be used if user cannot double-click (accessibility issues)

private void TitleSelect_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_TitleSelect_buttonActionPerformed if (null!= Title_Listbox.getSelectedItem()) Title_ListboxActionPerformed( evt); //GEN-LAST:event_TitleSelect_buttonActionPerformed public static void main(string args[]) { java.awt.eventqueue.invokelater(new Runnable() { public void run() { new NewJFrame().setVisible(true); ); //END main { // Variables declaration - do not modify//gen-begin:variables private javax.swing.jbutton IndexSelect_button; private java.awt.list Index_Listbox; private javax.swing.jtextpane ShowBlog_textPane; private javax.swing.jbutton TitleSelect_button; private java.awt.list Title_Listbox; private javax.swing.buttongroup buttongroup1; private javax.swing.buttongroup buttongroup2; private javax.swing.jlabel jlabel1; private javax.swing.jlabel jlabel2; private javax.swing.jscrollpane jscrollpane1; // End of variables declaration//gen-end:variables // method to retrieve list of titles after choosing a desired index term // add the index terms to the box upon running program; public void readfromindexfile(string filename) { try { File myfile = new File( filename ); FileReader filereader = new FileReader( myfile ); //Construct the BufferedWriter object BufferedReader reader = new BufferedReader( filereader); boolean done = false; String parts = ""; //parts are the index terms from index_terms.txt while(!done ) //reads while there are still "things" to be read { // Read Line parts = reader.readline(); if ( null == parts ) done = true; else

Index_Listbox.add(parts); // end while reader.close(); //END try catch (Exception ex) { Title_Listbox.add("No File '"+filename+"' to read: \n //END catch // END ReadFromIndexFile() "+ex); //method to retrieve blog text from title list public void readfromtitlefile(string filename) { //passed-in index term try { filename += "_Titles.txt"; //files are set up as IndexTerm'X'_Titles.txt: this builds the.txt file to look in (ex: XML_Title.txt) File myfile = new File(filename); int ii =0; FileReader filereader = new FileReader( myfile ); BufferedReader reader = new BufferedReader( filereader); boolean done = false; String titlename = ""; Title_Listbox.removeAll(); //makes sure Title_List box is cleared for new set of titles while(!done) { //while we are at 100 blogs or less titlename = reader.readline(); //gets blog Title - this is what's clickable in Title_Listbox if ( null == titlename ) done = true; else { Titles2Blogs[ii] = reader.readline(); //creates item in array of.htm blog files associated with the index term if ( null == Titles2Blogs[ii] ) done = true; else { Title_Listbox.add(titleName); //gets 'searchterm_title.txt' name --> searches THAT.txt file for all blog titles (ex:wp0fears.htm) ii++; if (ii >= Titles2Blogs.length) //we stop at 100 blogs [array size] done = true; // end while reader.close(); //END try catch (Exception ex) { Title_Listbox.add("No File '"+filename+"' to Read Prior information:\n "+ex); //END catch // END ReadFromTitleFile()

//END public class NewJFrame