|
It may be easier to add at the end of the list, but that doesn't mean it's more efficient. I'm guessing you've never heard of an insertion sort algorithm.
|
|
|
|
|
please help me to find a good java proposal to my java final project.. still we are learning java @ university but they asked us to give the java final project proposal.. so im hopeless in finding a good project..if anyone have a good new idea plz let me knw..
thx..
F.R.Majeed
|
|
|
|
|
|
Hi there,
I have an interview in a few hours for a new job which requires java technology.
I have some basic java knowledge and most things I found back in my .Net knowledge (Apache/Tomcat is similar to IIS, JVM is more or less CLR, etc...), but I was curious about the EJB specs. Are they like Session, Application and messaging objects in .NET ? That's what I gather from all the info on google, but I have the feeling that I'm missing a key point here. Most articles keep very vague in saying it makes the developer focus on the business logic eg.
So my question is, could you explain, in a nutshell, EJB (or other common java technologies) or point me to a good article (couldn't find one, not even wiki)
Many thanks.
V.
|
|
|
|
|
Looking at some of these links[^] I don't think you have time.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Thanks, that was idd my problem. That's why I wanted to know if there was something similar in .Net. Then I could map my .Net knowledge with this feature.
The articles are indeed lengthy and vague imho.
V.
|
|
|
|
|
The interview went unexpectedly well .
They figured that with my experience I could learn the new technologies very quickly anyway and they seemed more interested in motivation.
V.
|
|
|
|
|
what is the advance java and functon...??????
|
|
|
|
|
What indeed? Please think about your question before posting, as the above makes no sense. In fact you could probably type it into Google and get a reasonable answer.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
|
i have created one java servlet code from which i get 3 field from database table and i want to show this field on my js(java script) page in html tag like <lable>Name= and i want to show first name field from datbase infront of lable Name..
|
|
|
|
|
OK, now we know what you want. What's your question?
|
|
|
|
|
i have created a one java script file in that i have written a html code in boilerplate variable and ajax to call servlet .
in java servlet i have written a code for select query as to select data from database table and store tihs value in resultset
i want to store this resultset value in to javascript variable.
how i store it ???????
eg:-suppose i have table with firstname and Lastname fields and if i retrive this column in java servlet then i want this two column value to save/store in a java script variable on java script file
like var fname=????
var lname=????
|
|
|
|
|
Hi, i want to implement a voice chat in java . can anyone tell how to read abd send the voice data???
|
|
|
|
|
|
I'm working on a system and we have a problem on printing. System send an html content to the print class and we could not get a proper print page. I'm writing my codes. Please have a look..(sorry about my bad english)
PrintableEditorPane pane = new PrintableEditorPane(
html.getText());
pane.setContentType("text/html");
EditorPanePrinter pnl = new EditorPanePrinter(pane, new Paper(), new Insets(18, 18, 18, 18));
pnl.print();
---and this is my printing class
package org.esse.utility.image;
import javax.swing.*;
import javax.swing.text.View;
import javax.swing.text.Position;
import javax.print.PrintService;
import java.awt.print.*;
import java.awt.*;
import java.awt.geom.Area;
import java.awt.geom.AffineTransform;
import java.util.ArrayList;
public class EditorPanePrinter extends JPanel implements Pageable, Printable {
JEditorPane sourcePane;
Paper paper;
Insets margins;
ArrayList<pagepanel> pages;
int pageWidth;
int pageHeight;
View rootView;
public static int PAGE_SHIFT = 20;
PageFormat pageFormat;
public EditorPanePrinter(JEditorPane pane, Paper paper, Insets margins) {
initData(pane, paper, margins);
}
public void initData(JEditorPane pane, Paper paper, Insets margins) {
JEditorPane tmpPane = new JEditorPane();
tmpPane.setEditorKit(pane.getEditorKit());
tmpPane.setContentType(pane.getContentType());
tmpPane.setText(pane.getText());
this.sourcePane = tmpPane;
this.paper = paper;
this.margins = margins;
this.pageWidth = (int) paper.getWidth();
this.pageHeight = (int) paper.getHeight();
pageFormat = new PageFormat();
paper.setImageableArea(0, 0, paper.getWidth(), paper.getHeight() );
pageFormat.setPaper(paper);
doPagesLayout();
}
public void doPagesLayout() {
setLayout(null);
removeAll();
this.rootView = sourcePane.getUI().getRootView(sourcePane);
sourcePane.setSize(pageWidth - margins.top - margins.bottom, Integer.MAX_VALUE);
Dimension d = sourcePane.getPreferredSize();
sourcePane.setSize(pageWidth - margins.top - margins.bottom, d.height);
calculatePageInfo(); int count = pages.size();
this.setPreferredSize(new Dimension(pageWidth * 2 + 50, PAGE_SHIFT + count * (pageHeight + PAGE_SHIFT)));
}
@Override
public void paintComponent(Graphics g) {
super.paintComponent(g);
AffineTransform old = ((Graphics2D) g).getTransform();
((Graphics2D) g).setTransform(old);
}
protected void calculatePageInfo() {
pages = new ArrayList<pagepanel>();
int startY = 0;
int endPageY = getEndPageY(startY);
while (startY+pageHeight-margins.top-margins.bottom <
sourcePane.getHeight() * ( pageWidth /
sourcePane.getPreferredSize().getWidth()) / 1.8) {
Shape pageShape = getPageShape(startY, pageWidth - margins.left - margins.right, pageHeight - margins.top - margins.bottom, sourcePane);
pages.add(new PagePanel(startY, endPageY, pageShape));
startY = endPageY;
endPageY = getEndPageY(startY);
}
Shape pageShape = getPageShape(startY, pageWidth - margins.left - margins.right, pageHeight - margins.top - margins.bottom, sourcePane);
pages.add(new PagePanel(startY, endPageY, pageShape));
int count = 0;
for (PagePanel pi : pages) {
add(pi);
pi.setLocation(PAGE_SHIFT, PAGE_SHIFT + count * (pageHeight + PAGE_SHIFT));
count++;
}
}
protected int getEndPageY(int startY) {
int desiredY = startY + pageHeight - margins.top - margins.bottom;
int realY = desiredY;
for (int x = 1; x < pageWidth; x++) {
View v = getLeafViewAtPoint(new Point(x, realY), rootView);
if (v != null) {
Rectangle alloc = PrintApp.getAllocation(v, sourcePane).getBounds();
if (alloc.height > pageHeight - margins.top - margins.bottom) {
continue;
}
if (alloc.y + alloc.height > desiredY) {
realY = Math.min(realY, alloc.y);
}
}
}
return realY;
}
protected View getLeafViewAtPoint(Point p, View root) {
return getLeafViewAtPoint(p, root, sourcePane);
}
public static View getLeafViewAtPoint(Point p, View root, JEditorPane sourcePane) {
int pos = sourcePane.viewToModel(p);
View v = sourcePane.getUI().getRootView(sourcePane);
while (v.getViewCount() > 0) {
int i = v.getViewIndex(pos, Position.Bias.Forward);
v = v.getView(i);
}
Shape alloc = PrintApp.getAllocation(root, sourcePane);
if (alloc.contains(p)) {
return v;
}
return null;
}
public static Shape getPageShape(int pageStartY, int pageWidth, int pageHeight, JEditorPane sourcePane) {
Area result = new Area(new Rectangle(0, 0, pageWidth, pageHeight));
View rootView = sourcePane.getUI().getRootView(sourcePane);
Rectangle last = new Rectangle();
for (int x = 1; x < pageWidth; x++) {
View v = getLeafViewAtPoint(new Point(x, pageStartY), rootView, sourcePane);
if (v != null) {
Rectangle alloc = PrintApp.getAllocation(v, sourcePane).getBounds();
if (alloc.y < pageStartY && alloc.y + alloc.height > pageStartY) {
if (!alloc.equals(last)) {
Rectangle r = new Rectangle(alloc);
r.y -= pageStartY;
result.subtract(new Area(r));
}
}
last = alloc;
}
}
last = new Rectangle();
for (int x = 1; x < pageWidth; x++) {
View v = getLeafViewAtPoint(new Point(x, pageStartY + pageHeight), rootView, sourcePane);
if (v != null) {
Rectangle alloc = PrintApp.getAllocation(v, sourcePane).getBounds();
if (alloc.y < pageStartY + pageHeight && alloc.y + alloc.height > pageStartY + pageHeight) {
if (!alloc.equals(last)) {
Rectangle r = new Rectangle(alloc);
r.y -= pageStartY;
result.subtract(new Area(r));
}
}
last = alloc;
}
}
return result;
}
//pageable methods
public int getNumberOfPages() {
return pages.size();
}
public PageFormat getPageFormat(int pageIndex) throws IndexOutOfBoundsException {
return pageFormat;
}
public Printable getPrintable(int pageIndex) throws IndexOutOfBoundsException {
return this;
}
public int print(Graphics g, PageFormat pageFormat, int pageIndex)
throws PrinterException {
if (pageIndex < pages.size()) {
pageFormat.getPaper().setImageableArea(0, 0, paper.getWidth(), paper.getHeight());
pages.get(pageIndex).isPrinting = true;
pages.get(pageIndex).paint(g);
pages.get(pageIndex).paintAll(g);
pages.get(pageIndex).isPrinting = false;
return PAGE_EXISTS;
}
return NO_SUCH_PAGE;
}
class PagePanel extends JPanel {
int pageStartY;
int pageEndY;
Shape pageShape;
boolean isPrinting = false;
JPanel innerPage = new JPanel() {
public void paintComponent(Graphics g) {
super.paintComponent(g);
AffineTransform old = ((Graphics2D) g).getTransform();
//double scales = pageWidth
/ sourcePane.getPreferredSize().getWidth();
//scales = scales / 1.8;
Shape oldClip = g.getClip();
Area newClip = new Area(oldClip);
if (isPrinting) {
newClip = new Area(pageShape);
} else {
newClip.intersect(new Area(pageShape));
}
g.setClip(newClip);
g.translate(0, -pageStartY);
//((Graphics2D) g).scale(scales, scales);
sourcePane.paint(g);
for (Component c : sourcePane.getComponents()) {
AffineTransform tmp = ((Graphics2D) g).getTransform();
g.translate(c.getX(), c.getY());
((Container) c).getComponent(0).paint(g);
((Graphics2D) g).setTransform(tmp);
}
((Graphics2D) g).setTransform(old);
g.setClip(oldClip);
}
};
public PagePanel() {
this(0, 0, null);
}
public PagePanel(int pageStartY, int pageEndY, Shape pageShape) {
this.pageStartY = pageStartY;
this.pageEndY = pageEndY;
this.pageShape = pageShape;
setSize(pageWidth, pageHeight);
setBackground(Color.white);
setLayout(null);
add(innerPage);
innerPage.setBounds(margins.left, margins.top, pageWidth - margins.left - margins.right, pageHeight - margins.top - margins.bottom);
}
// public void paintComponent(Graphics g) {
// super.paintComponent(g);
// g.setColor(Color.black);
// g.drawRect(0, 0, getWidth() - 2, getHeight() - 2);
// }
}
public void print() {
print((PrintService) null);
}
public void print(PrintService ps) {
try {
PrinterJob pj = PrinterJob.getPrinterJob();
JFrame tmp = null;
if (this.getParent() == null) {
tmp = new JFrame();
tmp.getContentPane().add(new JScrollPane(this));
tmp.pack();
tmp.setVisible(false);
}
pj.setPageable(this);
if (ps != null) {
pj.setPrintService(ps);
}
// sending the document to the printer page
Boolean appliedPrint = pj.printDialog();
if(appliedPrint)
pj.print();
if (tmp != null) {
tmp.dispose();
}
} catch (PrinterException e1) {
e1.printStackTrace();
}
}
}
|
|
|
|
|
Waaaaaaaaay too much code. The least you could do is format it as a <code> block.
|
|
|
|
|
the (inputString == reverseString) if-conditional always returns false (even if it is true. please help. Couldn't figure this out. thanks.
import java.util.Scanner;
public class ReverseString{
public static void main (String[] args){
String inputString="";
int inputStringLength;
String reverseString="";
String stringHolder="";
Scanner in = new Scanner(System.in);
System.out.print("Enter a String: ");
inputString = in.next();
inputStringLength = inputString.length();
System.out.println("Input String is : " +inputString);
for (int i = 0; i<inputStringLength; i++){
stringHolder = inputString.charAt(i) + stringHolder;
reverseString = stringHolder;
}
System.out.println(reverseString);
System.out.println("inputString = " + inputString);
System.out.println("input length =" + inputString.length() + "reverse length " +reverseString.length());
System.out.println("Now let's test to see if your input is a palindrome (like hannah or 'a man, a plan, a canal, panama') \n" + "Does "+ inputString +" = the same forward and reversed? \n^^^ \n^^^ " );
if (inputString == reverseString){
System.out.println("yes!");
System.out.println(" YES!! Eureka! " + inputString + " == " + reverseString + "! Thus, " + inputString + " is a palindrome! gratzee!");
}else {
System.out.println("no");
System.out.println("NO!! \n" + inputString + " != (does not equal) " + reverseString + "\n So " + inputString + "is not a palindrome! Oh well no prob!" );
}
}
}
I've tried using scaffolding code to test for what is going on. I think someway reverseString is created may be a problem. But when I print reverseString and inputString they both have the same string length and visibly the same characters...so I don't know what the solution is at present.
|
|
|
|
|
You should be using String.equals() [^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hey really? Thanks Richard MacCutchan! Thanks for taking the time to look at that code, too. It's not yet solved b/c I have to try that comparison method, but thanks!!
However, I thought it was something like that so made a mini test program.
String var1 = "hello";
String var2 = "hello";
if (var1==var2){
System.out.println("equal!");
}
and THAT did show they were equal. If the String.equals() method works (and gets my ReverseString.java program to work, why would that above var1==var2 work but not so with inputString and reverseString?
Thanks!!
|
|
|
|
|
Well if you had read a bit more detail from the page I pointed you to you would understand that the above expression works only because var1 and var2 refer to the same String object, not because the strings themselves match. And from that it follows that you must always use String.equals() to get an actual comparison of the characters within the strings.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
oh bloody hell. was so excited to see a response, didn't even notice that you linked something.
I researched and found
"The == operator will only be true if two String references point to the same underlying String object. Hence two Strings representing the same content will be equal when tested by the equals(Object) method, but will only by equal when tested with the == operator if they are actually the same object."
which I "sorta" understand. like same object in memory referenced and two diff objects but with same string value (== only works as true with the former)
so == seems to compare objects in memory and String.equals() actually compares Strings (content of String objects).
Sweet am finally getting this a bit!!
Thanks for such complete answer...and now that that obstacle is resolved, my coding can progress for the day!
(Also I tried it and now that mini-app totally works. Thanks again!)
This is site is so much better than stackoverflow haha.
|
|
|
|
|
johtnkucz wrote: This is site is so much better than stackoverflow haha.
If nothing else you get a 5 for that comment.
Seriously, thanks for the feedback, it's always welcome, and good luck with your project(s).
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
I never rely on luck. I prefer efficiency and preparation (and utilizing awesome resources like this site!)!! Seriously thanks for the positive feedback...on my positive feedback!!
Seriously though This is my number one code-help (I have other resources for tutorials and stuff but if get stuck and need help) this owns other sites, including stack overflow. Your response was extremely helpful. thanks again so much for looking at code.
And re stackoverflow. I hate that site. Most comments and posts have this gross disgusting milieu of (ooh look how much coding I know or some cheesy leet rubbish of "no, you're supposed to post this way..or that way.." or whatever.
I just was thoroughly stumped, chucked up some code:
1. got the EXACT answer that was the prob
2. learned somethign I never fully understood even after a wretched computer science class and most all autodidactic(== compares objects not content of objects and strings may be equal but diff objects, so if linked to diff objects same content will appear as not equal because their objects are not equal but their content is) .
That's the epitome of helpful. Anyways if one gets similar exchanges, this is num 1 code resource. good times. The layout of forum posts/responses is unique and novel but appealing, too. Good tiems.
Were you involved in making this site or something, or just prefer this (anti overflow) to other sites, too. Cheers. thanks.
|
|
|
|
|
johtnkucz wrote: Were you involved in making this site or something
No, I'm just one of the 8.5 million ...
If you want to know a bit more about the site see here[^], and if you want to know who are the great people who did make the site then look here[^].
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|