Help with BrowserLauncher2 and NetBeans

Hey guys, I'm new to Java and am having a lot of fun writing my own programs.

Right now I'm trying to incorporate the BrowserLauncher2 (http://browserlaunch2.sourceforge.net/) library into my Netbeans 5.5.1 project running on Mac OSX 10.4.10.

I have included the BrowserLauncher2 library using Tools --> Library Manager and placed it in my "compile-time libraries" by right-clicking on the Libraries-->Properties in the Project screen but I still get an error when I try to call a URL.

I call it using: BrowserLauncher().openURLinBrowser("http://www.google.com"); and I receive the error

/Users/Krish/Programming/NetBeans/MusicFestivals_Revamped/src/$2007/learn.java:179: cannot find symbol

symbol : method BrowserLauncher()

location: class $2007.learn

BrowserLauncher().openURLinBrowser("http://www.google.com");

I'm sure I'm just not instantiating/importing the library properly but am really lost as to how to do it.

I've tried googling but there doesn't seem to be any Netbeans and BrowserLauncher2 guide/how-to yet so maybe we could help create one.

Thanks in advance!

Here's my code:

/*

* learn.java

*

* Created on June 28, 2007, 8:40 PM

*/

package $2007;

import java.awt.Font;

import java.awt.event.MouseAdapter;

import java.awt.event.MouseEvent;

import javax.swing.JTable;

import javax.swing.ListSelectionModel;

import javax.swing.event.ListSelectionEvent;

import javax.swing.event.ListSelectionListener;

import javax.swing.table.DefaultTableModel;

import java.net.URL;

//import BrowserLauncher2;

/**

*

* @author Krish

*/

publicclass learnextends javax.swing.JFrame{

final String[] columnNames ={"Festival Name",

"URL",

"Begins",

"Ends",

"Hide me!"};

final Object[][] data ={

{"National Orchestral Institute","http://www.music.umd.edu/special_programs/national_orchestral_institute/","6-1-07","6-30-07"},

{"Tafelmusik; Baroque Summer Music Institute","http://tafelmusik.org/training/tbsi/bsi.htm","6-1-07","6-14-07"},

{"Texas Music Festival","http://www.uh.edu/tmf/","6-1-07","6-30-07"},

{"Hot Springs Music Festival","http://www.hotmusic.org/apprentices.htm","6-2-07","6-16-07"},

{"Domaine Forget: Brass Session","http://www.domaineforget.com/en/academie/cor.shtml","6-3-07","6-17-07"},

{"Round Top, The International Music Festival at","http://festivalhill.org/Summerprogram.html","6-3-07","7-15-07"},

{"Sarasota Music Festival","https://tickets.fwcs.org/public/load_screen.asp?screen=Sarasota_Music_Festival","6-4-07","6-23-07"},

{"Sunflower Music Festival","http://www.sunflowermusicfestival.org/","6-5-07","6-12-07 (6-16-07 faculty concerts)"},

{"Colorado College Summer Music Festival","http://www.coloradocollege.edu/SummerPrograms/SummerFestivaloftheArts/musicfestival/","6-9-07","7-4-07"},

{"Kendall Betts Horn Camp","http://horncamp.org/","6-9-07","6-24-07"},

{"Wintergreen Summer Music Academy","http://wintergreenperformingarts.org/index.php?pageId=45","6-9-07","6-29-07"},

{"National Repertory Orchestra","http://www.nationalrepertoryorchestra.com/","6-10-07","8-5-07"},

{"Rocky Ridge Music Center; Young Artists Seminar","http://www.rockyridge.org/index.htm","6-11-07","7-15-07"},

{"Aspen Music Festival; Instrumental Program, American Academy of Conducting, Courses","http://www.aspenmusicfestival.com/","6-13-07","8-19-07"},

{"Music Academy of the West; Instrumental Program","http://www.musicacademy.org/","6-15-07","8-12-07"},

{"Sewanee Music Festival","http://www2.sewanee.edu/ssmf","6-16-07","7-22-07"},

{"Boston University Tanglewood Institute; French Horn Workshop","http://www.bu.edu/cfa/music/tanglewood/","6-17-07","6-30-07"},

{"ARIA International Music Festival","http://www.bsu.edu/web/cfa/music/aria/","6-18-07","7-14-07"},

{"Pierre Monteux School","http://www.monteuxschool.org/","6-18-07","7-29-07"},

{"Brevard Music Center","http://www.brevardmusic.org/index.php","6-20-07","8-5-07"},

{"Tanglewood Music Center; Instrumental and Orchestral Studies Fellowship","http://www.tanglewood.org/itemB/detail2columnTMC.jhtml?id=22800036&area=tgl","6-21-07","8-20-07"},

{"Bowdoin International Music Festival","http://www.summermusic.org/","6-23-07","8-4-07"},

{"Chautauqua Music Festival","http://music.ciweb.org/","6-23-07","8-14-07"},

{"Eastern Music Festival","http://www.easternmusicfestival.org","6-23-07","7-29-07"},

{"Bar Harbor Brass","http://www.barharborbrass.org./","6-24-07","7-1-07"},

{"Mannes Theory","http://216.71.55.88/mi/","6-24-07","6-27-07"},

{"New York Summer Music Festival","http://www.nysmf.org/","6-24-0","8-4-07"},

{"Kent/Blossom Music","http://dept.kent.edu/blossom/index.htm","7-1-07","8-12-07"},

{"Manchester Music Festival; Young Artists Program","http://www.mmfvt.org/index.cfm","7-1-07","8-14-07"},

{"Norfolk Chamber Music Festival; Chamber Music Session","http://www.yale.edu/norfolk/SchoolPrograms.htm","7-1-07","8-12-07"},

{"Yellow Barn Music School & Festival; Yellow Barn Program","http://www.yellowbarn.org/musicschool/yb.php","7-1-07","8-5-07"},

{"Banff Center; Master Classes","http://www.banffcentre.ca/programs/program.aspx?id=575","7-2-07","7-20-07"},

{"NSO Summer Music Institute","http://www.kennedy-center.org/nso/nsoed/smi/","7-2-07","7-29-07"},

{"Burgos Chamber Music Festival","http://www.burgosmusicfestival.com/home.htm","7-3-07","7-15-07"},

{"Schleswig-Holstein Music Festival","http://www.shmf.de/oa/","7-6-07","9-3-07"},

{"California Summer Music","http://www.csmusic.org/","7-7-07","7-30-07"},

{"Pacific Music Festival","http://www.pmf.or.jp/index_en.html","7-7-07","8-1-07"},

{"Institut Musical de Provence-Aubagne: Orchestral Workshop","http://www.impamusic.com/","7-11-07","7-20-07"},

{"Fairbanks Summer Music Festival","http://www.fsaf.org/","7-15-07","7-29-07"},

{"International Brass Quintet Summer Seminar","http://www.atlanticbrassquintet.com/seminar.php","7-21-07","8-3-07"},

{"Marrowstone Summer Music","http://marrowstone.syso.org/","7-22-07","8-5-07"},

{"Banff Center; Brass Residency","http://www.banffcentre.ca/programs/program.aspx?id=577","7-23-07","8-4-07"},

{"Banff Center; Opera & Concert Orchestra Residency","http://www.banffcentre.ca/programs/program.aspx?id=579","7-23-07","8-12-07"},

{"Rafael M閚dez Brass Institute","http://mendezbrassinstitute.com/","7-23-07","7-28-07"},

{"Las Vegas Music Festival","http://www.lasvegasmusicfestival.org/","7-27-07","8-12-07"},

{"Viana do Castello International Music Festival","http://www.vianamusicfest.org/index.html","8-1-07","8-15-07"},

{"Domaine Forget: New Music","http://www.domaineforget.com/en/academie/musNouvelle.shtml","8-12-07","8-25-07"}

};

/** Creates new form learn */

public learn(){

initComponents();

}

/** 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.

*/

// <editor-fold defaultstate="collapsed" desc=" Generated Code ">

privatevoid initComponents(){

jScrollPane2 =new javax.swing.JScrollPane();

myTextArea =new javax.swing.JTextArea();

jScrollPane1 =new javax.swing.JScrollPane();

table =new org.jdesktop.swingx.JXTable();

giftLabel =new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

addWindowListener(new java.awt.event.WindowAdapter(){

publicvoid windowActivated(java.awt.event.WindowEvent evt){

formWindowActivated(evt);

}

});

myTextArea.setColumns(20);

myTextArea.setRows(5);

jScrollPane2.setViewportView(myTextArea);

jScrollPane1.addMouseListener(new java.awt.event.MouseAdapter(){

publicvoid mouseEntered(java.awt.event.MouseEvent evt){

jScrollPane1MouseEntered(evt);

}

});

table.setModel(new DefaultTableModel(data, columnNames));

table.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS);

table.setColumnControlVisible(true);

table.addMouseListener(new java.awt.event.MouseAdapter(){

publicvoid mouseClicked(java.awt.event.MouseEvent evt){

tableMouseClicked(evt);

}

});

jScrollPane1.setViewportView(table);

giftLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/$2007/gift.gif")));

giftLabel.addMouseListener(new java.awt.event.MouseAdapter(){

publicvoid mouseClicked(java.awt.event.MouseEvent evt){

giftLabelMouseClicked(evt);

}

});

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()

.addContainerGap()

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING,false)

.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane2)

.add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 548, Short.MAX_VALUE))

.add(30, 30, 30)

.add(giftLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 258, Short.MAX_VALUE)

.addContainerGap())

);

layout.setVerticalGroup(

layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)

.add(layout.createSequentialGroup()

.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING,false)

.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()

.add(25, 25, 25)

.add(giftLabel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

.add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()

.addContainerGap()

.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 268, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))

.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)

.add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)

.addContainerGap(35, Short.MAX_VALUE))

);

pack();

}// </editor-fold>

privatevoid giftLabelMouseClicked(java.awt.event.MouseEvent evt){

// TODO add your handling code here:

BrowserLauncher().openURLinBrowser("http://www.google.com");

}

privatevoid formWindowActivated(java.awt.event.WindowEvent evt){

// TODO add your handling code here:

//disable gift icon on startup

giftLabel.setVisible(false);

}

privatevoid tableMouseClicked(java.awt.event.MouseEvent evt){

// TODO add your handling code here:

myTextArea.setText("haha! I replace you!: \n hey! you cliked a cell! \n you deserve a gift!\n");

int row = table.getSelectedRow();

Object data = table.getValueAt(row, 0);

myTextArea.append("Festival's name: " + data +"\n");

giftLabel.setVisible(true);

System.out.print("hi I'm the system.");

}

privatevoid jScrollPane1MouseEntered(java.awt.event.MouseEvent evt){

// TODO add your handling code here:

myTextArea.append("hey! you entered my scroll pane! \n");

//openURL(http://google.com);

// giftLabel.setVisible(false);

}

/**

* @param args the command line arguments

*/

publicstaticvoid main(String args[]){

java.awt.EventQueue.invokeLater(new Runnable(){

publicvoid run(){

new learn().setVisible(true);

}

});

}

// Variables declaration - do not modify

private javax.swing.JLabel giftLabel;

private javax.swing.JScrollPane jScrollPane1;

private javax.swing.JScrollPane jScrollPane2;

private javax.swing.JTextArea myTextArea;

private org.jdesktop.swingx.JXTable table;

// End of variables declaration

}

Message was edited by:

krimb1

[23688 byte] By [krimb1a] at [2007-11-27 9:11:55]
# 1

Hey! I made a breakthrough and thought I'd share it before anyone replies.

I added the following line with the rest of my imports:

import edu.stanford.ejalbert.BrowserLauncher;

However I still have not got it to work even with this new line so help is still welcome. =)

krimb1a at 2007-7-12 21:57:57 > top of Java-index,Java Essentials,New To Java...
# 2

Your call:

> BrowserLauncher().openURLinBrowser("http://www.google.com");

in your class learn can't be resolved by the compiler because your class does not define BrowserLauncher() method, nowhere.

I suspect, provided you have a proper import statement, the call should have been:

new BrowserLauncher().openURLinBrowser("http://www.google.com");

hiwaa at 2007-7-12 21:57:57 > top of Java-index,Java Essentials,New To Java...
# 3

Thanks for a quick reply!

I see now. I changed my call from

BrowserLauncher().openURLinBrowser("http://www.google.com");

to

new BrowserLauncher().openURLinBrowser("http://www.google.com");

And the earlier error message is now replaced with this one:

Compiling 1 source file to /Users/Krish/Programming/NetBeans/MusicFestivals_Revamped/build/classes

/Users/Krish/Programming/NetBeans/MusicFestivals_Revamped/src/$2007/learn.java:181: unreported exception edu.stanford.ejalbert.exception.BrowserLaunchingInitializingException; must be caught or declared to be thrown

new BrowserLauncher().openURLinBrowser("http://www.google.com");

1 error

BUILD FAILED (total time: 0 seconds)

I am fairly sure I am using the proper import statement as another help article here used the same call:

http://forum.java.sun.com/thread.jspa?threadID=5178589&tstart=75

import edu.stanford.ejalbert.BrowserLauncher;

class BrowserLauncher2 {

public static void main(String[] args) {

try {

BrowserLauncher launcher = new BrowserLauncher();

launcher.openURLinBrowser(args[0]);

}

catch (Exception e) {

e.printStackTrace();

}

}

}

I'm trying to read documentation on Exception handing from

http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html

but it's rather a tough tutorial and I'm not quite sure how to go about it.

Any other ideas? Thanks again.

krimb1a at 2007-7-12 21:57:57 > top of Java-index,Java Essentials,New To Java...
# 4
are you using netbeans gui editior?
schumachera at 2007-7-12 21:57:57 > top of Java-index,Java Essentials,New To Java...
# 5

Yes sir, I am using the NetBeans GUI editor to build my form etc.

In specific I'm using NetBeans IDE 5.5.1 under OSX 10.4.10 running Java 1.5.0_07.

Would it help if I posted a link to my entire project online? I'd be more than happy to if that's needed.

Hope that helps. =)

Message was edited by:

krimb1

krimb1a at 2007-7-12 21:57:57 > top of Java-index,Java Essentials,New To Java...
# 6
sorry but FUCKK neatbeans GUI editor. :). I hate it.. Well good luck i am sure someone will be able to help you out.
schumachera at 2007-7-12 21:57:57 > top of Java-index,Java Essentials,New To Java...