Results 1 to 9 of 9
  1. #1
    deemu is offline Member
    Join Date
    Feb 2012
    Posts
    15
    Rep Power
    0

    Default Help in java tree

    I am new to java...
    i am working in server and client... Its like 1 server send message to many client.
    in this i want to make as tree message.the programm is in eclipse and answer must be in APPlet.
    i have some coding and with this coding , i want to make it as in tree form......
    Java Code:
     while ((allLine = in.readLine()) != null) {
    			allLine = allLine.trim();
    			
    			if(allLine.indexOf("=Lang=")!=-1&&allLine.indexOf("Set=0")==-1){
    				JLabel j=new JLabel(allLine.substring(0,allLine.indexOf("=")));
    				jp.add(j); 
    				if(allLine.indexOf("Set=1")!=-1){
    					JCheckBox cb=new JCheckBox();
    					jp.add(cb);
    					cb.setSelected(true);
    					bestinformedclient.channBox.add(cb);
    				}
    				else{
    					JCheckBox cb=new JCheckBox();
    					jp.add(cb);
    					cb.setSelected(false);
    					bestinformedclient.channBox.add(cb);
    				}
    			}
    			
    			}
    		in.close();
    	
    		JScrollPane sp = new JScrollPane(jp);
    		sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    		sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    	
    		content.add(sp);
    	}
    
    }
    Last edited by Norm; 02-06-2012 at 01:07 PM. Reason: added code tags

  2. #2
    deemu is offline Member
    Join Date
    Feb 2012
    Posts
    15
    Rep Power
    0

    Default Help in java

    I am new to java...
    i am working in server and client... Its like 1 server send message to many client.
    in this i want to make as tree message.the programm is in eclipse and answer must be in APPlet.
    i have some coding and with this coding , i want to make it as in tree form......

    while ((allLine = in.readLine()) != null) {
    allLine = allLine.trim();

    if(allLine.indexOf("=Lang=")!=-1&&allLine.indexOf("Set=0")==-1){
    JLabel j=new JLabel(allLine.substring(0,allLine.indexOf("=")));
    jp.add(j);
    if(allLine.indexOf("Set=1")!=-1){
    JCheckBox cb=new JCheckBox();
    jp.add(cb);
    cb.setSelected(true);
    bestinformedclient.channBox.add(cb);
    }
    else{
    JCheckBox cb=new JCheckBox();
    jp.add(cb);
    cb.setSelected(false);
    bestinformedclient.channBox.add(cb);
    }
    }

    }
    in.close();

    JScrollPane sp = new JScrollPane(jp);
    sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZO NTAL_SCROLLBAR_ALWAYS);
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL _SCROLLBAR_ALWAYS);

    content.add(sp);
    }

    }
    Last edited by Norm; 02-06-2012 at 01:11 PM. Reason: Merged with 2nd copy

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,271
    Rep Power
    25

    Default Re: Help in java tree

    Can you explain what you are trying to do?
    i want to make as tree message
    What is a "tree message"?
    answer must be in APPlet.
    What does this mean?

    What does the posted code have to do with your problem?

  4. #4
    deemu is offline Member
    Join Date
    Feb 2012
    Posts
    15
    Rep Power
    0

    Default Re: Help in java tree

    This is like in Web page . When ever you add some thing For eg : createing channel english . Then it will be connected to client.

    When ever we are running eclipse , the client will show (channel english ) to the java client.

    the client and java client are in Applet.

    ya... answer is in Applet...

    the answer must be in tree form...
    so i need to write in coding for tree . Which line i must write the javatree code. what is the java tree code ?

  5. #5
    deemu is offline Member
    Join Date
    Feb 2012
    Posts
    15
    Rep Power
    0

    Default Re: Help in java tree

    Java Code:
    import java.awt.Container;
    import java.awt.GridLayout;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.net.URL;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    
    public class ChannW extends JFrame{
    	private static final long serialVersionUID = 1L;
    	
    	ChannW() throws Exception{
    		setSize(325,375);
    		setLocation(225,225);
    		setTitle(" Channels");
    		
    		Container content=getContentPane();
    		JPanel jp = new JPanel();
    		jp.setLayout(new GridLayout(0,2));
    		
    		URL url = this.getClass().getProtectionDomain().getCodeSource().getLocation();
            String decodepath=java.net.URLDecoder.decode(url.getPath(),"UTF-8");
            File file = new File(decodepath+"Infoclient.ini");
            BufferedReader in = new BufferedReader(new FileReader(file));
            String allLine="";
            
            bestinformedclient.channBox.removeAllElements();
            
            while ((allLine = in.readLine()) != null) {
    			allLine = allLine.trim();
    			
    			if(allLine.indexOf("=Lang=")!=-1&&allLine.indexOf("Set=0")==-1){
    				JLabel j=new JLabel(allLine.substring(0,allLine.indexOf("=")));
    				jp.add(j); 
    				if(allLine.indexOf("Set=1")!=-1){
    					JCheckBox cb=new JCheckBox();
    					jp.add(cb);
    					cb.setSelected(true);
    					bestinformedclient.channBox.add(cb);
    				}
    				else{
    					JCheckBox cb=new JCheckBox();
    					jp.add(cb);
    					cb.setSelected(false);
    					bestinformedclient.channBox.add(cb);
    				}
    			}
    			
    			}
    		in.close();
    	
    		JScrollPane sp = new JScrollPane(jp);
    		sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    		sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    	
    		content.add(sp);
    	}
    
    }
    Last edited by Norm; 02-06-2012 at 01:33 PM. Reason: added code tags

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,271
    Rep Power
    25

    Default Re: Help in java tree

    You mention many parts to this project: server, client, eclipse, applet, tree, web page,

    Can you explain what code in what part of the project you are working on?

    Where does the ChannW class fit in?

  7. #7
    deemu is offline Member
    Join Date
    Feb 2012
    Posts
    15
    Rep Power
    0

    Default Re: Help in java tree

    import java.awt.Container;
    import java.awt.GridLayout;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileReader;
    import java.net.URL;
    import javax.swing.JCheckBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;

    public class ChannW extends JFrame{
    private static final long serialVersionUID = 1L;

    ChannW() throws Exception{
    setSize(325,375);
    setLocation(225,225);
    setTitle(" Channels");

    Container content=getContentPane();
    JPanel jp = new JPanel();
    jp.setLayout(new GridLayout(0,2));

    URL url = this.getClass().getProtectionDomain().getCodeSourc e().getLocation();
    String decodepath=java.net.URLDecoder.decode(url.getPath( ),"UTF-8");
    File file = new File(decodepath+"Infoclient.ini");
    BufferedReader in = new BufferedReader(new FileReader(file));
    String allLine="";

    bestinformedclient.channBox.removeAllElements();

    while ((allLine = in.readLine()) != null) {
    allLine = allLine.trim();

    if(allLine.indexOf("=Lang=")!=-1&&allLine.indexOf("Set=0")==-1){
    JLabel j=new JLabel(allLine.substring(0,allLine.indexOf("=")));
    jp.add(j);
    if(allLine.indexOf("Set=1")!=-1){
    JCheckBox cb=new JCheckBox();
    jp.add(cb);
    cb.setSelected(true);
    bestinformedclient.channBox.add(cb);
    }
    else{
    JCheckBox cb=new JCheckBox();
    jp.add(cb);
    cb.setSelected(false);
    bestinformedclient.channBox.add(cb);
    }
    }

    }
    in.close();

    JScrollPane sp = new JScrollPane(jp);
    sp.setHorizontalScrollBarPolicy(JScrollPane.HORIZO NTAL_SCROLLBAR_ALWAYS);
    sp.setVerticalScrollBarPolicy(JScrollPane.VERTICAL _SCROLLBAR_ALWAYS);

    content.add(sp);
    }

    }

  8. #8
    deemu is offline Member
    Join Date
    Feb 2012
    Posts
    15
    Rep Power
    0

    Default Re: Help in java tree

    Ok leave that .... can u tell me how to create a code for java tree ?

  9. #9
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,188
    Rep Power
    19

    Default Re: Help in java tree

    Cross posted. Even duplicated the first response on both sites.
    New to java (Applets forum at JavaRanch)

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Binary Tree Help - Find the largest sub-tree
    By joshhazel in forum New To Java
    Replies: 2
    Last Post: 01-30-2012, 02:08 AM
  2. tree in java
    By sugir1987 in forum New To Java
    Replies: 2
    Last Post: 01-19-2012, 02:16 PM
  3. Replies: 0
    Last Post: 04-04-2010, 07:40 AM
  4. Creating a Tree and then saving the Tree
    By jackmatt2 in forum New To Java
    Replies: 0
    Last Post: 08-22-2009, 12:51 PM
  5. java tree
    By tony404 in forum Advanced Java
    Replies: 5
    Last Post: 06-23-2008, 06:43 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •