|
In fact, when you're creating your new J2EE project, you've got the option to define where you've installed the App. Server desired for your project, in order to allow the IDE to build the specific artefact with its deployment descriptors.
|
|
|
|
|
I am building an interface that will be run only locally on users computers using HTML (no web servers involved). What I'd like to do as part of this project is to be able to list the contents of local folders related to this project. Meaning I have a parent folder that will contain all the HTML pages as well as folders with PDF files in them. From my main page I'd like to have a link to those folders and when visited, that link would list the files in that folder. This way, when additional files are added or when files are deleted, the listing will reflect the actual folder contents. Right now this works by linking to the folders and getting the raw Directory listing but the listings are not pretty. I am looking for a more elegant way to achieve this.
Anyone know how to do this with HTML or Javascript?
Thanks,
Craig
|
|
|
|
|
Quite possibly, but this is the Java forum.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I would use a CMS. No need to develop that yourself.
try WebsiteBaker[^] as a simple CMS for small projects.
|
|
|
|
|
|
what are the coding is right for out put visualisation hanoi tower in netbeans?
import java.awt.*;
import javax.swing.*;
import no.geosoft.cc.graphics.*;
/**
* G demo program. Demonstrates:
*
*
* - A sample game application
* - Graphics animation
* - GObject reparenting
*
*
* @author Jacob Dreyer
*/
public class Demo14 extends JFrame
{
private TowersOfHanoi towersOfHanoi_;
private GWindow window_;
private Peg[] pegs_;
private int nDiscs_;
private JButton startButton_;
public Demo14 (int nDiscs)
{
super ("G Graphics Library - Demo 14");
setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
nDiscs_ = nDiscs;
// Create the graphic canvas
window_ = new GWindow (new Color (200, 230, 200));
getContentPane().add (window_.getCanvas());
// Create scene
GScene scene = new GScene (window_);
double w0[] = {0.0, 0.0, 0.0};
double w1[] = {4.0, 0.0, 0.0};
double w2[] = {0.0, nDiscs_ * 2, 0.0};
scene.setWorldExtent (w0, w1, w2);
// Add title object and add to scene
scene.add (new Title());
// Create the 3 pegs and add to the scene
int nPegs = 3;
pegs_ = new Peg[nPegs];
for (int i = 0; i < nPegs; i++) {
pegs_[i] = new Peg (i + 1.0);
scene.add (pegs_[i]);
}
// Create the discs and add to the first peg
for (int i = 0; i < nDiscs; i++) {
Disc disc = new Disc ((double) (nDiscs - i) / nDiscs);
disc.setPosition (1.0, i);
pegs_[0].add (disc);
}
pack();
setSize (new Dimension (500, 500));
setVisible (true);
// Create the puzzle and execute the solution
towersOfHanoi_ = new TowersOfHanoi();
towersOfHanoi_.solve();
}
public void discMoved (int source, int destination)
{
// This is the disc to move
Disc disc = (Disc) pegs_[source].getChild (pegs_[source].getNChildren()-1);
double y0 = disc.getY();
double y1 = nDiscs_ + 4.0;
double x0 = pegs_[source].getX();
double x1 = pegs_[destination].getX();
// Animate vertical up movement
double step = 0.2;
double y = y0;
while (y < y1) {
disc.setPosition (x0, y);
disc.redraw();
window_.refresh();
y += step;
}
// Reparent peg
pegs_[source].remove (disc);
pegs_[destination].add (disc);
// Animate horizontal movement
step = 0.05;
double x = x0;
while (x != x1) {
disc.setPosition (x, y);
disc.redraw();
window_.refresh();
x += (x1 > x0 ? step : -step);
if (Math.abs (x - x1) < 0.01) x = x1;
}
// Animate vertical down movement
step = 0.2;
y = y1;
y1 = pegs_[destination].getNChildren() - 1;
while (y > y1) {
if (Math.abs (y - y1) < 0.01) y = y1;
disc.setPosition (x, y);
disc.redraw();
window_.refresh();
y -= step;
}
}
/**
* Graphics object for canvas title.
*/
class Title extends GObject
{
private GSegment anchor_;
public Title()
{
GStyle style = new GStyle();
style.setLineStyle (GStyle.LINESTYLE_INVISIBLE);
style.setForegroundColor (new Color (100, 100, 200));
style.setFont (new Font ("serif", Font.PLAIN, 36));
setStyle (style);
anchor_ = new GSegment();
addSegment (anchor_);
GText text = new GText ("Towers of Hanoi", GPosition.SOUTHEAST);
anchor_.setText (text);
}
public void draw()
{
anchor_.setGeometry (20, 20);
}
}
/**
* Graphics representation of a peg.
*/
class Peg extends GObject
{
private double x_;
private GSegment peg_;
private double[] xy_;
public Peg (double x)
{
x_ = x;
GStyle style = new GStyle();
style.setBackgroundColor (new Color (100, 100, 100));
setStyle (style);
peg_ = new GSegment();
addSegment (peg_);
xy_ = new double[] {x_ - 0.05, 0.0,
x_ - 0.05, nDiscs_ + 2,
x_ + 0.05, nDiscs_ + 2,
x_ + 0.05, 0.0,
x_ - 0.05, 0.0};
}
public double getX()
{
return x_;
}
public void draw()
{
peg_.setGeometryXy (xy_);
}
}
/**
* Graphics representation of a disc.
*/
class Disc extends GObject
{
private double size_;
private GSegment disc_;
private double x_, y_;
public Disc (double size)
{
size_ = size;
GStyle style = new GStyle();
style.setForegroundColor (new Color (255, 0, 0));
style.setBackgroundColor (new Color (255, 150, 150));
setStyle (style);
disc_ = new GSegment();
addSegment (disc_);
}
public void setPosition (double x, double y)
{
x_ = x;
y_ = y;
}
public double getY()
{
return y_;
}
public void draw()
{
double[] xy = new double[] {x_ - size_ / 2.0, y_,
x_ - size_ / 2.0, y_ + 1.0,
x_ + size_ / 2.0, y_ + 1.0,
x_ + size_ / 2.0, y_,
x_ - size_ / 2.0, y_};
disc_.setGeometryXy (xy);
}
}
/**
* Class for solving the "Towers of Hanoi" puzzle.
*/
class TowersOfHanoi
{
public void solve()
{
solve (nDiscs_, 0, 2, 1);
}
private void solve (int nDiscs, int source, int destination, int auxiliary)
{
if (nDiscs == 1)
discMoved (source, destination);
else if (nDiscs > 1) {
solve (nDiscs - 1, source, auxiliary, destination);
discMoved (source, destination);
solve (nDiscs - 1, auxiliary, destination, source);
}
}
}
public static void main (String[] args)
{
int nDiscs = 8;
Demo14 demo = new Demo14 (nDiscs);
}
}
help me please
|
|
|
|
|
it is supposed to be YOUR homework. so I suggest that you do it yourself.
We will help you if you've got a problem, but we do not provide solutions for homework.
|
|
|
|
|
Please wrap your code in Pre tag. it will give better readability to other user to understand your code snippet.
|
|
|
|
|
resize
private BufferedImage resizeImage(BufferedImage originalImage, int type,int width, int hieght){
BufferedImage resizedImage = new BufferedImage(width, hieght, type);
Graphics2D g = resizedImage.createGraphics();
g.drawImage(originalImage, 0, 0, width, hieght, null);
g.dispose();
return resizedImage;
}
convert into gray scale
public static BufferedImage convertToGrayscale(BufferedImage source) {
BufferedImageOp op = new ColorConvertOp(
ColorSpace.getInstance(ColorSpace.CS_GRAY), null);
return op.filter(source, null);
}
public BufferedImage gray(BufferedImage source)
{
BufferedImage image = new BufferedImage(source.getWidth(), source.getHeight(),
BufferedImage.TYPE_BYTE_BINARY);
// BufferedImage.);
Graphics g = image.getGraphics();
g.drawImage(source, 0, 0, null);
g.dispose();
return image;
}
rotate
public static BufferedImage rotate(BufferedImage img, int angle) {
int w = img.getWidth();
int h = img.getHeight();
BufferedImage dimg = dimg = new BufferedImage(h, w, img.getType());
Graphics2D g = dimg.createGraphics();
g.rotate(Math.toRadians(angle), h/2, w/2);
g.drawImage(img, null, 0, 0);
return dimg;
}
horizontalflip
public static BufferedImage horizontalflip(BufferedImage img) {
int w = img.getWidth();
int h = img.getHeight();
BufferedImage dimg = new BufferedImage(w, h, img.getType());
Graphics2D g = dimg.createGraphics();
g.drawImage(img, 0, 0, w, h, w, 0, 0, h, null);
g.dispose();
return dimg;
}
dithering
public static BufferedImage processImage(BufferedImage inputImage) {
// Create a binary image for the results of processing
int w = inputImage.getWidth();
int h = inputImage.getHeight();
BufferedImage outputImage = new BufferedImage(w, h,
BufferedImage.TYPE_BYTE_BINARY);
// Work on a copy of input image because it is modified by diffusion
WritableRaster input = inputImage.copyData(null);
WritableRaster output = outputImage.getRaster();
final int threshold = 180;
float value, error;
for (int y = 0; y < h; ++y)
for (int x = 0; x < w; ++x) {
value = input.getSample(x, y, 0);
// Threshold value and compute error
if (value < threshold) {
output.setSample(x, y, 0, 0);
error = value;
}
else {
output.setSample(x, y, 0, 1);
error = value - 255;
}
// Spread error amongst neighbouring pixels
if((x > 0) && (y > 0) && (x < (w-1)) && (y < (h-1)))
{
value = input.getSample(x+1, y, 0);
input.setSample(x+1, y, 0, clamp(value + 0.4375f * error));
value = input.getSample(x-1, y+1, 0);
input.setSample(x-1, y+1, 0, clamp(value + 0.1875f * error));
value = input.getSample(x, y+1, 0);
input.setSample(x, y+1, 0, clamp(value + 0.3125f * error));
value = input.getSample(x+1, y+1, 0);
input.setSample(x+1, y+1, 0, clamp(value + 0.0625f * error));
}
}
return outputImage;
}
// Forces a value to a 0-255 integer range
public static int clamp(float value) {
return Math.min(Math.max(Math.round(value), 0), 255);
}
public static final int getColorIndexSize(RenderedImage img) {
ColorModel cm = img.getColorModel();
if (cm instanceof IndexColorModel) {
IndexColorModel icm = (IndexColorModel)cm;
return icm.getMapSize();
} else {
return 0;
}
}
|
|
|
|
|
Please don't post messages like this here; read this[^]. If you have an idea for an article then follow these guidelines[^], and do it properly.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Have a TVG in compensation for the little one.
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
'm doing my graduation project on RECOGNITION OF HANDWRITTEN SHORTHAND LANGUAGE STROKES .... So, please any one who is interested in it give me some guidelines...
1.thinking to implement it in MATLAB or JAVA... please suggest me which is better ...
2.will i get any module of code to build my project instead of building it from scratch..? if , from where pls specify it....
3.pls any one who is interested in guiding me may pls leave your mail id as comment.. so that i 'll ask for your help...
|
|
|
|
|
bharath S h wrote: doing my graduation project
1. Which is better? That is a very subjective question, better in what way? You need to research the languages and decide which better meets your needs.
2. Since it's your project then I would suggest you need to design and write it. Copying others' work for a graduation project is not really honest.
3. This won't happen. This is an open site where all assistance is offered in the forums and thus is public.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
'm doing my graduation project on RECOGNITION OF HANDWRITTEN SHORTHAND LANGUAGE STROKES .... So, please any one who is interested in it give me some guidelines...
1.thinking to implement it in MATLAB or JAVA... please suggest me which is better ...
2.will i get any module of code to build my project instead of building it from scratch..? if , from where pls specify it....
..
|
|
|
|
|
Always wrap your code in Pre tag. it will give better readability to other user to understand your code snippet.
|
|
|
|
|
thanks for ur code,,, but i decided to do it matlab.... so any thanks for posting
|
|
|
|
|
import java.util.Arrays;
import org.apache.commons.lang.time.*;
public class JavaApplication1 {
public static void main(String[] args) {
java.util.Random r = new java.util.Random();
int[] stuff = new int[100000];
System.out.println("Unordered array....:");
for (int i = 0; i < stuff.length; i++)
{
stuff[i] = r.nextInt(100000);
}
System.out.print(Arrays.toString(stuff));
StopWatch watch = new StopWatch();
watch.start();
Arrays.sort(stuff, 0, 100000);
watch.stop();
System.out.println("Ordered array....:");
System.out.print(Arrays.toString(stuff));
System.out.println();
System.out.println("executed in "+watch.getTime()+" miliseconds...");
}
}
StopWatch api download
runs 4 times slower than the .net c# code!
what am i missing? what can i do to improve performance? is this interesting? I am familiar with c# but i wand to deep dive in java
to broaden my knowledge on languages and frameworks
here is the code in c#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication4
{
class Program
{
static void Main(string[] args)
{
Random r = new Random();
int[] stuff = new int[100000];
System.Console.WriteLine("Unordered array....:");
for (int i = 0; i < stuff.Length; i++)
{
stuff[i] = r.Next(100000);
System.Console.Write(stuff[i].ToString() + " ");
}
Stopwatch watch = new Stopwatch();
watch.Start();
Array.Sort(stuff);
watch.Stop();
System.Console.WriteLine("Ordered array....:");
for(int k=0;k<stuff.Length;k++)
{
System.Console.Write(stuff[k].ToString() + " ");
}
System.Console.WriteLine("executed in " + watch.ElapsedMilliseconds.ToString() + " miliseconds...");
System.Console.ReadKey();
}
}
}
|
|
|
|
|
nipsonanomimata wrote: is this interesting?
Not really.
|
|
|
|
|
how much RAM is your java-runtime allowed to access?
|
|
|
|
|
how can i check how much ram is my java-runtime allowed to access?
i just installed the jdk1.7 , and build the code using netbeans 7.01
|
|
|
|
|
SOLUTION:
This works for me but I still do not know why it was behaving like that...
if (table.getCellEditor() != null) {
table.getCellEditor().stopCellEditing();
}
Was called when deleting the row, forcing the cell that is being edited to stop editing.
PROBLEM:
I have the following CellEditor that is used to validate cells on a column:
public class CellEditor extends AbstractCellEditor implements TableCellEditor {
protected TextField source = new TextField();
private ArrayList<IValidator> validators = new ArrayList<IValidator>();
public CellEditor WithValidation(IValidator validator) {
validators.add(validator);
return this;
}
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
source.setText(String.valueOf(value));
return source;
}
public Object getCellEditorValue() {
return source.getText();
}
@Override
public boolean stopCellEditing() {
String s = ((String) this.getCellEditorValue());
if (s == null) {
this.fireEditingCanceled();
return false;
}
for (IValidator v : this.validators) {
if (!v.isValid(s)) {
JOptionPane.showMessageDialog(null, v.getErrorMessage());
this.fireEditingCanceled();
return false;
}
}
return super.stopCellEditing();
}
}
And I attach the code to my table like this:
this.jTable1.getColumnModel()
.getColumn(0)
.setCellEditor(new loyaltyapp.validation.CellEditor()
.WithValidation(new TextLengthValidator(1, 12)));
When the second snippet of code is commented everything works as intended (but of course not including any validation)...
The problem is that when I do attach the CellEditor to my table when I remove a row WHILE a cell is being edited the rest of the row gets deleted, leaving behind a rogue cell!
Image of selecting a cell:
http://www.mediafire.com/?8n999a4djacdj84[^]
Image of deleting the row while selecting the validation cell:
http://www.mediafire.com/?mozjjzc53ju12b2[^]
The only way to remove it is by pressing escape...
Any ideas?
|
|
|
|
|
The problem is that when I do attach the CellEditor to my table when I remove a row WHILE a cell is being edited the rest of the row gets deleted, leaving behind a rogue cell!
Then decide - Editing OR deleting. Can't have both. Is the system deleting the row or how is it done?
|
|
|
|
|
ecrir un programme compose une formule en sous formule
|
|
|
|
|
1. This is an English language site.
2. We do not write code to order.
3. Even translated your question makes little sense.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|