This discussion is archived
13 Replies Latest reply: Jun 12, 2013 11:52 PM by EJP RSS

got error while compiling this source code?

1012996 Newbie
Currently Being Moderated
[code =java]package com.agent.client.movies;

import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.ArrayList;

public interface DataSourceMovies extends Remote{

ArrayList<String[]> getAllMovies() throws RemoteException;
ArrayList<String[]> findMoviesByYear( int year) throws RemoteException;
ArrayList<String[]> findMoviesByDirector(String director) throws RemoteException;
ArrayList<String[]> findMoviesByGenre(String genre) throws RemoteException;
ArrayList<String[]> findMoviesByName(String name) throws RemoteException;
}



/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/*
* MovieClient.java
*
* Created on Apr 24, 2012, 10:49:58 AM
*/

package com.agent.client.movies;

import com.agent.client.songs.SongsClient;
import com.agent.client.Utility;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import javax.naming.InitialContext;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;

/**
*
*
*/
public class MovieClient extends javax.swing.JFrame {

ArrayList<String> mappedips = new ArrayList<String>();
DefaultListModel<String> modelmsg = new DefaultListModel<String>();
InitialContext ctx;

/** Creates new form MovieClient */
public MovieClient(String ips) {
setLookAndFeel();
initComponents();
Utility.setInCenter(this);

StringTokenizer stok = new StringTokenizer(ips, ":");
while(stok.hasMoreTokens())
mappedips.add(stok.nextToken());
}

public void setLookAndFeel(){
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(SongsClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(SongsClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(SongsClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(SongsClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
}

/** 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();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jPanel2 = new javax.swing.JPanel();
btclose = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
jPanel4 = new javax.swing.JPanel();
jPanel8 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
txtkey = new javax.swing.JTextField();
btsearch = new javax.swing.JButton();
jPanel9 = new javax.swing.JPanel();
rdbyname = new javax.swing.JRadioButton();
rdbydirector = new javax.swing.JRadioButton();
rdbygenre = new javax.swing.JRadioButton();
rdbyyear = new javax.swing.JRadioButton();
jPanel5 = new javax.swing.JPanel();
jPanel6 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
lstMessages = new javax.swing.JList(modelmsg);
jPanel7 = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
tabmovies = new javax.swing.JTable();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setMinimumSize(new java.awt.Dimension(500, 500));

jLabel1.setFont(new java.awt.Font("Simplified Arabic", 1, 24));
jLabel1.setForeground(new java.awt.Color(0, 102, 204));
jLabel1.setText("Mobile Agent: Find Movie Information");
jPanel1.add(jLabel1);

getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);

btclose.setText("Close");
btclose.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btcloseActionPerformed(evt);
}
});
jPanel2.add(btclose);

getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_END);

jPanel3.setLayout(new java.awt.BorderLayout());

jPanel4.setLayout(new java.awt.GridLayout(2, 1));

jLabel2.setText("Key");

btsearch.setText("Search");
btsearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btsearchActionPerformed(evt);
}
});

javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
jPanel8.setLayout(jPanel8Layout);
jPanel8Layout.setHorizontalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtkey, javax.swing.GroupLayout.PREFERRED_SIZE, 482, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btsearch)
.addContainerGap(130, Short.MAX_VALUE))
);
jPanel8Layout.setVerticalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(14, 14, 14)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(txtkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btsearch))
.addContainerGap(13, Short.MAX_VALUE))
);

jPanel4.add(jPanel8);

buttonGroup1.add(rdbyname);
rdbyname.setSelected(true);
rdbyname.setText("By name");

buttonGroup1.add(rdbydirector);
rdbydirector.setText("By director");

buttonGroup1.add(rdbygenre);
rdbygenre.setText("By genre");

buttonGroup1.add(rdbyyear);
rdbyyear.setText("By year");

javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
jPanel9.setLayout(jPanel9Layout);
jPanel9Layout.setHorizontalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addComponent(rdbyname)
.addGap(36, 36, 36)
.addComponent(rdbydirector)
.addGap(37, 37, 37)
.addComponent(rdbygenre)
.addGap(33, 33, 33)
.addComponent(rdbyyear)
.addContainerGap(352, Short.MAX_VALUE))
);
jPanel9Layout.setVerticalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(rdbyname)
.addComponent(rdbydirector)
.addComponent(rdbygenre)
.addComponent(rdbyyear))
.addContainerGap(20, Short.MAX_VALUE))
);

jPanel4.add(jPanel9);

jPanel3.add(jPanel4, java.awt.BorderLayout.PAGE_START);

jPanel5.setLayout(new java.awt.BorderLayout());

jPanel6.setLayout(new java.awt.BorderLayout());

lstMessages.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
jScrollPane1.setViewportView(lstMessages);

jPanel6.add(jScrollPane1, java.awt.BorderLayout.CENTER);

jPanel5.add(jPanel6, java.awt.BorderLayout.PAGE_END);

jPanel7.setLayout(new java.awt.BorderLayout());

tabmovies.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {

},
new String [] {
"Name", "Director", "Genre", "Release Year"
}
));
jScrollPane2.setViewportView(tabmovies);

jPanel7.add(jScrollPane2, java.awt.BorderLayout.CENTER);

jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER);

jPanel3.add(jPanel5, java.awt.BorderLayout.CENTER);

getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);

pack();
}// </editor-fold>//GEN-END:initComponents

private void btcloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btcloseActionPerformed
System.exit(0);
}//GEN-LAST:event_btcloseActionPerformed

private void btsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btsearchActionPerformed
searchMovies();
}//GEN-LAST:event_btsearchActionPerformed

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btclose;
private javax.swing.JButton btsearch;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JPanel jPanel9;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JList lstMessages;
private javax.swing.JRadioButton rdbydirector;
private javax.swing.JRadioButton rdbygenre;
private javax.swing.JRadioButton rdbyname;
private javax.swing.JRadioButton rdbyyear;
private javax.swing.JTable tabmovies;
private javax.swing.JTextField txtkey;
// End of variables declaration//GEN-END:variables

private void searchMovies() {

if(txtkey.getText().trim().length()==0){
JOptionPane.showMessageDialog(null, "Please enter some words...");
return;
}

for(String ip : mappedips){
modelmsg.addElement("Looking up node : " + ip);

DataSourceMovies movies = null;
try {
ctx = new InitialContext();
movies = (DataSourceMovies)ctx.lookup("rmi://" + ip + "/movieserver");

} catch (Exception e) {
modelmsg.addElement("Error contacting node...");
e.printStackTrace();
break;
}

List<String[]> movieslist = null;

try{

if(rdbyname.isSelected())
movieslist = movies.findMoviesByName(txtkey.getText().trim());
else if(rdbydirector.isSelected())
movieslist = movies.findMoviesByDirector(txtkey.getText().trim());
else if(rdbygenre.isSelected())
movieslist = movies.findMoviesByGenre(txtkey.getText().trim());
else if(rdbyyear.isSelected()){
try {
movieslist = movies.findMoviesByYear(Integer.parseInt(txtkey.getText().trim()));
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Invalid year...");
return;
}
}

if(movieslist!=null && movieslist.size()>0){
modelmsg.addElement("Songs found...");

DefaultTableModel model = (DefaultTableModel) tabmovies.getModel();

while(model.getRowCount()>0){
model.removeRow(0);
tabmovies.revalidate();
}

for(String[] moviedata : movieslist)
model.addRow(moviedata);
}
}
catch(Exception ex) {               
modelmsg.addElement("Error reading data...");
break;
}
}

}
}



/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.agent.client.movies;

import com.agent.client.Utility;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.net.Socket;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JWindow;
import javax.swing.SwingConstants;

/**
*
*
*/
public class MovieSplashScreen {

private javax.swing.JLabel lbimage;
private javax.swing.JLabel lbloading;
private javax.swing.JLabel lbmobile;
private javax.swing.JPanel panelBack;

public static void main(String[] ar) {
new MovieSplashScreen().displaySplash(ar[0]);
}

public void displaySplash(String mapperip) {
JWindow window = new JWindow();
window.getContentPane().add(
new JLabel("Loading JFrame...", SwingConstants.CENTER));
window.setSize(525, 240);
Utility.setInCenter(window);

panelBack = new javax.swing.JPanel();
lbimage = new javax.swing.JLabel();
lbloading = new javax.swing.JLabel();
lbmobile = new javax.swing.JLabel();

panelBack.setBackground(new java.awt.Color(255, 255, 255));
panelBack.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 102), 2));
panelBack.setLayout(null);

lbimage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/agent/client/splash.jpg"))); // NOI18N
panelBack.add(lbimage);
lbimage.setBounds(250, 20, 250, 180);

lbloading.setFont(new java.awt.Font("Showcard Gothic", 0, 30)); // NOI18N
lbloading.setText("Loading...");
panelBack.add(lbloading);
lbloading.setBounds(50, 120, 210, 70);

lbmobile.setFont(new java.awt.Font("Tekton Pro Cond", 0, 24)); // NOI18N
lbmobile.setForeground(new java.awt.Color(0, 51, 51));
lbmobile.setText("Mobile Agents 1.0");
panelBack.add(lbmobile);
lbmobile.setBounds(30, 20, 230, 40);

window.add(panelBack, java.awt.BorderLayout.CENTER);

window.setVisible(true);
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
}

Socket client = null;

try {
client = new Socket(mapperip,2222);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Mapping server down...");
System.exit(0);
}

DataInputStream din = null;
DataOutputStream dout = null;
String ips = null;

try {
din = new DataInputStream(client.getInputStream());
dout = new DataOutputStream(client.getOutputStream());

dout.writeUTF("movies");

ips = din.readUTF();

} catch (Exception e) {
JOptionPane.showMessageDialog(null, "Cannot retrieve mappings...");
e.printStackTrace();
System.exit(0);
}

window.setVisible(false);
MovieClient sclient = new MovieClient(ips);
sclient.setVisible(true);
window.dispose();
}
}



  • 1. Re: got error while compiling this source code?
    Kayaman Guru
    Currently Being Moderated
    An error you say?

    Well, you better fix it then.
    And you might want to fix the formatting in your code while you're at it (put it between
     tags).                                                                                                                                                                                                                                                                                                                    
  • 2. Re: got error while compiling this source code?
    1012996 Newbie
    Currently Being Moderated
    its giving error class interface or enum expected! ,i have checked there is no syntax problem !
  • 3. Re: got error while compiling this source code?
    810618 Newbie
    Currently Being Moderated
    Judging from the information you've provided, I'd say the problem was that you are missing a class, interface or enum.
  • 4. Re: got error while compiling this source code?
    Kayaman Guru
    Currently Being Moderated
    >
    First, use the
     tags to format the code. You can edit your post and add them. If you expect any help, do this first.
    
    
    its giving error class interface or enum expected! ,i have checked there is no syntax problem !
    Sure there is. The compiler is a lot more careful than you are.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
  • 5. Re: got error while compiling this source code?
    EJP Guru
    Currently Being Moderated
    You must be kidding. You post hundreds of lines of code, that depends on several other classes of your own; you state you are getting a compile error without providing the actual error or the line it is pointing to; you claim without proof that there is no syntax error. I don't know what kind of help you're expecting here but you won't be gettingit.
  • 6. Re: got error while compiling this source code?
    1012996 Newbie
    Currently Being Moderated
    i have already said that its giving error: class ,interface or enum expected for all three package
  • 7. Re: got error while compiling this source code?
    1012996 Newbie
    Currently Being Moderated
    i have checked program on that basis i am saying there is no error .if u got any then tell me dont make assumptions that it may be or not.
  • 8. Re: got error while compiling this source code?
    Kayaman Guru
    Currently Being Moderated
    1009993 wrote:
    i have checked program on that basis i am saying there is no error
    Well, it's the compiler who decides, so you're wrong.
    if u got any then tell me dont make assumptions that it may be or not.
    We're not assuming anything. The compiler says that there's an error, so there's an error.

    And you still haven't formatted the code, which makes it very unlikely that you'll get any help.

    You have 2 choices now:
    1. Continue whining and not doing anything.
    2. Format the code with
     tags so it becomes legible.
    
    The choice is yours, but if you go for number 1, you'll just be wasting your own time.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
  • 9. Re: got error while compiling this source code?
    gimbal2 Guru
    Currently Being Moderated
    Kayaman wrote:
    You have 2 choices now:
    1. Continue whining and not doing anything.
    2. Format the code with
     tags so it becomes legible.
    3. Actually listen to the compiler and go find and fix the mistake :s Either that or continue to believe that the tools are lying to you, which means you are better off going to use something else. It makes no sense to use tools you believe are broken.
  • 10. Re: got error while compiling this source code?
    1012996 Newbie
    Currently Being Moderated
    {code = java}package com.agent.client.movies;

    import java.rmi.Remote;
    import java.rmi.RemoteException;
    import java.util.ArrayList;

    public interface DataSourceMovies extends Remote{

    ArrayList<String[]> getAllMovies() throws RemoteException;
    ArrayList<String[]> findMoviesByYear( int year) throws RemoteException;
    ArrayList<String[]> findMoviesByDirector(String director) throws RemoteException;
    ArrayList<String[]> findMoviesByGenre(String genre) throws RemoteException;
    ArrayList<String[]> findMoviesByName(String name) throws RemoteException;
    }



    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    /*
    * MovieClient.java
    *
    * Created on Apr 24, 2012, 10:49:58 AM
    */

    package com.agent.client.movies;

    import com.agent.client.songs.SongsClient;
    import com.agent.client.Utility;
    import java.util.ArrayList;
    import java.util.List;
    import java.util.StringTokenizer;
    import javax.naming.InitialContext;
    import javax.swing.DefaultListModel;
    import javax.swing.JOptionPane;
    import javax.swing.table.DefaultTableModel;

    /**
    *
    *
    */
    public class MovieClient extends javax.swing.JFrame {

    ArrayList<String> mappedips = new ArrayList<String>();
    DefaultListModel<String> modelmsg = new DefaultListModel<String>();
    InitialContext ctx;


    /** Creates new form MovieClient */
    public MovieClient(String ips) {
    setLookAndFeel();
    initComponents();
    Utility.setInCenter(this);


    StringTokenizer stok = new StringTokenizer(ips, ":");
    while(stok.hasMoreTokens())
    mappedips.add(stok.nextToken());
    }


    public void setLookAndFeel(){
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
    * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
    */
    try {
    for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
    if ("Nimbus".equals(info.getName())) {
    javax.swing.UIManager.setLookAndFeel(info.getClassName());
    break;
    }
    }
    } catch (ClassNotFoundException ex) {
    java.util.logging.Logger.getLogger(SongsClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
    java.util.logging.Logger.getLogger(SongsClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
    java.util.logging.Logger.getLogger(SongsClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
    java.util.logging.Logger.getLogger(SongsClient.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>
    }

    /** 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();
    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel2 = new javax.swing.JPanel();
    btclose = new javax.swing.JButton();
    jPanel3 = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    jLabel2 = new javax.swing.JLabel();
    txtkey = new javax.swing.JTextField();
    btsearch = new javax.swing.JButton();
    jPanel9 = new javax.swing.JPanel();
    rdbyname = new javax.swing.JRadioButton();
    rdbydirector = new javax.swing.JRadioButton();
    rdbygenre = new javax.swing.JRadioButton();
    rdbyyear = new javax.swing.JRadioButton();
    jPanel5 = new javax.swing.JPanel();
    jPanel6 = new javax.swing.JPanel();
    jScrollPane1 = new javax.swing.JScrollPane();
    lstMessages = new javax.swing.JList(modelmsg);
    jPanel7 = new javax.swing.JPanel();
    jScrollPane2 = new javax.swing.JScrollPane();
    tabmovies = new javax.swing.JTable();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setMinimumSize(new java.awt.Dimension(500, 500));

    jLabel1.setFont(new java.awt.Font("Simplified Arabic", 1, 24));
    jLabel1.setForeground(new java.awt.Color(0, 102, 204));
    jLabel1.setText("Mobile Agent: Find Movie Information");
    jPanel1.add(jLabel1);

    getContentPane().add(jPanel1, java.awt.BorderLayout.PAGE_START);

    btclose.setText("Close");
    btclose.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    btcloseActionPerformed(evt);
    }
    });
    jPanel2.add(btclose);

    getContentPane().add(jPanel2, java.awt.BorderLayout.PAGE_END);

    jPanel3.setLayout(new java.awt.BorderLayout());

    jPanel4.setLayout(new java.awt.GridLayout(2, 1));

    jLabel2.setText("Key");

    btsearch.setText("Search");
    btsearch.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(java.awt.event.ActionEvent evt) {
    btsearchActionPerformed(evt);
    }
    });

    javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
    jPanel8.setLayout(jPanel8Layout);
    jPanel8Layout.setHorizontalGroup(
    jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel8Layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(txtkey, javax.swing.GroupLayout.PREFERRED_SIZE, 482, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
    .addComponent(btsearch)
    .addContainerGap(130, Short.MAX_VALUE))
    );
    jPanel8Layout.setVerticalGroup(
    jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel8Layout.createSequentialGroup()
    .addGap(14, 14, 14)
    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(jLabel2)
    .addComponent(txtkey, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
    .addComponent(btsearch))
    .addContainerGap(13, Short.MAX_VALUE))
    );

    jPanel4.add(jPanel8);

    buttonGroup1.add(rdbyname);
    rdbyname.setSelected(true);
    rdbyname.setText("By name");

    buttonGroup1.add(rdbydirector);
    rdbydirector.setText("By director");

    buttonGroup1.add(rdbygenre);
    rdbygenre.setText("By genre");

    buttonGroup1.add(rdbyyear);
    rdbyyear.setText("By year");

    javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
    jPanel9.setLayout(jPanel9Layout);
    jPanel9Layout.setHorizontalGroup(
    jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel9Layout.createSequentialGroup()
    .addContainerGap()
    .addComponent(rdbyname)
    .addGap(36, 36, 36)
    .addComponent(rdbydirector)
    .addGap(37, 37, 37)
    .addComponent(rdbygenre)
    .addGap(33, 33, 33)
    .addComponent(rdbyyear)
    .addContainerGap(352, Short.MAX_VALUE))
    );
    jPanel9Layout.setVerticalGroup(
    jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(jPanel9Layout.createSequentialGroup()
    .addContainerGap()
    .addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
    .addComponent(rdbyname)
    .addComponent(rdbydirector)
    .addComponent(rdbygenre)
    .addComponent(rdbyyear))
    .addContainerGap(20, Short.MAX_VALUE))
    );

    jPanel4.add(jPanel9);

    jPanel3.add(jPanel4, java.awt.BorderLayout.PAGE_START);

    jPanel5.setLayout(new java.awt.BorderLayout());

    jPanel6.setLayout(new java.awt.BorderLayout());

    lstMessages.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));
    jScrollPane1.setViewportView(lstMessages);

    jPanel6.add(jScrollPane1, java.awt.BorderLayout.CENTER);

    jPanel5.add(jPanel6, java.awt.BorderLayout.PAGE_END);

    jPanel7.setLayout(new java.awt.BorderLayout());

    tabmovies.setModel(new javax.swing.table.DefaultTableModel(
    new Object [][] {

    },
    new String [] {
    "Name", "Director", "Genre", "Release Year"
    }
    ));
    jScrollPane2.setViewportView(tabmovies);

    jPanel7.add(jScrollPane2, java.awt.BorderLayout.CENTER);

    jPanel5.add(jPanel7, java.awt.BorderLayout.CENTER);

    jPanel3.add(jPanel5, java.awt.BorderLayout.CENTER);

    getContentPane().add(jPanel3, java.awt.BorderLayout.CENTER);

    pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btcloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btcloseActionPerformed
    System.exit(0);
    }//GEN-LAST:event_btcloseActionPerformed

    private void btsearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btsearchActionPerformed
    searchMovies();
    }//GEN-LAST:event_btsearchActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btclose;
    private javax.swing.JButton btsearch;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JList lstMessages;
    private javax.swing.JRadioButton rdbydirector;
    private javax.swing.JRadioButton rdbygenre;
    private javax.swing.JRadioButton rdbyname;
    private javax.swing.JRadioButton rdbyyear;
    private javax.swing.JTable tabmovies;
    private javax.swing.JTextField txtkey;
    // End of variables declaration//GEN-END:variables

    private void searchMovies() {


    if(txtkey.getText().trim().length()==0){
    JOptionPane.showMessageDialog(null, "Please enter some words...");
    return;
    }


    for(String ip : mappedips){
    modelmsg.addElement("Looking up node : " + ip);


    DataSourceMovies movies = null;
    try {
    ctx = new InitialContext();
    movies = (DataSourceMovies)ctx.lookup("rmi://" + ip + "/movieserver");


    } catch (Exception e) {
    modelmsg.addElement("Error contacting node...");
    e.printStackTrace();
    break;
    }


    List<String[]> movieslist = null;


    try{


    if(rdbyname.isSelected())
    movieslist = movies.findMoviesByName(txtkey.getText().trim());
    else if(rdbydirector.isSelected())
    movieslist = movies.findMoviesByDirector(txtkey.getText().trim());
    else if(rdbygenre.isSelected())
    movieslist = movies.findMoviesByGenre(txtkey.getText().trim());
    else if(rdbyyear.isSelected()){
    try {
    movieslist = movies.findMoviesByYear(Integer.parseInt(txtkey.getText().trim()));
    } catch (Exception e) {
    JOptionPane.showMessageDialog(null, "Invalid year...");
    return;
    }
    }


    if(movieslist!=null && movieslist.size()>0){
    modelmsg.addElement("Songs found...");


    DefaultTableModel model = (DefaultTableModel) tabmovies.getModel();

    while(model.getRowCount()>0){
    model.removeRow(0);
    tabmovies.revalidate();
    }


    for(String[] moviedata : movieslist)
    model.addRow(moviedata);
    }
    }
    catch(Exception ex) {
    modelmsg.addElement("Error reading data...");
    break;
    }
    }

    }
    }



    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */
    package com.agent.client.movies;

    import com.agent.client.Utility;
    import java.io.DataInputStream;
    import java.io.DataOutputStream;
    import java.net.Socket;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JWindow;
    import javax.swing.SwingConstants;

    /**
    *
    *
    */
    public class MovieSplashScreen {

    private javax.swing.JLabel lbimage;
    private javax.swing.JLabel lbloading;
    private javax.swing.JLabel lbmobile;
    private javax.swing.JPanel panelBack;

    public static void main(String[] ar) {
    new MovieSplashScreen().displaySplash(ar[0]);
    }

    public void displaySplash(String mapperip) {
    JWindow window = new JWindow();
    window.getContentPane().add(
    new JLabel("Loading JFrame...", SwingConstants.CENTER));
    window.setSize(525, 240);
    Utility.setInCenter(window);

    panelBack = new javax.swing.JPanel();
    lbimage = new javax.swing.JLabel();
    lbloading = new javax.swing.JLabel();
    lbmobile = new javax.swing.JLabel();

    panelBack.setBackground(new java.awt.Color(255, 255, 255));
    panelBack.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 102, 102), 2));
    panelBack.setLayout(null);

    lbimage.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/agent/client/splash.jpg"))); // NOI18N
    panelBack.add(lbimage);
    lbimage.setBounds(250, 20, 250, 180);

    lbloading.setFont(new java.awt.Font("Showcard Gothic", 0, 30)); // NOI18N
    lbloading.setText("Loading...");
    panelBack.add(lbloading);
    lbloading.setBounds(50, 120, 210, 70);

    lbmobile.setFont(new java.awt.Font("Tekton Pro Cond", 0, 24)); // NOI18N
    lbmobile.setForeground(new java.awt.Color(0, 51, 51));
    lbmobile.setText("Mobile Agents 1.0");
    panelBack.add(lbmobile);
    lbmobile.setBounds(30, 20, 230, 40);

    window.add(panelBack, java.awt.BorderLayout.CENTER);

    window.setVisible(true);
    try {
    Thread.sleep(5000);
    } catch (InterruptedException e) {
    }

    Socket client = null;


    try {
    client = new Socket(mapperip,2222);
    } catch (Exception e) {
    JOptionPane.showMessageDialog(null, "Mapping server down...");
    System.exit(0);
    }


    DataInputStream din = null;
    DataOutputStream dout = null;
    String ips = null;


    try {
    din = new DataInputStream(client.getInputStream());
    dout = new DataOutputStream(client.getOutputStream());


    dout.writeUTF("movies");


    ips = din.readUTF();


    } catch (Exception e) {
    JOptionPane.showMessageDialog(null, "Cannot retrieve mappings...");
    e.printStackTrace();
    System.exit(0);
    }


    window.setVisible(false);
    MovieClient sclient = new MovieClient(ips);
    sclient.setVisible(true);
    window.dispose();
    }
    }




  • 11. Re: got error while compiling this source code?
    Kayaman Guru
    Currently Being Moderated
    No. The tag is just
    . One in the top and one in the bottom.
    And just edit the original message instead of reposting it again.                                                                                                                                                                                                                                                                        
  • 12. Re: got error while compiling this source code?
    gimbal2 Guru
    Currently Being Moderated
    Example:

    \
    public static void main(String[] args){
    
    }
    \
    Result:
    public static void main(String[] args){
    
    }
  • 13. Re: got error while compiling this source code?
    EJP Guru
    Currently Being Moderated
    harshihony wrote:
    i have already said that its giving error: class ,interface or enum expected for all three package. i have checked program on that basis i am saying there is no error .if u got any then tell me dont make assumptions that it may be or not.
    I know what you said. The point is that the code you posted is incomplete, so nobody else can check it. I took the trouble myself of compiling this code and guessing what the several missing classes and interfaces might be. Have you considered the possibility that it might be one of those that has the error? Have you posted the entire error here? As I suggested? No, you just reposted the same stuff, as far as I can tell, or at least as far as I can be bothered with telling, which is approximately zero at this stage.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points