Tree Structure Of Folders
Mar 21, 2014
I have been trying to make a good tree structure for my Electrical Distribution network.. How to create two "subfolder" of my Voltage level folder.
Here is the code
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
[Code] ....
View Replies
ADVERTISEMENT
Jun 17, 2014
How to do draw the original binary tree based on traversal results?
A binary tree has this pre-order traversal result: A,B,D,H,I,E,F,C,G,K,J (TreeNodes) And the same tree gives the following in-order traversal: B,H,I,D,A,C,F,E,K,G,J. Can you draw the tree structure?
View Replies
View Related
Apr 9, 2014
I am new to jsf i have been given a task to create a tree structure in jsf but cant use richfaces and primefaces. I need a complete project for reference as i am to totally new to this.
View Replies
View Related
Jun 26, 2015
I have an excel file with data listed as the following, i m trying to parse down using POI
A
B
C
D1
D2
F
G1
G2
G3
M
S1
R
T
U
L
X
Y
Z
is it possible to generate an output like the following
A
A-->B
A-->B-->C
A-->B-->C-->D1
A-->B-->C-->D2
A-->B-->F
A-->B-->F-->G1
A-->B-->F-->G2
A-->B-->F-->G3
A-->B-->M
A-->B-->M-->S1
A-->R
A-->R-->T
A-->U
L
L-->X
L-->X-->Y
L-->X-->Y-->Z
I have been trying from quite some time but havent figured out the logic ...
View Replies
View Related
May 31, 2014
I never used tree, node etc. Consider an array of strings that come from html tags. This needs to be turned into a tree structure. Here, any Hn is the child of the most recent Hn-1
String[] Headers = {"H1", "H1", "H2", "H3", "H3", "H2", "H2", "H3",
"H4", "H2", "H2", "H2", "H1", "H2", "H2", "H3", "H4", "H4", "H2" };
Desired output -
ROOT
H1
H1
...H2
......H3
......H3
...H2
...H2
......H3
.........H4
...H2
...H2
...H2
H1
...H2
...H2
......H3
.........H4
.........H4
...H2
ANSWER -
class Example {
static class Node {
final String name;
final int indent;
Collection<Node> children = new LinkedList<> ();
[Code] .....
View Replies
View Related
Feb 8, 2014
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
public class tree_lock_test{
int total_instances;
int thread_instances = 0;
int N;
[Code] .....
this is compiled with another Peterson class which has implemeted peterson lock for two threads ...
View Replies
View Related
Apr 22, 2014
I am creating a web application that runs on server X(unix) and it has another unix system mounted on it. I want to generate the file tree structure of this mounted unix file system and show it on to a web application so that users can select a file and move it onto this current unix machine.
I know this sounds stupid and you may want to say why cant we directly copy the file, I am doing a proof of concept and using this as a basis.
View Replies
View Related
Apr 14, 2015
I need to read folder structure from the excle file and need to read all the files which are available inside folder structure.folder structure like below
c:Migrate
C:MigrateMigrateFiles
...
...
..etc.
I am ble to read files which is avalibale in all the folders with single thread,i want to read those files with multiple threads,each thread shoud reads the files from different folder. here how to read.
View Replies
View Related
Jul 17, 2014
Batch file (. BAT) problems with some folders on. I created an application in Java and put the JRE folder within the application, because some users do not have Java installed on your machine and the way I did, my application runs. JAR with the JRE that is contained in my application but I created a BAT file that contains the following command:
start "" jre8 bin javaw-jar app.jar
So I run my program in java through the file. BAT calling JRE that is inside the folder and then this JRE runs the mine. JAR and works great anywhere in windows, worked well on a USB key with this command is within. BAT (start "" jre8 bin javaw-jar app.jar).
BAT in certain folders, eg Program Files and Program Files (x86), I need this code to be able to find any directory, regardless of whether the directory has spaces in the name, symbols, numbers or anything else, because maybe people will put the application folder to another location or rename the folder, and if this happens the program will stop working? And especially do not give problems to run inside the Program Files and Program Files (x86) because the application runs everywhere except in these two folders.
View Replies
View Related
May 30, 2014
I developed an application that is accessing some property files. The condition was that the user should be able to modify the content or parameters of those property file.How can I distribute the application using Java web start that also includes those property file in the client side?
View Replies
View Related
Jun 30, 2014
I have a code that uploads files in server after browsing folders and files then get the paths of files but I have a problem in getting the paths
List items = upload.parseRequest(request);
Iterator iterator = items.iterator();
while (iterator.hasNext()) {
FileItem item = (FileItem) iterator.next();
if (!item.isFormField())
{ fileName = item.getName();
root = getServletContext().getRealPath("/");
path = new File(root + "/uploads");
[Code]...
list1 must has paths that I want but I do not get the paths of upload files
View Replies
View Related
Feb 6, 2015
Implement a Las Vegas slot machine! The machine works as follows. First, it generates three random integers (use import java.lang.Math.*; then call Math.random()*7 to generate a random number between [a,b)) that are in the range of 0-7. Once the numbers are generated, the following rules are used to determine the prize:
- If all three numbers are equal to 7, you are winning $1,000,
- If all three numbers are equal, but not equal to 7, you are winning $500,
- If two of the numbers are equal to 7 and the third one is six, you are winning $400,
- If two numbers are equal, you are winning $100,
- Otherwise you are not winning anything.
And for that I wrote:
import java.lang.Math;
public class Assn1_2150130 {
public static void main(String[] args) {
// Generate three random signle-digit integar from 0-7.
int n1 = (int)(Math.random()*7);
int n2 = (int)(Math.random()*7);
int n3 = (int)(Math.random()*7);
[code]...
But I just can't figure out a way to print out the "YOU WON NOTHING." independently.If I say that n1!=n2 && n2!=n3 && n3!=n1, and then write another line of println. It gives out the number as well as the "NOTHING".
View Replies
View Related
May 27, 2014
I want to define this data structure , I show you an example
"first street",{{1,40},{43,45},{34,26}},
"second street",{{14,41},{42,5},{3,46}},
............
I wrote in this way but it doesnt work :
Map<String,ArrayList<int[]>> Street=new HashMap<String, ArrayList<int[2]>>();
View Replies
View Related
Nov 3, 2014
I'm having trouble with this program:
//********************************************************************
// Demonstrates the existence of separate data space in multiple instantiations of a programmer-defined class.
//********************************************************************
[code]....
Basically i'm trying to add one more "coin" to flip. My problem is that my if-else structure isn't working correctly here's what it looks like:
if (count1 < GOAL)
if (count2 < GOAL)
System.out.println("Coin 3 Wins!");
[Code] .....
It only works correctly when "coin2" wins.How would I modify my if else structure to get the output I am looking for?
View Replies
View Related
Feb 16, 2015
Is it possible to map URL's with independent view dir structure? If so how?
My goal is to simply point an url to a specific view file:
i.e.
[URL] ....
to
not/default/path/views/main/index.xhtml
and
www.myserver.com/application/admin/
to
not/default/path/views/admin/index.xhtml
A couple solutions I found so far where:
Solution 1
PrettyFaces
I just didn't wanted to use a third party solution. This is my best solution so far.
Solution 2(a JSF solution):
navigation rule entries in the faces-config.xml file.
A bean is required, not a bad thing in above example but not great in combination with static navigation like:<h:commandButton action="index"/>
Solution 3 (another JSF solution)
Resource Library Contracts
This forces me to work in the contracts file.
None of the solutions gave me a clear solution except prettyfaces.
Are there some elegant native JSF solutions ? Something flexible and reusable? Something like a mvc controller i used to use in php applications. In this controller I was able to add a template file in the constructor and an content file in specific function. Custom paths where no problem. I didn't want to use mvc nor the php language in this project.
View Replies
View Related
Feb 27, 2014
I'm trying to fill a List<String>, named overlappedGrid, from another List<String>, named listGrid. I'm facing an exception:Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - unexpected type
required: variable
found: value
at arab2004_d.ProcessingLayer.printShape(Arab2004_D.j ava:101)
at arab2004_d.Arab2004_D.main(Arab2004_D.java:30)
Java Result: 1
Here is my source code (the exception line is commented "here is the exception"):
package arab2004_d;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.LinkedList;
[code]....
I tried to copy listGrid in another List<String> but the exception remain the same.
View Replies
View Related
May 26, 2014
I have noticed that you can style JavaFX controls using their sub-structure.
E.g. to style the label in a table column header to be left justified I can do this :
.table-view .column-header-background .label { -fx-alignment: center-left ; }
How can I style my own nodes/controls doing this? Basically it amounts to asking how the selectors like ".column-header-background" are associated with sub-structures of my Java control/node objects. So suppose I have something like
.fancy-node .fred .label { ... }
How does JavaFX associate fancy-node and fred with something in my implementation of a Node/Control?
View Replies
View Related
May 8, 2015
how to structure simple programs (i.e. one-method algorithms for a simple purpose). There are a few different ways that I have been doing it, but I want to be consistent. Should I put both the one-method algorithm (e.g. a factorial function) and the main method that executes the algorithm into the same class and then export it to an executable .jar file for use? Or should I create one class for the algorithm and another for the main method that executes the algorithm? In addition, is there any reason that I should out these classes in a package before I export it?
As another similar question, if I have constructed two distinct classes with two separate purposes, and they are both used in the construction of a single program, then would it be best to just put the main method in a third, separate class or should I put it in one of the two classes?
View Replies
View Related
Sep 27, 2014
Problem in inserting,removing and searching in trie data structure.
View Replies
View Related
May 4, 2015
I am trying to Implement a method matchBracket(String exp), which should take a String expression consisting of only symbols (,[,{,<,),],},> , and checks if the brackets in the expression are matching using stack data structure.
I know how the methods of stack class like push,pop,peek are for however how to do the checking for opening and closing brackets iteratively ?
public static void matchBracket(String str){
// creating a stack of character at first
Stack <Character> stack = new Stack<Character>() ;
// starting loop to scan the expression below inside main method
for(int i = 0; i<str.length(); i++){
[Code] ....
/**Expected Output:
*The parentheses are not matching
*The parentheses are matching
View Replies
View Related
May 21, 2014
My assignment is to design a simple GUI calculator using the stack data structure to perform additions, subtractions, multiplications and divisions. But i having error while i press the action there.
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.util.Stack;
public class JCalculator implements ActionListener {
[Code] ...
View Replies
View Related
Mar 12, 2014
I have a program I am working on, and have been using the following code:
Java Code:
private void checkQInstall(){
try {
qs = new File("C:MEMORYGAMEq.bin");
in = new BufferedReader(new FileReader(qs));
} catch (FileNotFoundException e) {
System.out.println("CALLED");
[Code] .....
Now my main issue is I am working on a project that could be used on a variety of systems. I understand that Java is designed for flexibility among OS's and that the way I have coded is designed for a Windows system (afaik). How to retain an installation directory so that on subsequent openings, the program knows where to open the file, without it being platform dependent.
View Replies
View Related
Jan 26, 2014
I am having problem with some problems like this nested for-loop for instance ....
-----1-----
----333----
---55555---
--7777777--
-999999999-
Now I have to write a method called printDesign that produces the following output but i am not even entirely sure how to start it out now of course i know how to make a for-loop but and i guess if i was to do something for this i would do this .....
Java Code:
for(int*j=0;j<N-k;j++){
System.out.print("-");*
for(int*j=0;j<i;j++){
System.out.print(i);*
for(int*j=0;j<N-k;j++){
System.out.print("-");*
System.out.println();*
}
}
} mh_sh_highlight_all('java');
View Replies
View Related
Aug 28, 2014
I have a tree-based data structure that looks somewhat like this:image1.png..Every tree always has a height of no more then 3, and each of these classes has a very specific use, generalization is not possible between them.Now, I want to display my data structure with a JTree in a Swing application. A JTree needs a TreeModel and so I created a custom TreeModel for my classes, it looks like this:
public class CustomTreeModel implements TreeModel {
private Root root;
public Object getRoot() {
return root;
[code]....
But then I would introduce this interface to my Model classes just for the purpose of writing the View. So my data model has to be altered to make the View work, this sounds completely against MVC to me and also like something I dont really like.On the other hand, the CustomTreeModel would be much simpler, easier to understand, easier to maintain and just in general more pleasing to the eye.Should I change my Model to improve the View? Is instanceof okay to be used in View classes?
View Replies
View Related
Mar 31, 2014
I have a design scenario here which is quite interesting and complex. I have a Java class structure as follows,
class A
{
class B;
innerClass B
{
List<class C> listofC;
innerClass C
{
String attribute1;
String attribute2; // Their getter setters
}
}
}
So I have this as an API. Now my challenge is that I need to add one more property to inner class C. i.e attribute3 in innerClass C. I need to do this without disturbing the code in class A by extending these classes or writing a new wrapper, so I can use class C with new properties .
I hope this should be achievable through any design pattern either at runtime or design time.
View Replies
View Related
Jul 27, 2014
I'm trying to build a program that contains the ability to:
(1) insert new node at head,
(2) print out contents of the list in order,
(3) remove first node from head,
(4) remove last node from tail,
(5) find a target value,
(6) give total number of occurrences of a target value, and
(7) give total number of items in list.
The areas I'm struggling with implementing are: (
- remove from tail - I know how to find the final node but I can't quite figure out how to set it to null since its initial type is an integer.
- find a target value - how to make the parameters quite workout so the user can simply input an integer value.
- The solution is probably really simple but I can't figure out how to print out the results of these methods when I call them.
public class Node
{
private int data;
private Node link;
// Node Constructor 1
public Node()
{
data = 0;
link = null;
[code]....
View Replies
View Related