Department of Computer Science University of Nevada, Reno Role-Coll Role Based Collaboration Software CS 425 12/12/2006 Software Team: Harold De Armas, Erik Hanchett, Raymond Lee, Zack Norcross Business Team: Mark Tyman, Max Volger Internal Advisors: Sergiu Dascalu, PhD., Gary Valiere PhD.
Table of Contents TABLE OF CONTENTS... 2 INTRODUCTION... 3 CLASS SUMMARY... 4 SOURCE CODE... 5 AdminFrame Class... 5 ALlImagesFilter Class... 14 BackgroundPanal Class... 15 ConnectionManager Class... 17 EditUserFrame Class... 19 GetUser Class... 26 GIFFilter Class... 27 JPGFilter Class... 28 LoginFrame Class... 29 MainFrame Class... 34 NewUserFrame Class... 41 PNGFilter Class... 48 SaveUser Class... 49 SkinBean Class... 50 UserBean Class... 51 User Class... 54 UserTreeNode Class... 58 XML DOCUMENTATION... 60 POM XML... 60 User s XML... 61 2 of 62
Introduction The objective of Role-Coll is to be an interactive collaboration product. The proposed product will allow multiple interested parties to have visual input on a document or conversation. However the product will have built in intelligence as to which users input will be displayed by default and which users input to shared only if it is approved by their superior. The aptly named Role-Coll, short for Role-based collaboration software, will allow users to share collaboration freely at their own level and their superiors will be able to filter the input from all of their subordinates. Role-Coll will also incorporate modularity to allow for different modules to be plugged in as the subject of the conversations change. The primary focus for Roll-Coll is a music plug-in that allows collaboration among an entire band or orchestra on a multiple pieces of music. Each section would be able to make their own notes on their music and the conductor could filter out only the notes that he saw useful. Collaborative software allows multiple users to contribute to multiple documents in a way that every user contributes to the creation of the document they are working on. This is a very powerful tool because it allows input from a variety of users and the users feel part of the creative process. Collaboration software could be improved in two key areas, by adding roles to each of the users, and by allowing for more variation in the documents that are being collaborated on. Our project will be focused on two key improvements to collaboration software. The first improvement is the addition of user roles. In current collaboration software, everyone is editing the same document, and everyone has the same privileges to do so. With the addition of roles, users are organized in a hierarchy such that there are leaders and subordinates. Another important distinction is that every user has a copy of the document that is unique to them. Everyone may make changes to their document that is not reflected in the collaborated document, much like making liner notes in a real document. The roles come in place when a leader submits a change to subordinates. The change is applied automatically and users have the ability to modify it in their own document. If a subordinate has a modification they would like to make in a document, they would need to submit it to the leader for approval. Then the leader can chose to apply the modification to the group s document or discard it. The second improvement proposed to collaboration software is that of how a document is defined. Collaboration does not only happen on text documents and whiteboards. Engineers need to create and edit circuit diagrams and using a simple whiteboard would be tedious. The particular interest of this group is music notation. In rehearsals of symphony orchestras, a large collaboration effort is taking place where the document being collaborated on is a piece of sheet music. Sheet music is another unique document that is not easily described by a text editor or a whiteboard. Along with the ability to enforce roles in the collaboration process, the software should also allow for a wider variety of collaboration through the implementation of modules. For future consideration, Role-Coll should come with the standard modules that allow for text editing and use of a whiteboard. Role-Coll should feature an interface by which a user can create a system the application can use to display, interpret, and modify a collaborative document. Since Role-Coll is a modular project, future developments can include a larger library of modules. Role-Coll might be enhanced to support a wider 3 of 62
variety of modules that were not thought of in initial conception. A web interface could be created so users can view and make basic changes to the document. Roll-Coll has completed the preliminary research and work necessary to create a prototype graphical user interface. Roll-Coll has also completed research on the XML specification for MusicXML files that will be the basis of this software. Database diagrams have been created to describe the internal structure and storage of the documents as well as the roles for use in the music setting. Finally class outlines and initial methods have been prototyped to serve the needs of Roll-Coll. Class Summary No. Class Name Description 1 AdminFrame This class displays the admin form 2 AllImagesFilter This filter will show all jpg, gif, and png files aswell as all folders in the directory. 3 BackgroundPanel Background for all panels 4 ConnectionManager This class creates a static connection to the database 5 EditUserFrame Frame for dispaying user information 6 GetUser This class will retreive user data from the database 7 GIFFilter Filters all files except.gif files from the file dialog box 8 JPGFilter Filters all files except.jpg files from the file dialog box 9 LoginFrame This class validates a users credintals and opens the correct frame 10 MainFrame This class displays the main UI screen 11 NewUserFrame Admin frame used for adding users 12 PNGFilter Filters all files except.jpg files from the file dialog box 13 SaveUser This class is used to update user information in the database. 14 SkinBean Controls the skin of the user interface 15 UserBean This class contains all of the user information in an object 16 Users This class loads the user tree in the main and admin frame 17 UserTreeNode Extention of a the DefaultMutableTreeNode class A UserBean was added containing the users information 4 of 62
Source Code AdminFrame Class /* * AdminFrame.java * * Created on November 26, 2006, 4:49 PM package rolecoll.ui; import javax.imageio.imageio; import javax.swing.tree.defaulttreecellrenderer; import javax.swing.tree.treepath; import rolecoll.beans.skinbean; import rolecoll.beans.userbean; import rolecoll.beans.usertreenode; import rolecoll.beans.users; * This class displays the admin form public class AdminFrame extends javax.swing.jframe { private TreePath path = null; Creates new form AdminFrame public AdminFrame() { // get users Users.getUsers( // init skin SkinBean.initSkin(SkinBean.skin initcomponents( // Update only one tree instance DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer)jTree1.getCellRenderer( // Remove the icons renderer.setleaficon(null renderer.setclosedicon(null renderer.setopenicon(null personalpanel.grabfocus( This method is called from within the constructor to * initialize the form. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initcomponents() { jscrollpane1 = new javax.swing.jscrollpane( jtree1 = new javax.swing.jtree(users.usertree jtabbedpane1 = new javax.swing.jtabbedpane( personalpanel = new javax.swing.jpanel( firstnametext = new javax.swing.jtextfield( 5 of 62
lastnametext = new javax.swing.jtextfield( jlabel1 = new javax.swing.jlabel( jlabel2 = new javax.swing.jlabel( loginpanel = new javax.swing.jpanel( jlabel3 = new javax.swing.jlabel( jlabel4 = new javax.swing.jlabel( logintext = new javax.swing.jtextfield( passwordtext = new javax.swing.jtextfield( jlabel5 = new javax.swing.jlabel( idtext = new javax.swing.jtextfield( rolepanel = new javax.swing.jpanel( rolename = new javax.swing.jtextfield( jlabel6 = new javax.swing.jlabel( jlabel7 = new javax.swing.jlabel( rolepriority = new javax.swing.jtextfield( jlabel8 = new javax.swing.jlabel( superiorid = new javax.swing.jtextfield( jmenubar2 = new javax.swing.jmenubar( jmenu2 = new javax.swing.jmenu( jmenuitem1 = new javax.swing.jmenuitem( jmenuitem2 = new javax.swing.jmenuitem( jmenuitem3 = new javax.swing.jmenuitem( setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close settitle("role-coll" setcursor(new java.awt.cursor(java.awt.cursor.default_cursor) try{ seticonimage(imageio.read(mainframe.class.getclassloader().getresource( "images/rolecoll.jpg")) catch(exception e){ e.printstacktrace( setresizable(false jtree1.addfocuslistener(new java.awt.event.focusadapter() { public void focusgained(java.awt.event.focusevent evt) { jtree1focusgained(evt jscrollpane1.setviewportview(jtree1 jtabbedpane1.setfont(new java.awt.font("verdana", 1, 12) personalpanel.setfont(new java.awt.font("verdana", 1, 12) firstnametext.setfont(new java.awt.font("verdana", 0, 12) lastnametext.setfont(new java.awt.font("verdana", 0, 12) jlabel1.setfont(new java.awt.font("verdana", 1, 12) jlabel1.settext("first Name" jlabel2.setfont(new java.awt.font("verdana", 1, 12) jlabel2.settext("last Name" org.jdesktop.layout.grouplayout personalpanellayout = new org.jdesktop.layout.grouplayout(personalpanel 6 of 62
personalpanel.setlayout(personalpanellayout personalpanellayout.sethorizontalgroup( personalpanellayout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(personalpanellayout.createsequentialgroup().addcontainergap().add(personalpanellayout.createparallelgroup(org.jdesktop.layout.groupl ayout.leading).add(jlabel1).add(jlabel2)).add(12, 12, 12).add(personalPanelLayout.createParallelGroup(org.jdesktop.layout.GroupL ayout.trailing).add(lastnametext, 185, Short.MAX_VALUE).add(firstNameText, 185, Short.MAX_VALUE)).addContainerGap()) personalpanellayout.setverticalgroup( personalpanellayout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(personalpanellayout.createsequentialgroup().addcontainergap().add(personalpanellayout.createparallelgroup(org.jdesktop.layout.groupl ayout.baseline).add(jlabel1).add(firstnametext, org.jdesktop.layout.grouplayout.preferred_size)).add(12, 12, 12).add(personalPanelLayout.createParallelGroup(org.jdesktop.layout.GroupL ayout.baseline).add(jlabel2).add(lastnametext, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap(198, Short.MAX_VALUE)) jtabbedpane1.addtab("personal", personalpanel loginpanel.setfont(new java.awt.font("verdana", 1, 12) jlabel3.setfont(new java.awt.font("verdana", 1, 12) jlabel3.settext("login" jlabel4.setfont(new java.awt.font("verdana", 1, 12) jlabel4.settext("password" logintext.setfont(new java.awt.font("verdana", 0, 12) 7 of 62
passwordtext.setfont(new java.awt.font("verdana", 0, 12) jlabel5.setfont(new java.awt.font("verdana", 1, 12) jlabel5.settext("user ID" idtext.seteditable(false idtext.setfont(new java.awt.font("verdana", 0, 12) org.jdesktop.layout.grouplayout loginpanellayout = new org.jdesktop.layout.grouplayout(loginpanel loginpanel.setlayout(loginpanellayout loginpanellayout.sethorizontalgroup( loginpanellayout.createparallelgroup(org.jdesktop.layout.grouplayout.le ADING).add(loginPanelLayout.createSequentialGroup().addContainerGap().add(loginPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayo ut.leading).add(jlabel4).add(jlabel3).add(jlabel5)).add(24, 24, 24).add(loginPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayo ut.leading).add(logintext, 180, Short.MAX_VALUE).add(passwordText, 180, Short.MAX_VALUE).add(idText, 59, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap()) loginpanellayout.setverticalgroup( loginpanellayout.createparallelgroup(org.jdesktop.layout.grouplayout.le ADING).add(loginPanelLayout.createSequentialGroup().addContainerGap().add(loginPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayo ut.baseline).add(logintext, org.jdesktop.layout.grouplayout.preferred_size).add(jlabel3)).add(9, 9, 9).add(loginPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayo ut.baseline).add(passwordtext, 8 of 62
org.jdesktop.layout.grouplayout.preferred_size).add(jlabel4)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(loginpanellayout.createparallelgroup(org.jdesktop.layout.grouplayo ut.baseline).add(jlabel5).add(idtext, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap(173, Short.MAX_VALUE)) jtabbedpane1.addtab("login", loginpanel rolename.setfont(new java.awt.font("verdana", 0, 12) jlabel6.setfont(new java.awt.font("verdana", 1, 12) jlabel6.settext("role Name" jlabel7.setfont(new java.awt.font("verdana", 1, 12) jlabel7.settext("role Priority" rolepriority.setfont(new java.awt.font("verdana", 0, 12) jlabel8.setfont(new java.awt.font("verdana", 1, 12) jlabel8.settext("superior ID" superiorid.setfont(new java.awt.font("verdana", 0, 12) org.jdesktop.layout.grouplayout rolepanellayout = new org.jdesktop.layout.grouplayout(rolepanel rolepanel.setlayout(rolepanellayout rolepanellayout.sethorizontalgroup( rolepanellayout.createparallelgroup(org.jdesktop.layout.grouplayout.lea DING).add(rolePanelLayout.createSequentialGroup().addContainerGap().add(rolePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayou t.leading).add(jlabel6).add(jlabel7).add(jlabel8)).add(17, 17, 17).add(rolePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayou t.leading).add(rolename, 169, Short.MAX_VALUE).add(rolePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayou t.trailing, false) 9 of 62
.add(org.jdesktop.layout.grouplayout.leading, rolepriority).add(org.jdesktop.layout.grouplayout.leading, superiorid, 32, Short.MAX_VALUE))).addContainerGap()) rolepanellayout.setverticalgroup( rolepanellayout.createparallelgroup(org.jdesktop.layout.grouplayout.lea DING).add(rolePanelLayout.createSequentialGroup().addContainerGap().add(rolePanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayou t.baseline).add(jlabel6).add(rolename, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(rolepanellayout.createparallelgroup(org.jdesktop.layout.grouplayou t.baseline).add(jlabel7).add(rolepriority, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(rolepanellayout.createparallelgroup(org.jdesktop.layout.grouplayou t.baseline).add(jlabel8).add(superiorid, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap(175, Short.MAX_VALUE)) jtabbedpane1.addtab("role", rolepanel jmenu2.settext("file" jmenuitem1.settext("add New User" jmenuitem1.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { jmenuitem1actionperformed(evt jmenu2.add(jmenuitem1 10 of 62
jmenuitem2.settext("edit Selected User" jmenuitem2.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { jmenuitem2actionperformed(evt jmenu2.add(jmenuitem2 jmenuitem3.settext("delete Selected User" jmenuitem3.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { jmenuitem3actionperformed(evt jmenu2.add(jmenuitem3 jmenubar2.add(jmenu2 setjmenubar(jmenubar2 org.jdesktop.layout.grouplayout layout = new org.jdesktop.layout.grouplayout(getcontentpane() getcontentpane().setlayout(layout layout.sethorizontalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(layout.createsequentialgroup().add(jscrollpane1, 100, org.jdesktop.layout.grouplayout.preferred_size).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(jtabbedpane1, 294, Short.MAX_VALUE)) layout.setverticalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(jscrollpane1, 291, Short.MAX_VALUE).add(org.jdesktop.layout.GroupLayout.TRAILING, jtabbedpane1, 291, Short.MAX_VALUE) pack( // </editor-fold>//gen-end:initcomponents * This method deletes the currently selected user 11 of 62
private void jmenuitem3actionperformed(java.awt.event.actionevent evt) {//GEN-FIRST:event_jMenuItem3ActionPerformed // TODO add your handling code here: delete user //GEN-LAST:event_jMenuItem3ActionPerformed * This method opens a form to edit the currently selected users information private void jmenuitem2actionperformed(java.awt.event.actionevent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed new BackgroundPanel().setVisible(true new EditUserFrame().setVisible(true //GEN-LAST:event_jMenuItem2ActionPerformed * This method opens a new user dialog private void jmenuitem1actionperformed(java.awt.event.actionevent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed new BackgroundPanel().setVisible(true new NewUserFrame().setVisible(true //GEN-LAST:event_jMenuItem1ActionPerformed * This method populates the user information on the admin form private void jtree1focusgained(java.awt.event.focusevent evt) {//GEN-FIRST:event_jTree1FocusGained path = jtree1.getselectionpath( if(path!= null){ UserTreeNode usernode = (UserTreeNode)path.getLastPathComponent( UserBean userinfo = usernode.getuserinfo( firstnametext.settext(userinfo.getuserfirstname() lastnametext.settext(userinfo.getuserlastname() logintext.settext(userinfo.getuserlogin() passwordtext.settext(userinfo.getpassword() idtext.settext(userinfo.getuserid() rolename.settext(userinfo.getrolename() rolepriority.settext(integer.tostring(userinfo.getrolepriority()) superiorid.settext(userinfo.getsuperiorid() logintext.updateui( personalpanel.grabfocus( //GEN-LAST:event_jTree1FocusGained * Runs the form * @param args the command line arguments public static void main(string args[]) { java.awt.eventqueue.invokelater(new Runnable() { public void run() { new BackgroundPanel().setVisible(true 12 of 62
new AdminFrame().setVisible(true // Variables declaration - do not modify//gen-begin:variables private javax.swing.jtextfield firstnametext; private javax.swing.jtextfield idtext; private javax.swing.jlabel jlabel1; private javax.swing.jlabel jlabel2; private javax.swing.jlabel jlabel3; private javax.swing.jlabel jlabel4; private javax.swing.jlabel jlabel5; private javax.swing.jlabel jlabel6; private javax.swing.jlabel jlabel7; private javax.swing.jlabel jlabel8; private javax.swing.jmenu jmenu2; private javax.swing.jmenubar jmenubar2; private javax.swing.jmenuitem jmenuitem1; private javax.swing.jmenuitem jmenuitem2; private javax.swing.jmenuitem jmenuitem3; private javax.swing.jscrollpane jscrollpane1; private javax.swing.jtabbedpane jtabbedpane1; private javax.swing.jtree jtree1; private javax.swing.jtextfield lastnametext; private javax.swing.jpanel loginpanel; private javax.swing.jtextfield logintext; private javax.swing.jtextfield passwordtext; private javax.swing.jpanel personalpanel; private javax.swing.jtextfield rolename; private javax.swing.jpanel rolepanel; private javax.swing.jtextfield rolepriority; private javax.swing.jtextfield superiorid; // End of variables declaration//gen-end:variables 13 of 62
ALlImagesFilter Class /* * AllImagesFilter.java * * Created on November 25, 2006, 6:19 PM * package rolecoll.beans; import java.io.file; import javax.swing.filechooser.filefilter; * This filter will show all jpg, gif, and png files aswell as all folders in * the directory. public class AllImagesFilter extends FileFilter { * This method will return the accepted status of an input file. * @param file - input file * @return boolean - returns the accepted status of a file public boolean accept(file file) { String filename = file.getname( if(filename.endswith(".jpg") filename.endswith(".gif") filename.endswith(".png") file.isdirectory()){ return true; else{ return false; * This method returns the decription of the filter for the file dialog * drop down menu. * @return String - Description public String getdescription() { return "All Images"; 14 of 62
BackgroundPanal Class /* * BackgroundPanel.java * * Created on November 25, 2006, 1:46 PM package rolecoll.ui; import com.l2fprod.gui.plaf.skin.skin; import com.l2fprod.gui.plaf.skin.skinlookandfeel; import javax.swing.uimanager; import rolecoll.beans.users; * Background for all panels public class BackgroundPanel extends javax.swing.jpanel { Creates new form BackgroundPanel public BackgroundPanel() { try{ // first tell SkinLF which theme to use Skin skintouse = SkinLookAndFeel.loadThemePack(Users.class.getClassLoader().getResource( "themes/aquathemepack.zip") SkinLookAndFeel.setSkin(skinToUse // finally set the Skin Look And Feel UIManager.setLookAndFeel(new SkinLookAndFeel() catch(exception e){ e.printstacktrace( initcomponents( * Runs the Panel stand alone. public static void main(string args[]) { java.awt.eventqueue.invokelater(new Runnable() { public void run() { new BackgroundPanel().setVisible(true This method is called from within the constructor to * initialize the form. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initcomponents() { 15 of 62
org.jdesktop.layout.grouplayout layout = new org.jdesktop.layout.grouplayout(this this.setlayout(layout layout.sethorizontalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(0, 278, Short.MAX_VALUE) layout.setverticalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(0, 129, Short.MAX_VALUE) // </editor-fold>//gen-end:initcomponents // Variables declaration - do not modify//gen-begin:variables // End of variables declaration//gen-end:variables 16 of 62
ConnectionManager Class /* * ConnectionManager.java * * Created on December 9, 2006, 12:42 PM package rolecoll.beans; import java.io.ioexception; import java.sql.connection; import java.sql.drivermanager; import java.sql.sqlexception; import java.util.properties; * This class creates a static connection to the database public class ConnectionManager { * Static connection to the database private static Connection connection = null; private static final String DB_HOST = "rolecoll.database.host"; private static final String DB_PORT = "rolecoll.database.port"; private static final String DB_NAME = "rolecoll.database.name"; private static final String DB_USER = "rolecoll.database.user"; private static final String DB_PASSWORD = "rolecoll.database.password"; private static final String DB_TYPE = "rolecoll.database.type"; private static final String DB_DRIVER = "rolecoll.database.driver"; private static final String PROP_FILE = "database.properties"; private Properties properties = new Properties( Creates a new instance of ConnectionManager public ConnectionManager() throws SQLException, IOException, ClassNotFoundException { // read properties file properties.load(this.getclass().getclassloader().getresourceasstream(pr OP_FILE) // instanciate the driver class Class.forName(properties.getProperty(DB_DRIVER) // Connect to dabase String host = properties.getproperty(db_host String port = properties.getproperty(db_port String dbname = properties.getproperty(db_name String user = properties.getproperty(db_user String password = properties.getproperty(db_password 17 of 62
String type = properties.getproperty(db_type dbname; String url = "jdbc:" + type + "://" + host + ":" + port + "/" + connection = DriverManager.getConnection(url, user, password * This method destroys the connection public static void destroy() throws SQLException { if(connection!= null){ connection.close( * This method returns the status of the connection * @return boolean public boolean isconnected() throws SQLException { return!connection.isclosed( * This method returns the static connection * @return Connection public static Connection getconnection(){ return connection; 18 of 62
EditUserFrame Class /* * NewUserFrame.java * * Created on December 7, 2006, 8:19 PM package rolecoll.ui; import javax.imageio.imageio; import rolecoll.beans.skinbean; import rolecoll.beans.users; * Frame for dispaying user information public class EditUserFrame extends javax.swing.jframe { Creates new form NewUserFrame public EditUserFrame() { Users.getUsers( SkinBean.initSkin(SkinBean.skin initcomponents( This method is called from within the constructor to * initialize the form. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initcomponents() { jtabbedpane1 = new javax.swing.jtabbedpane( jpanel1 = new javax.swing.jpanel( jtextfield1 = new javax.swing.jtextfield( jtextfield2 = new javax.swing.jtextfield( jlabel1 = new javax.swing.jlabel( jlabel2 = new javax.swing.jlabel( jpanel2 = new javax.swing.jpanel( jtextfield3 = new javax.swing.jtextfield( jtextfield4 = new javax.swing.jtextfield( jlabel3 = new javax.swing.jlabel( jlabel4 = new javax.swing.jlabel( jpanel3 = new javax.swing.jpanel( jtextfield5 = new javax.swing.jtextfield( jtextfield6 = new javax.swing.jtextfield( jlabel5 = new javax.swing.jlabel( jlabel6 = new javax.swing.jlabel( jtextfield7 = new javax.swing.jtextfield( jlabel7 = new javax.swing.jlabel( jbutton1 = new javax.swing.jbutton( jbutton2 = new javax.swing.jbutton( setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close settitle("enter User Information" 19 of 62
try{ seticonimage(imageio.read(edituserframe.class.getclassloader().getresou rce("images/rolecoll.jpg")) catch(exception e){ e.printstacktrace( setresizable(false jtabbedpane1.setfont(new java.awt.font("verdana", 1, 12) jtextfield1.setcolumns(20 jtextfield1.setfont(new java.awt.font("verdana", 0, 12) jtextfield2.setcolumns(20 jtextfield2.setfont(new java.awt.font("verdana", 0, 12) jlabel1.setfont(new java.awt.font("verdana", 1, 12) jlabel1.settext("first Name" jlabel2.setfont(new java.awt.font("verdana", 1, 12) jlabel2.settext("last Name" org.jdesktop.layout.grouplayout jpanel1layout = new org.jdesktop.layout.grouplayout(jpanel1 jpanel1.setlayout(jpanel1layout jpanel1layout.sethorizontalgroup( jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout.leadi NG).add(jPanel1Layout.createSequentialGroup().add(25, 25, 25).add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. LEADING).add(jLabel1).add(jLabel2)).add(35, 35, 35).add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. TRAILING).add(jTextField1, org.jdesktop.layout.grouplayout.preferred_size).add(jtextfield2, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap(54, Short.MAX_VALUE)) jpanel1layout.setverticalgroup( jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout.leadi NG).add(jPanel1Layout.createSequentialGroup().add(20, 20, 20) 20 of 62
.add(jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout. BASELINE).add(jLabel1).add(jTextField1, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout. BASELINE).add(jLabel2).add(jTextField2, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap(42, Short.MAX_VALUE)) jtabbedpane1.addtab("personal", jpanel1 jtextfield3.setcolumns(20 jtextfield3.setfont(new java.awt.font("verdana", 0, 12) jtextfield4.setfont(new java.awt.font("verdana", 0, 12) jlabel3.setfont(new java.awt.font("verdana", 1, 12) jlabel3.settext("user Name" jlabel4.setfont(new java.awt.font("verdana", 1, 12) jlabel4.settext("password" org.jdesktop.layout.grouplayout jpanel2layout = new org.jdesktop.layout.grouplayout(jpanel2 jpanel2.setlayout(jpanel2layout jpanel2layout.sethorizontalgroup( jpanel2layout.createparallelgroup(org.jdesktop.layout.grouplayout.leadi NG).add(jPanel2Layout.createSequentialGroup().add(24, 24, 24).add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. LEADING).add(jLabel3).add(jLabel4)).add(37, 37, 37).add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. TRAILING, false).add(jtextfield4).add(jtextfield3)).add(52, 52, 52)) jpanel2layout.setverticalgroup( 21 of 62
jpanel2layout.createparallelgroup(org.jdesktop.layout.grouplayout.leadi NG).add(jPanel2Layout.createSequentialGroup().add(20, 20, 20).add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. BASELINE).add(jLabel3).add(jTextField3, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(jpanel2layout.createparallelgroup(org.jdesktop.layout.grouplayout. BASELINE).add(jLabel4).add(jTextField4, 21, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap(42, Short.MAX_VALUE)) jtabbedpane1.addtab("login", jpanel2 jtextfield5.setcolumns(20 jtextfield5.setfont(new java.awt.font("verdana", 0, 12) jtextfield6.setcolumns(3 jtextfield6.setfont(new java.awt.font("verdana", 0, 12) jlabel5.setfont(new java.awt.font("verdana", 1, 12) jlabel5.settext("role Name" jlabel6.setfont(new java.awt.font("verdana", 1, 12) jlabel6.settext("priority" jtextfield7.setcolumns(5 jtextfield7.setfont(new java.awt.font("verdana", 0, 12) jlabel7.setfont(new java.awt.font("verdana", 1, 12) jlabel7.settext("superior ID" org.jdesktop.layout.grouplayout jpanel3layout = new org.jdesktop.layout.grouplayout(jpanel3 jpanel3.setlayout(jpanel3layout jpanel3layout.sethorizontalgroup( jpanel3layout.createparallelgroup(org.jdesktop.layout.grouplayout.leadi NG).add(jPanel3Layout.createSequentialGroup().add(24, 24, 24).add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. LEADING).add(jLabel6) 22 of 62
.add(jlabel5).add(jlabel7)).add(38, 38, 38).add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. LEADING).add(jTextField6, org.jdesktop.layout.grouplayout.preferred_size).add(jtextfield5, org.jdesktop.layout.grouplayout.preferred_size).add(jtextfield7, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap(47, Short.MAX_VALUE)) jpanel3layout.setverticalgroup( jpanel3layout.createparallelgroup(org.jdesktop.layout.grouplayout.leadi NG).add(jPanel3Layout.createSequentialGroup().addContainerGap().add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. BASELINE).add(jLabel5).add(jTextField5, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(jpanel3layout.createparallelgroup(org.jdesktop.layout.grouplayout. BASELINE).add(jLabel6).add(jTextField6, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(jpanel3layout.createparallelgroup(org.jdesktop.layout.grouplayout. BASELINE).add(jLabel7).add(jTextField7, org.jdesktop.layout.grouplayout.preferred_size)).addcontainergap(22, Short.MAX_VALUE)) jtabbedpane1.addtab("role", jpanel3 23 of 62
jbutton1.setfont(new java.awt.font("verdana", 1, 12) jbutton1.settext("cancel" jbutton2.setfont(new java.awt.font("verdana", 1, 12) jbutton2.settext("ok" org.jdesktop.layout.grouplayout layout = new org.jdesktop.layout.grouplayout(getcontentpane() getcontentpane().setlayout(layout layout.sethorizontalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(org.jdesktop.layout.grouplayout.trailing, layout.createsequentialgroup().addcontainergap(272, Short.MAX_VALUE).add(jButton2).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jButton1).add(14, 14, 14)).add(jTabbedPane1) layout.setverticalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(layout.createsequentialgroup().add(jtabbedpane1, 138, org.jdesktop.layout.grouplayout.preferred_size).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(layout.createparallelgroup(org.jdesktop.layout.grouplayout.baselin E).add(jButton2).add(jButton1)).addContainerGap( Short.MAX_VALUE)) pack( // </editor-fold>//gen-end:initcomponents * runs the frame stand alone * @param args the command line arguments public static void main(string args[]) { java.awt.eventqueue.invokelater(new Runnable() { public void run() { new NewUserFrame().setVisible(true // Variables declaration - do not modify//gen-begin:variables 24 of 62
private javax.swing.jbutton jbutton1; private javax.swing.jbutton jbutton2; private javax.swing.jlabel jlabel1; private javax.swing.jlabel jlabel2; private javax.swing.jlabel jlabel3; private javax.swing.jlabel jlabel4; private javax.swing.jlabel jlabel5; private javax.swing.jlabel jlabel6; private javax.swing.jlabel jlabel7; private javax.swing.jpanel jpanel1; private javax.swing.jpanel jpanel2; private javax.swing.jpanel jpanel3; private javax.swing.jtabbedpane jtabbedpane1; private javax.swing.jtextfield jtextfield1; private javax.swing.jtextfield jtextfield2; private javax.swing.jtextfield jtextfield3; private javax.swing.jtextfield jtextfield4; private javax.swing.jtextfield jtextfield5; private javax.swing.jtextfield jtextfield6; private javax.swing.jtextfield jtextfield7; // End of variables declaration//gen-end:variables 25 of 62
GetUser Class /* * GetUser.java * * Created on December 10, 2006, 6:05 PM package rolecoll.beans; import java.util.arraylist; import java.util.collection; * This class will retreive user data from the database public class GetUser { private static final String SELECT_SINGLE = "SELECT * FROM USERS" + " WHERE id=%id%"; private static final String SELECT_ALL = "SELECT * FROM USERS" + " WHERE id=%id%"; all Creates a new instance of GetUser public GetUser() { * This method returns a collection of user beans populated with * of the user data in the database * @return Collection - collection of user beans public static Collection selectallusers(){ return new ArrayList( * This method returns a user bean given a user id * @param id - users id number * @return UserBean - user data from the database public static UserBean selectuser(string id){ // todo return new UserBean( 26 of 62
GIFFilter Class /* * GIFFilter.java * * Created on November 25, 2006, 6:19 PM package rolecoll.beans; import java.io.file; import javax.swing.filechooser.filefilter; * Filters all files except.gif files from the file dialog box public class GIFFilter extends FileFilter { box * @param file - file in question * @return boolean - the filtered status of a file public boolean accept(file file) { String filename = file.getname( return filename.endswith(".gif" * @return String - discription of the filter for the file dialog public String getdescription() { return "*.gif"; 27 of 62
JPGFilter Class /* * JPGFilter.java * * Created on November 25, 2006, 6:19 PM package rolecoll.beans; import java.io.file; import javax.swing.filechooser.filefilter; * Filters all files except.jpg files from the file dialog box public class JPGFilter extends FileFilter { box * @param file - file in question * @return boolean - the filtered status of a file public boolean accept(file file) { String filename = file.getname( return filename.endswith(".jpg" * @return String - discription of the filter for the file dialog public String getdescription() { return "*.jpg"; 28 of 62
LoginFrame Class /* * LoginFrame.java * * Created on November 25, 2006, 1:57 PM package rolecoll.ui; import java.net.url; import javax.imageio.imageio; import javax.swing.uimanager; import rolecoll.beans.skinbean; import rolecoll.beans.userbean; import rolecoll.beans.users; * This class validates a users credintals and opens the correct frame public class LoginFrame extends javax.swing.jframe { Creates new form LoginFrame public LoginFrame() { SkinBean.initSkin(SkinBean.skin Users.getUsers( initcomponents( This method is called from within the constructor to * initialize the form. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initcomponents() { jpanel1 = new javax.swing.jpanel( jtextfield1 = new javax.swing.jtextfield( jlabel1 = new javax.swing.jlabel( jlabel2 = new javax.swing.jlabel( jbutton1 = new javax.swing.jbutton( jpasswordfield1 = new javax.swing.jpasswordfield( jcombobox1 = new javax.swing.jcombobox( jlabel3 = new javax.swing.jlabel( setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close settitle("role-coll Login" try{ seticonimage(imageio.read(loginframe.class.getclassloader().getresource ("images/rolecoll.jpg")) catch(exception e){ e.printstacktrace( setname("loginframe" setresizable(false 29 of 62
jtextfield1.setcolumns(20 jtextfield1.setfont(new java.awt.font("verdana", 0, 12) jtextfield1.setautoscrolls(false jlabel1.setfont(new java.awt.font("verdana", 1, 12) jlabel1.settext("login" jlabel2.setfont(new java.awt.font("verdana", 1, 12) jlabel2.settext("password" { { jbutton1.setfont(new java.awt.font("verdana", 1, 12) jbutton1.settext("ok" jbutton1.addactionlistener(new java.awt.event.actionlistener() public void actionperformed(java.awt.event.actionevent evt) jbutton1actionperformed(evt jpasswordfield1.setfont(new java.awt.font("verdana", 0, 12) jcombobox1.setfont(new java.awt.font("verdana", 0, 12) jcombobox1.setmodel(new javax.swing.defaultcomboboxmodel(new String[] { "Default", "Aqua", "Ninja", "Tiger", "Toxic" ) jcombobox1.additemlistener(new java.awt.event.itemlistener() { public void itemstatechanged(java.awt.event.itemevent evt) { jcombobox1itemstatechanged(evt jlabel3.setfont(new java.awt.font("verdana", 1, 12) jlabel3.settext("skin Theme" org.jdesktop.layout.grouplayout jpanel1layout = new org.jdesktop.layout.grouplayout(jpanel1 jpanel1.setlayout(jpanel1layout jpanel1layout.sethorizontalgroup( jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout.leadi NG).add(org.jdesktop.layout.GroupLayout.TRAILING, jpanel1layout.createsequentialgroup().addcontainergap().add(jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout. TRAILING).add(jButton1, 67, org.jdesktop.layout.grouplayout.preferred_size).add(org.jdesktop.layout.grouplayout.leading, jpanel1layout.createsequentialgroup().add(jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout. LEADING).add(jLabel1) 30 of 62
.add(jlabel2).add(jlabel3)).add(22, 22, 22).add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. LEADING).add(org.jdesktop.layout.GroupLayout.TRAILING, jcombobox1, 0, 124, Short.MAX_VALUE).add(org.jdesktop.layout.GroupLayout.TRAILING, jpasswordfield1, 124, Short.MAX_VALUE).add(jTextField1, 124, Short.MAX_VALUE)))).add(19, 19, 19)) jpanel1layout.setverticalgroup( jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout.leadi NG).add(jPanel1Layout.createSequentialGroup().addContainerGap().add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. BASELINE).add(jLabel1).add(jTextField1, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(jpanel1layout.createparallelgroup(org.jdesktop.layout.grouplayout. BASELINE).add(jLabel2).add(jPasswordField1, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related, Short.MAX_VALUE).add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout. BASELINE).add(jComboBox1, org.jdesktop.layout.grouplayout.preferred_size).add(jlabel3)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(jbutton1).add(29, 29, 29)) 31 of 62
org.jdesktop.layout.grouplayout layout = new org.jdesktop.layout.grouplayout(getcontentpane() getcontentpane().setlayout(layout layout.sethorizontalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(jpanel1, Short.MAX_VALUE) layout.setverticalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(jpanel1, 129, org.jdesktop.layout.grouplayout.preferred_size) pack( // </editor-fold>//gen-end:initcomponents * This method sets the skin chosen by the user private void jcombobox1itemstatechanged(java.awt.event.itemevent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged SkinBean.skin = (String)jComboBox1.getSelectedItem( //GEN-LAST:event_jComboBox1ItemStateChanged * This method checks the creditals of a user and opens the correct frame * for that user private void jbutton1actionperformed(java.awt.event.actionevent evt) {//GEN-FIRST:event_jButton1ActionPerformed // get text from fields String user = jtextfield1.gettext( String password = String.valueOf(jPasswordField1.getPassword() // get user bean UserBean userbean = (UserBean)Users.userMap.get(user if(user!= null && password!= null){ // check password if(userbean.getpassword().equals(password)){ // open main frame if(!userbean.isadmin()){ this.setvisible(false new BackgroundPanel().setVisible(true new MainFrame().setVisible(true // open admin frame else{ this.setvisible(false new BackgroundPanel().setVisible(true new AdminFrame().setVisible(true else{ 32 of 62
// todo display error //GEN-LAST:event_jButton1ActionPerformed * Run the login frame * @param args the command line arguments public static void main(string args[]) { java.awt.eventqueue.invokelater(new Runnable() { public void run() { new LoginFrame().setVisible(true // Variables declaration - do not modify//gen-begin:variables private javax.swing.jbutton jbutton1; private javax.swing.jcombobox jcombobox1; private javax.swing.jlabel jlabel1; private javax.swing.jlabel jlabel2; private javax.swing.jlabel jlabel3; private javax.swing.jpanel jpanel1; private javax.swing.jpasswordfield jpasswordfield1; private javax.swing.jtextfield jtextfield1; // End of variables declaration//gen-end:variables 33 of 62
MainFrame Class /* * MainFrame.java * * Created on November 20, 2006, 9:53 PM package rolecoll.ui; import com.l2fprod.gui.plaf.skin.skin; import com.l2fprod.gui.plaf.skin.skinlookandfeel; import java.awt.color; import java.awt.component; import java.awt.container; import java.awt.point; import java.awt.event.mouseevent; import java.awt.event.mouselistener; import java.awt.event.mousemotionlistener; import java.awt.image.bufferedimage; import java.io.file; import java.io.ioexception; import javax.imageio.imageio; import javax.swing.imageicon; import javax.swing.jbutton; import javax.swing.jfilechooser; import javax.swing.jframe; import javax.swing.jinternalframe; import javax.swing.jlabel; import javax.swing.jlayeredpane; import javax.swing.jpanel; import javax.swing.jscrollpane; import javax.swing.jtextarea; import javax.swing.jtextpane; import javax.swing.jtoolbar; import javax.swing.jviewport; import javax.swing.jwindow; import javax.swing.lookandfeel; import javax.swing.uimanager; import javax.swing.unsupportedlookandfeelexception; import javax.swing.filechooser.filefilter; import javax.swing.tree.defaulttreecellrenderer; import rolecoll.beans.*; * This class displays the main UI screen public class MainFrame extends JFrame { private JTextPane textpane = null; private int xadjustment; private int yadjustment; Creates new form MainFrame public MainFrame() { // init skin 34 of 62
SkinBean.initSkin(SkinBean.skin initcomponents( // Update only one tree instance DefaultTreeCellRenderer renderer = (DefaultTreeCellRenderer)jTree1.getCellRenderer( // Remove the tree icons renderer.setleaficon(null renderer.setclosedicon(null renderer.setopenicon(null This method is called from within the constructor to * initialize the form. // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initcomponents() { jscrollpane1 = new javax.swing.jscrollpane( jtree1 = jtree1 = new javax.swing.jtree(users.usertree jtabbedpane1 = new javax.swing.jtabbedpane( jlabel1 = new javax.swing.jlabel( jlabel2 = new javax.swing.jlabel( jtoolbar1 = new JToolBar(null, JToolBar.VERTICAL try{ jbutton1 = new JButton( new ImageIcon( ImageIO.read(MainFrame.class.getClassLoader().getResource("images/open. jpg"))) catch(exception e){ e.printstacktrace( try{ jbutton2 = new JButton( new ImageIcon( ImageIO.read(MainFrame.class.getClassLoader().getResource("images/save. jpg"))) catch(exception e){ e.printstacktrace( try{ jbutton3 = new JButton( new ImageIcon( ImageIO.read(MainFrame.class.getClassLoader().getResource("images/note. jpg"))) catch(exception e){ e.printstacktrace( try{ jbutton4 = new JButton( new ImageIcon( 35 of 62
ImageIO.read(MainFrame.class.getClassLoader().getResource("images/FullS creen.jpg"))) catch(exception e){ e.printstacktrace( jmenubar1 = new javax.swing.jmenubar( jmenu1 = new javax.swing.jmenu( jmenuitem1 = new javax.swing.jmenuitem( jmenu2 = new javax.swing.jmenu( jmenu3 = new javax.swing.jmenu( setdefaultcloseoperation(javax.swing.windowconstants.exit_on_close settitle("role-coll" try{ seticonimage(imageio.read(mainframe.class.getclassloader().getresource( "images/rolecoll.jpg")) catch(exception e){ e.printstacktrace( jtree1.setfont(new java.awt.font("verdana", 1, 11) jscrollpane1.setviewportview(jtree1 jtabbedpane1.settabplacement(javax.swing.jtabbedpane.bottom jlabel1.setfont(new java.awt.font("verdana", 1, 14) jlabel1.sethorizontalalignment(javax.swing.swingconstants.center jlabel1.settext("users Tree" jlabel2.setfont(new java.awt.font("verdana", 1, 14) jlabel2.sethorizontalalignment(javax.swing.swingconstants.center jlabel2.settext("document Panel" { { jtoolbar1.setrollover(true jtoolbar1.setfont(new java.awt.font("verdana", 0, 12) jbutton1.setfont(new java.awt.font("verdana", 1, 12) jbutton1.settooltiptext("open" jbutton1.addactionlistener(new java.awt.event.actionlistener() public void actionperformed(java.awt.event.actionevent evt) jbutton1actionperformed(evt jtoolbar1.add(jbutton1 jbutton2.setfont(new java.awt.font("verdana", 1, 12) jbutton2.settooltiptext("save" jtoolbar1.add(jbutton2 jbutton3.setfont(new java.awt.font("verdana", 1, 12) jbutton3.settooltiptext("new Note" 36 of 62
{ { jbutton3.addactionlistener(new java.awt.event.actionlistener() public void actionperformed(java.awt.event.actionevent evt) jbutton3actionperformed(evt jtoolbar1.add(jbutton3 jbutton4.setfont(new java.awt.font("verdana", 1, 12) jbutton4.settooltiptext("full Screen" jtoolbar1.add(jbutton4 jmenu1.settext("file" jmenuitem1.settext("open" jmenuitem1.addactionlistener(new java.awt.event.actionlistener() { public void actionperformed(java.awt.event.actionevent evt) { jmenuitem1actionperformed(evt jmenu1.add(jmenuitem1 jmenubar1.add(jmenu1 jmenu2.settext("edit" jmenubar1.add(jmenu2 jmenu3.settext("help" jmenubar1.add(jmenu3 setjmenubar(jmenubar1 org.jdesktop.layout.grouplayout layout = new org.jdesktop.layout.grouplayout(getcontentpane() getcontentpane().setlayout(layout layout.sethorizontalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(layout.createsequentialgroup().add(layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading, false).add(jlabel1, Short.MAX_VALUE).add(jScrollPane1, 135, Short.MAX_VALUE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILIN G) 37 of 62
.add(jtabbedpane1, 280, Short.MAX_VALUE).add(jLabel2, 280, Short.MAX_VALUE)).addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED).add(jToolBar1, 35, org.jdesktop.layout.grouplayout.preferred_size).add(0, 0, 0)) layout.setverticalgroup( layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading).add(layout.createsequentialgroup().add(layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading ).add(jlabel2).add(jlabel1, 18, org.jdesktop.layout.grouplayout.preferred_size)).addpreferredgap(org.jdesktop.layout.layoutstyle.related).add(layout.createparallelgroup(org.jdesktop.layout.grouplayout.leading ).add(layout.createsequentialgroup().add(jtoolbar1, org.jdesktop.layout.grouplayout.preferred_size).add(260, 260, 260)).add(org.jdesktop.layout.GroupLayout.TRAILING, jscrollpane1, 285, Short.MAX_VALUE).add(org.jdesktop.layout.GroupLayout.TRAILING, jtabbedpane1, 285, Short.MAX_VALUE))) pack( // </editor-fold>//gen-end:initcomponents * This method creates a new note on the currently selected document private void jbutton3actionperformed(java.awt.event.actionevent evt) {//GEN-FIRST:event_jButton3ActionPerformed JInternalFrame note = new JInternalFrame( note.setopaque(false note.setbackground(new Color(255, 255, 255, 0) note.setresizable(true note.setclosable(true note.setsize(100, 100 note.setmaximizable(true 38 of 62
JTextPane textpane = new JTextPane( textpane.setopaque(false note.getcontentpane().add(textpane note.show( JScrollPane pane = (JScrollPane)jTabbedPane1.getSelectedComponent( JLabel label = (JLabel)((JViewport)pane.getComponent(0)).getComponent(0 label.add(note //GEN-LAST:event_jButton3ActionPerformed /* * This method opens a dialog box for opening documents (tool bar) private void jbutton1actionperformed(java.awt.event.actionevent evt) {//GEN-FIRST:event_jButton1ActionPerformed openaction( //GEN-LAST:event_jButton1ActionPerformed /* * This method opens a dialog box for opening documents (File menu) private void jmenuitem1actionperformed(java.awt.event.actionevent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed openaction( //GEN-LAST:event_jMenuItem1ActionPerformed * Runs the form * @param args the command line arguments public static void main(string args[]) { java.awt.eventqueue.invokelater(new Runnable() { public void run() { new BackgroundPanel().setVisible(true new MainFrame().setVisible(true * This method creates a open dialog used to open a document private void openaction(){ // file dialog JFileChooser chooser = new JFileChooser( // remove "All Files" filter FileFilter[] filters = chooser.getchoosablefilefilters( chooser.removechoosablefilefilter(filters[0] // add jpg filter FileFilter jpgfilter = new JPGFilter( chooser.addchoosablefilefilter(jpgfilter // add gif filter FileFilter giffilter = new GIFFilter( 39 of 62
chooser.addchoosablefilefilter(giffilter // add png filter FileFilter pngfilter = new PNGFilter( chooser.addchoosablefilefilter(pngfilter // add bmp filter FileFilter allimagesfilter = new AllImagesFilter( chooser.addchoosablefilefilter(allimagesfilter JFrame frame = new JFrame( chooser.showopendialog(frame // Get the selected file File file = chooser.getselectedfile( String filename = file.getname( BufferedImage image = null; try { image = ImageIO.read(file catch(ioexception e) { System.out.println("read error: " + e.getmessage() ImageIcon icon = new ImageIcon(image JLabel imagelabel = new JLabel(icon JScrollPane imagescroll = new JScrollPane(imageLabel jtabbedpane1.add(filename.substring(0, filename.lastindexof(".")), imagescroll // move selected panel to new panel if(jtabbedpane1.getselectedindex() > -1 ){ jtabbedpane1.setselectedindex(jtabbedpane1.getselectedindex()+1 // Variables declaration - do not modify//gen-begin:variables private javax.swing.jbutton jbutton1; private javax.swing.jbutton jbutton2; private javax.swing.jbutton jbutton3; private javax.swing.jbutton jbutton4; private javax.swing.jlabel jlabel1; private javax.swing.jlabel jlabel2; private javax.swing.jmenu jmenu1; private javax.swing.jmenu jmenu2; private javax.swing.jmenu jmenu3; private javax.swing.jmenubar jmenubar1; private javax.swing.jmenuitem jmenuitem1; private javax.swing.jscrollpane jscrollpane1; private javax.swing.jtabbedpane jtabbedpane1; private javax.swing.jtoolbar jtoolbar1; private javax.swing.jtree jtree1; // End of variables declaration//gen-end:variables private JPanel jpanel2; 40 of 62