Results 1 to 9 of 9
Thread: Help in java tree
- 02-06-2012, 09:26 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 15
- Rep Power
- 0
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
- 02-06-2012, 11:47 AM #2
Member
- Join Date
- Feb 2012
- Posts
- 15
- Rep Power
- 0
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
- 02-06-2012, 01:06 PM #3
Re: Help in java tree
Can you explain what you are trying to do?
What is a "tree message"?i want to make as tree message
What does this mean?answer must be in APPlet.
What does the posted code have to do with your problem?
- 02-06-2012, 01:21 PM #4
Member
- Join Date
- Feb 2012
- Posts
- 15
- Rep Power
- 0
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 ?
- 02-06-2012, 01:23 PM #5
Member
- Join Date
- Feb 2012
- Posts
- 15
- Rep Power
- 0
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
- 02-06-2012, 01:32 PM #6
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?
- 02-06-2012, 01:34 PM #7
Member
- Join Date
- Feb 2012
- Posts
- 15
- Rep Power
- 0
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);
}
}
- 02-06-2012, 01:40 PM #8
Member
- Join Date
- Feb 2012
- Posts
- 15
- Rep Power
- 0
Re: Help in java tree
Ok leave that .... can u tell me how to create a code for java tree ?
- 02-06-2012, 01:45 PM #9
Re: Help in java tree
Cross posted. Even duplicated the first response on both sites.
New to java (Applets forum at JavaRanch)
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
Binary Tree Help - Find the largest sub-tree
By joshhazel in forum New To JavaReplies: 2Last Post: 01-30-2012, 02:08 AM -
tree in java
By sugir1987 in forum New To JavaReplies: 2Last Post: 01-19-2012, 02:16 PM -
Data Structures(Binary Search Tree to AVL Tree)ASAP pls
By jfAdik in forum Forum LobbyReplies: 0Last Post: 04-04-2010, 07:40 AM -
Creating a Tree and then saving the Tree
By jackmatt2 in forum New To JavaReplies: 0Last Post: 08-22-2009, 12:51 PM -
java tree
By tony404 in forum Advanced JavaReplies: 5Last Post: 06-23-2008, 06:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks