masijade 1,351 Industrious Poster Team Colleague Featured Poster

If the "WordSet" class implements a Collection/List/Map interface (or extends a Class that does so), then yes, it can be used, otherwise, no, it can't. Now, whether or not you can use it for this "WordSet" Class, I can't say, as I have no idea what the class looks like.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, it will, and I don't, myself, consider that a limitation (after all, you do want to see the entire content, don't you?). If you don't want them to take up more space, then place your JPanels into JScrollPanes and place the JScrollPanes into the GBL and let the "additional" content be "scrollable", although you wouls probably not like that either. ;-)

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, I have stated multiple times, that the components will take the minimum (or preferredSize amount of space) space needed to display itself. It might help if you actually showed some more of your code as this works just fine

import java.awt.Color;
import java.awt.Container;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;


public class GridBagTest extends JFrame {

	public static final long serialVersionUID = 0L;

	JPanel redPanel, bluePanel, greenPanel;

	GridBagConstraints gbc;
	Container container;

	public static void main (String args[]) {
		GridBagTest gbe = new GridBagTest();
		try { Thread.sleep(2000); } catch (InterruptedException ie) {}
		gbe.setVisible(false);
		gbe.dispose();
	}

	public GridBagTest() {
		setSize (400, 400);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		container = getContentPane();

		redPanel = new JPanel ();
		greenPanel = new JPanel ();
		bluePanel = new JPanel ();
		redPanel.setBackground(Color.RED);
		greenPanel.setBackground(Color.GREEN);
		bluePanel.setBackground(Color.BLUE);

		GridBagLayout gbl = new GridBagLayout();
		container.setLayout(gbl);
		gbc = new GridBagConstraints ();

		AddPanel (redPanel, 0, 1);
		AddPanel (greenPanel, 1, 8);
		AddPanel (bluePanel, 9, 1);

		gbl.columnWeights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };
		setVisible (true);
	}

	public void AddPanel (JPanel panel, int gridx, int gridwidth) {
		gbc.gridx = gridx;
		gbc.gridy = 0;
		gbc.gridwidth = gridwidth;
		gbc.gridheight = 1;
		gbc.weightx = 0.0;
		gbc.weighty = 1.0;
		gbc.fill = GridBagConstraints.BOTH;
		add(panel, gbc);
	}
}

And seems to do exactly what you're asking.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, have you tried the columnWeights suggestion? Does that "fit the bill" for you?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

And you have given three columns (0, 1, and 10, and where has column 9 gone, as that is your 10th column since the first column is 0, 10 is the eleventh column) a percentage of 100%, and the remaining became 0% (since you didn't assign one to them), so, obviously, all of the space will be (at best) evenly split between those three columns. So, even that you "know" that the weights are percentages, you seemingly don't know what that means (so I doubt that assertion to begin with). It has nothing to do with the gridwidth. If you want 10 columns all with a width of 0.1 and use gridwidth to "control" component size, then use the columnwieghts property of the layout itself.

gbl.columnWeights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };

(gbl is the GridBagLayout variable, I don't know what you used as you didn't show it.)

And set c1.wieghtx to 0.0. Also, you can reuse the same GridBagConstraints object. A copy of that object will be made when you use add (at least when using gbl.setConstraints(comp, const) and then add(comp), I'm not sure about add(comp, const) as I don't use that one). There is no reason to create a new GridBagConstraints object every time.

If a component "needs" more space than the "columnWeight" would normally provide, it will still take it, though.

There is no "forceGridSize" as that would make it GridLayout, so use that.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Google?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Every place where you write to the file, and the place where you open the file. I would also say to add a windowClosing method (which means using your own WindowListener) or a shutdown hook to close the file, but that is probably too much at the moment, and shouldn't be necessary, as it should automatically close, normally, when the program exits (but call flush after every write, to be sure).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, we are not here to do your work for you. The API docs and the tutorials work wonders.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? So, as a simple soultion, open a PrintStream to a file and set that to System.out. As a slightly better solution, open a FileWriter and set that as an instance variable and have the actionlisteners write to that rather than system. out, as a thid solution, but one which the instructor probably doesn't want to see, simply redirect standard out on the command line. There are much more elegant solutions, but any of these will work. At least try.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

This post is completely unrelated to the rest of the thread. Start your own thread and do not resurrect zombies to post unrelated material.

Salem commented: close++ +20
masijade 1,351 Industrious Poster Team Colleague Featured Poster

This is a completely new topic. Start a new thread and stop resurrecting dead ones. As a hint, Google "POI HSSF/XSSF" and/or "Andy Khan jxl".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Then use JApplet and simply do setMenuBar(menubar), JApplets own setMenuBar, not yours.

Edit: You don't want to mix AWT and Swing, anyway, and Applet is awt, JApplet is Swing, and since the rest is swing ....

masijade 1,351 Industrious Poster Team Colleague Featured Poster

add the JMenubar to the JApplet, not to "screens".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The weightx and weighty values are doubles, because they are percentages. A weight of 1 means 100%. If you want 10% it should be 0.1

Edit: Remember, though, that if the component needs more space than that in order to be completely displayed it will take that space, so don't, necessarily, expect that those percentages are "set in stone".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Don't ressurect old threads with useless posts.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It looks as though you have simply wrapped the entirety of your class definition with the main method declaration. Why?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

I said that sarcastically, and not because I didn't think it was part of the problem. Also, ls is not "colorised" for most people (or do you have some statistics to support this). I would like to see those "colorised" prompts on the standard Solaris installation, for instance. Also, even if this is the case, the problem is with an alias and a simple "\ls" will work just as well as /bin/ls. And, no, that semicolon does not terminate the for loop. I don't, however, see the "done"s closing the loops.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm "==", maybe?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your method is returning a single double, rather than a double array, and you index into an array, not a double.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Well, are you even attempting to read the formatting? Or are you just trying to read the text? See HWPFDocument and its getStyleSheet method. All of the formatting is contained in the style sheets. The text is just the, well, text.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

getResourceAsStream is not finding the file.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See the post above yours.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

When you open an ObjectInputStream it attempts to first read the "header" (which will automatically be created upon creating an ObjectOutputStream on the other end), which the API docs clearly state. And, since your groovy script is not creating an ObjectOutputStream for your java program to read your ObjectInputStream fails. Why are you even attempting to open any kind of InputStream on the Java side if your Groovy script is not sending anything? And your using a BufferedReader on the Groovy side will not work with an ObjectOutputStream from the Java side. It would only receive a lot of nonsensical garbage.

Edit: Okay, I see you are writing from the groovy side (although it is sometimes w and sometimes writer and neither, as far as I can see, is ever defined). But, it seems to be a Character stream. So again, why the Object Streams Java side and the character reader/writer on the groovy side. That is destined to fail.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay. Finished.

masijade 1,351 Industrious Poster Team Colleague Featured Poster
System.out.print("are you sure you want to delete this file ["my file+"]y=yes/n=no");

my file or myfile Take a closer look at that line. Also, what about the "connection" between the first quoted String and that variable? Isn't something missing there, as well? Once again, take a closer look at that line.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Your constructor takes two parameters and you are calling it with 0. And don't try bringing up th "default constructor" (if you know about that) as that is only created by compiler if the doesn't already have any constructors.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

JOptionPane?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Google a bit, this question has been asked almost as often as the "Is Java Pure OOP idiocy".

By the second one you'll have to scroll a bit.

http://www.daniweb.com/forums/thread100646.html
http://www.java-forums.org/advanced-java/9997-very-urgent-need-help-calculating-difference-between-two-dates.html

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Study this, and I really mean study this, as I hate doing this sort of thing, I don't think it usually helps, but I can see I will be talking for hours trying to nudge you in the right direction.

public class MatrixTest {
	private static int[][] matrix = {
			{ 1, 2, 3, 4, 5 },
			{ 2, 3, 4, 5, 6 },
			{ 3, 4, 5, 6, 7 },
			{ 4, 5, 6, 7, 8 },
			{ 5, 6, 7, 8, 9 }
		};

	private static int[][] pattern1 = {
			{ 2, 3 },
			{ 3, 4 }
		};

	private static int[][] pattern2 = {
			{ 4, 5, 6 },
			{ 5, 6, 7 }
		};

	private static int[][] pattern3 = {
			{ 2, 2 },
			{ 3, 3 }
		};

	private static int[] findStart(int[][] pattern) {
		int[] result = { -1, -1 };
		START:
		for (int i = 0; i <= matrix.length - pattern.length; i++) {
			for (int j = 0; j <= matrix[0].length - pattern[0].length; j++) {
				if (matrix[i][j] == pattern[0][0]) {
					if (confirmMatch(i, j, pattern)) {
						result[0] = i;
						result[1] = j;
						break START;
					}
				}
			}
		}
		return result;
	}

	private static boolean confirmMatch(int row, int col, int[][] pattern) {
		for (int k = 0; k < pattern.length; k++) {
			for (int l = 0; l < pattern[0].length; l++) {
				if (pattern[k][l] != matrix[row + k][col + l]) {
					return false;
				}
			}
		}
		return true;
	}

	public static void main(String[] args) {
		int[] vals = findStart(pattern1);
		if (vals[0] != -1) {
			System.out.println("Pattern 1 found at Row:  " + vals[0] + "  Col:  " + vals[1]);
		} else {
			System.out.println("Pattern 1 not found.");
		}

		vals = findStart(pattern2);
		if (vals[0] != -1) {
			System.out.println("Pattern 2 found at Row:  " + vals[0] + "  Col:  " + vals[1]);
		} else {
			System.out.println("Pattern 2 not found.");
		}

		vals = findStart(pattern3);
		if (vals[0] != -1) {
			System.out.println("Pattern 3 found at Row:  " + vals[0] + "  Col:  " + vals[1]);
		} else {
			System.out.println("Pattern 3 not found.");
		}
	}
}
masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? Show us your attempt at it, not just your assingment text, and we will help you correct it, but we are not going to do it for you. Regardless of what your personal feeling about it would be, that would not help you, it would hurt you.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

"outer" length and "inner" length are the lengths of the arrays in the 2D array. I.E. double[][] a = new double[5][6]; the "inner" length is 6 (i.e. the length of the "sub" arrays) and the "outer" length is 5 (i.e. the length of the encompassing array). Both the matrix and the pattern have "outer" and "inner" lengths.

Usually the "outer" will refer to the row and the "inner" to the column, but this is arbitrary, so long as any calculations to be done with the matrix are done with the proper "alignment", and the same "alignment" is used throughout the program.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Like I said. Make it the first line of the method. It does no good to check whether or not it is a directory after you have already called listFiles on it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

First of all, get the lengths of the "inner" and "outer" array of the pattern. Then, when looping through the matrix, there is no reason to go beyond matrix.outer.length - pattern.outer.length, or matrix.inner.length - pattern.inner.length as the pattern wouldn't fit in those spaces. Then loop until you find the first value from the pattern in the matrix. Then loop through the inner matrix comparing it's values to the "offset" values from the matrix. i.e.

pattern[outerIndex][innerIndex] == matrix[firstFoundIndex + patternOuterIndex][firstFoundIndex + patternInnerIndex]

.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

define "not working".

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Because you wrongly overrode equals. Add the "@Override" annotation above every method that is suppossed to override something and you would notice that. The "equals" method needs to take "Object" as the parameter, not "WatchedPath".

Edit: And, obviously, you should then check that are actually getting a "WatchedPath, and not something else, and, regardless, you should also check that it is not null.

Edit Again: As well as checking that "dir" is not null, before calling equals and/or hashCode, and/or CompareTo on it, of course. And, for the compareTo to be used properly, don't forget to implement Comparable.

stephen84s commented: Ahh... Missed the equals() method signature +5
masijade 1,351 Industrious Poster Team Colleague Featured Poster

HashSet uses hashCode and equals as already stated. Also, as already stated, test the hashCode and equals outputs of Path, and ensure that you are getting what you expect, and ensure that the problem does not lie there.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

As the first line of your "identify" method add if (!di.isDirectory()) return;

masijade 1,351 Industrious Poster Team Colleague Featured Poster

It is not condescending, at all. Scriplets in your JSP is a mixing of the model and the view (and, quite probably, the control) and a maintenance nightmare. If you are going to do something, regardless of on what scale, you can at least attempt to do it right.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm this, and this?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Yes, this is a basic JSP/JDBC problem. It is exactly what you should not be doing. Learn what beans are and use them. Or, at least, the SQL JSTL tags.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Okay? And? Try adding a simple sleep for, say 20 milliseconds, after the println, and see how it looks then. When you use System.out you are, essentially, giving up the output to another thread to actually throw out to the screen (among other things) and that will make this seem chaotic. Add a sleep to give it a bit of time. Better, would be to define a List in that "change" class and, rather than printing the sctrings, simply adding the strings to the list, and printing the entire list at the end. As long as the "add" takes place in the synchorinzed methods you will see the "flow" statements in the proper order.

Even more elegant, would be to use a ConcurrentLinkedQueue and add the strings to that and start another thread that does nothing but read this queue and print the strings contained therein. That should, also, give you the output in the proper order.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

You shouldn't need to be doing all of that at all. With the methods being synchronised, the synchronisation is taken place on the instance of change anyway, so only one thread will have access to the instance at one time already anyway.

And, since they both get the same instance of change, then that "commonresource" variable should be an instance variable and not a class variable (iow it should not be static).

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Uhm, add a couple of newlines?

System.getProperty("line.separator");

Or use two or three calls to println rather than just one?

masijade 1,351 Industrious Poster Team Colleague Featured Poster

No, I mean go to the site where you downloaded hive and look for some sort of "support" link there.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

What did I just say. The IDE's come with execution environments, but you will still want a device to deploy to and test on.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

NetBeans has a JME development environment as do most other "mainstream" IDE's. Choose one and try it out (they are also able to emulate JME run environments), but you will need one of the devices to deploy to to test it properly.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

Sounds like a question for the "hive" developers.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

See the API docs for JPasswordField. There is a method there called setEchoChar (or something to that effect). Use it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

The first simply "gets" another reference to STDIN, the next part reads the arguments provided to the command until it finds the option "-bs" and then reads that options parameter (i.e. the next argument). The last block creates an instance the class and calls a method from it.

masijade 1,351 Industrious Poster Team Colleague Featured Poster

call pack on the frame in which the component resides

or

call doLayout (and/or validate) on the component to which the component was added and then repaint

Edit: Although, in the second scenario, the layout of the frame itself (if the size of "subcomponent" has changed) will also, still need to be updated, so maybe simply call pack on the Frame or doLayout on the contentPane of the frame.

Chaster commented: Short, very good answer, that solves the issue. +3