 |

|
When posting your question please:- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-fou
|
|
|
|

|
hai friends............
i want the source code to receive the string in java based mobile phone via bluetooth from computer............
pls help me friends.................
|
|
|
|

|
usic vicky wrote: i want the source code Then you need to write it yourself, or use Google to search for samples[^].
|
|
|
|

|
I want source code in java for room allocation and auto optimisation for rooms in any training institute according to number of students and room capacity and according to future requirement rooms are optimised itself
|
|
|
|

|
Member 10325645 wrote: I want source code in java for ...
Really? You've been here six months, and you haven't worked out that this site doesn't work like that?
If you need specific help with part of some code that you're working on, then we can help. If you just want someone to write some code for you, then you're in the wrong place.
It's even up there at the top of the page:
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'".
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|

|
A homework question! Do your homework yourself. For specific problems, you may ask questions here, but it is up to you to learn to understand how things work, and hence you must try to write some simple programs instead of just copying code!
|
|
|
|

|
can anyone please help me with this.. ive created a class for gui..in which the frame consists 3 button and two text fields.. one button is to start server.. another button is to connect server.. and another button is for sending messages.. i have another server class... now how do i link the start server button object to server class inorder to start the server...???
startserver button say B1: gui class
link to server class?? can someone help me please..??
|
|
|
|

|
Write an event handler for the button, which creates a server object and starts it. Or is that too obvious?
|
|
|
|

|
You have need to implements ActionListener add actionlistener event like this
JButton btnStartServer = new JButton(" >> Start Server <<");
//Add action listener to button
btnStartServer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
//Execute when button is pressed
Server svr=new Server()
svr.startServer();
}
});
In Server class you have to create a startServer() method to do backend processing part.
Like This Example Code:
public void startServer() {
keepGoing = true;
/* create socket server and wait for connection requests */
try
{
// the socket used by the server
ServerSocket serverSocket = new ServerSocket(port);
// infinite loop to wait for connections
while(keepGoing)
{
// format message saying we are waiting
display("Server waiting for Clients on port " + port + ".");
Socket socket = serverSocket.accept(); // accept connection
// if I was asked to stop
if(!keepGoing)
break;
ClientThread t = new ClientThread(socket); // make a thread of it
al.add(t); // save it in the ArrayList
t.start();
}
// I was asked to stop
try {
serverSocket.close();
for(int i = 0; i < al.size(); ++i) {
ClientThread tc = al.get(i);
try {
tc.sInput.close();
tc.sOutput.close();
tc.socket.close();
}
catch(IOException ioE) {
// not much I can do
}
}
}
catch(Exception e) {
display("Exception closing the server and clients: " + e);
}
}
// something went bad
catch (IOException e) {
String msg = sdf.format(new Date()) + " Exception on new ServerSocket: " + e + "\n";
display(msg);
}
}
/*
manoj kumar
|
|
|
|

|
hi guys please help any body
|
|
|
|
|

|
Hi , I am just trying to reverse all the words of a string at their place only ex if there is a string : "vandana is a good girl" then the out put of the program should be "anadnav is a doog lrig" for that i have created a package to calculate the no of words in the string and also for calculating reverse of a string that pacage is: package p1; public class meth { public int cal(String s) { int wrd=0; for(int i=0;i<s.length();i++) { char c=s.charAt(i); if(Character.isWhitespace(c)) { wrd++; } } return wrd+1; } public String rev(String b) { String p=""; for(int i=0;i<b.length();i++) { p=b.charAt(i)+p; } return p; } } -----------------------------------------------------------------And the code of my program is : import p1.*; import java.io.*; class rv { public static void main(String args[]) throws IOException { InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); System.out.println("Enter your string :"); String s=br.readLine(); meth ob=new meth(); int n=ob.cal(s); String m=""; while(n>=0) { for(int i=0;i<s.lenght();i++) { char c=s.charAt(i); if(Character.isWhitespace(c)) { String p=s.substring(0,i); meth ob1=new meth(); String sb=ob1.rev(p); m=m+" "+sb; s=s.substring(i+1,s.length()); } } n--; } System.out.println(m); } } but the problem is my program gives different different out put and it's not working well and i've tired to understand th problem.
-- modified 5-Apr-14 14:25pm.
|
|
|
|

|
Why make it so complicated? Just read the string and then loop through the characters in reverse order and print each one. You will end up with the string reversed.
|
|
|
|

|
i need to reverse the spelling of words and need not to change their order i.e dog is an animal out should be: god si na lamina .if i use for loop then then the whole string get it'sreverse.
|
|
|
|

|
Then all you need to do is split the string at each wordbreak (e.g. space) and then do the same to each word.
|
|
|
|

|
yeah same i was doing in my code can you please take a look of it
|
|
|
|

|
As I suggested earlier, it can be simplified considerably by using the Scanner class, as in the following sample. If you do not wish to use the scanner, then you could write your own class that splits a string into a collection of tokens.
public static void main(String[] args) throws Exception {
Scanner sc = new Scanner("Cotta and Balbus love the sweet voices of the girls");
while (sc.hasNext())
{
String nextWord = sc.next();
char c;
for (int i = nextWord.length() - 1; i > -1; --i)
{
c = nextWord.charAt(i);
System.out.print(c);
}
System.out.print(" ");
}
System.out.println(".");
}
|
|
|
|

|
Take a look at the Scanner class[^], which can help in the breaking up of words.
|
|
|
|

|
I want java code for fetch the details from my ms access database and those details are run in my program to excute the code.....
-- modified 5-Apr-14 7:44am.
|
|
|
|

|
Guyss i need just code for fetch details from msaccess database...
|
|
|
|
|

|
Hi guys , I do need help , cause i'm no a develloper but i have to do program on java that will read .txt file from database and get a specific String(FERME):
10/04/13 06:46 PS : 16 PN 239-Km 359.4 L.V K.ANI PN239 L/V: FERME
10/04/13 06:46 PS : 16 PN 239-Km 359.4 L.V 8V CdV C.J : 08.8 V
the file is made of multiple line like above, i just need to check if the file hade the word FERME....
thank you for your help
|
|
|
|

|
If that is all you need to do then it would be faster just to run the FIND command. However if there is more to it than that, and you are sure that you need a Java program, then you need to learn The Java Language[^] and the Basic I/O classes[^].
|
|
|
|

|
Sure I'm doing it but still :
-04-10-11:22:30. DEFAUT Z: .
RANDAN..
P0:.......
P1:.......
P2:.......
P3:.STA... 10/04 11:22
-04-10-11:22:55.............
RANDAN..
P0:.......
P1:.......
P2:.......
P3:.END DF 10/04 11:22
My files lines are structured like above,where the P1,P2..can change their states,at the specifique time,just want read those line and compare if the P1,P
,P3 states changed...please really nee ur help guys!!!...
|
|
|
|

|
mtouxx wrote: nee ur help guys With what? You still have not explained anything about your code or where it is having a problem/ What do you mean by P1,P2..can change their states,at the specifique time, or just want read those line and compare if the P1,P
,P3 states changed?
|
|
|
|

|
Ok i need a java code that helps me to read and check my file line by line, and in thoses line we get parameters, such as P1, P2,and P3, this file in to take on a data base, and each file get several lines
|
|
|
|

|
mtouxx wrote: i need a java code Well I'm afraid you are going to have to write it, as only you know what you are trying to do with the content of these files. The Scanner class[^] is probably a good one to help you parse the data.
|
|
|
|

|
Really appreciate thsi conversation such a helpfull!!!!..
|
|
|
|

|
But I think i better ask somewhere else!...
|
|
|
|

|
I think you may find the answers the same; no one is going to write this for you.
|
|
|
|

|
Someone kind enough I believe will help me..anyway think u for your attention!..
|
|
|
|

|
hello,
can any1 tell me how to develop a port scanner in java.I am not asking d entire code but atleast can any1 gimme an idea where 2 start from.
|
|
|
|
|

|
hello,
can any1 tell me how to develop a port scanner in java.
|
|
|
|

|
Google[^]
We can't do a lot for you if you don't give more details...
I will never again mention that Dalek Dave was the poster of the One Millionth Lounge Post, nor that it was complete drivel.
How to ask a question
|
|
|
|

|
I want to create a jquery dialog box which onlick of a image it has to load the dynamic page data and display. currently iam writing the code as below but its not working.
var history = function(value, rowIndex) {
var id = this.grid.getItem(rowIndex).ID;
return "<img src=/img/showimg.jpg width=20 height=20 id=button1">";
};
<script>
$(function() {
$( "#dialog" ).dialog({
autoOpen: false,
show: {
effect: "blind",
duration: 1000
},
hide: {
effect: "explode",
duration: 1000
}
});
$( "#button1" ).click(function() {
$( "#dialog" ).dialog( "open" );
});
});
|
|
|
|
|

|
If I know
String IP = "127.0.0.1";
int port = 2020;
how an I estbish connection fomone client to this one in java Socket Programming.
I hae tried
Socket s = SocketFactory.getDefault().createSocket("localhost", Integer.parseInt(port));// sf = new SocketFactory;
but it is throwing exception.
Please help
|
|
|
|

|
The address "127.0.0.1" is the loopback address of your own PC, so you will need another program running there that is listening on that port. See http://docs.oracle.com/javase/tutorial/networking/sockets/[^] for the correct way to do it.
In future please do not just say "it is throwing exception. Please help". Provide the exact code that is failing, and full details of the exception or other error message.
|
|
|
|

|
Hi
Here i am posting my code that i have written
package com.evora.practice.swing;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.filechooser.FileNameExtensionFilter;
public class PhotoViewer {
public static void main(String args[]){
new Main();
}
}
class ImageDraw extends Canvas{
/**
*
*/
private static final long serialVersionUID = 1L;
BufferedImage img;
double radian=0.0;
Dimension ds;
int iw;
int ih;
int x;
int y;
int adjX;
int adjY;
int adjW;
int adjH;
int mX;
int mY;
int orWidth;
int orHeight;
boolean rotate;
HashMap imgFiles;
String filename;
int curImgIndex;
ImageDraw(){
ds=getToolkit().getScreenSize(); //get the screen size
mX=(int)ds.getWidth()/4; //half of the screen width
mY=(int)ds.getHeight()/4; //half of the screen height
filename=null; //initialize filename variable
rotate=false; //initialize rotate variable
//initialize variables used to increase or decrease photo size
adjX=0;
adjY=1;
adjW=1;
adjH=1;
}
public void paint(Graphics g){
if(filename!=null){
if(rotate) //show rotated photo
rotateImage(g);
else
showImage(g); //show normal and zoom photo
}
}
//The rotateImage rotates the photo in clockwise or counterclockwise
//direction based on the radian value
public void rotateImage(Graphics g){
Graphics2D g2d=(Graphics2D)g;
g2d.translate(mX,mY); //move the original coordinate to point(mX,mY)
g2d.rotate(radian); //rotate the photo
g2d.translate(-iw/2,-ih/2); //move the coordinate back to point (iw/2,ih/2)
g2d.drawImage(img,0,0,iw,ih,null);//show the rotate photo
g2d.dispose(); //clean the g2d object
rotate=false; //reset the rotate to false after the photo rotates
}
//Increase the radian value by Math.PI/2
//so the photo is rotated in clockwise direction
public void rotateClockwise(){
radian+=Math.PI/2;
}
//Decrease the radian value by Math.PI/2
//so the photo is rotated in countclockwise direction
public void rotateCounterClockwise(){
radian-=Math.PI/2;
}
//The showImage method has code to display the photo when it is in
//normal view or zoom view
public void showImage(Graphics g){
Graphics2D g2d=(Graphics2D)g;
g2d.translate(x,y);
g2d.drawImage(img,0,0,iw,ih,null);
g2d.dispose();
}
public void readImage(String filename){
try{
//read the photo file so it is ready to display
img=ImageIO.read(new File(filename));
//get the original width and height of the photo
orWidth=img.getWidth();
orHeight=img.getHeight();
//Make sure the photo is not too large to fit the screen
if(mX40 && ih>40){
adjX+=10;
adjY+=10;
adjW-=20;
adjH-=20;
setImageBounds();
}
}
//The storeImages method is invoked when the user select the Open... sub-menu
//item from the program interface
//It displays a file chooser dialog for multiple files selection
//The selected photos file are stored in a HashMap object imgList for
//later show
public void storeImages(){
imgFiles=new HashMap();
JFileChooser chooser = new JFileChooser("C:\\Users\\Public\\Pictures\\Sample Pictures\\");
FileNameExtensionFilter filter = new FileNameExtensionFilter("Images", "jpg", "gif","png","bmp");
chooser.setFileFilter(filter);
chooser.setMultiSelectionEnabled(true);
int returnVal = chooser.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
File[] Files=chooser.getCurrentDirectory().listFiles();
for( int i=0;i getImgFiles(){
return imgFiles;
}
}
//The Main class represents the interface of the PhotoView program
//On the interface, you see a File menu that has two sub-menu items: Open..., and Exit
//When the photo is displayed, the program will display a panel that contains
//all buttons you need to rotate, zoom, move, and play the slideshow of the photos
class Main extends JFrame implements ActionListener{
/**
*
*/
private static final long serialVersionUID = 1L;
JButton btrotateClockwise;
JButton btrotateCounterClockwise;
JButton btZoomIn;
JButton btPrevious;
JButton btNext;
JButton btZoomOut;
JButton btSlideShow;
JPanel panel;
ImageDraw imgDraw;
boolean stop=true;
ImageSlide Slider;
Main(){
setTitle("Photo Viewer");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setExtendedState(this.getExtendedState() | JFrame.MAXIMIZED_BOTH);
setBackground(Color.CYAN);
JMenuBar mainmenu=new JMenuBar();
JMenu menu=new JMenu("File");
JMenuItem mopen=new JMenuItem("Open...");
mopen.setMnemonic(KeyEvent.VK_O);
mopen.addActionListener(this);
JMenuItem mexit=new JMenuItem("Exit");
mexit.setMnemonic(KeyEvent.VK_X);
mexit.addActionListener(this);
menu.add(mopen);
menu.add(mexit);
mainmenu.add(menu);
setJMenuBar(mainmenu);
btrotateClockwise=new JButton("ROTATE RIGHT");
btrotateClockwise.setBackground(Color.GREEN);
btrotateClockwise.addActionListener(this);
btrotateCounterClockwise=new JButton("ROTATE LEFT");
btrotateCounterClockwise.setBackground(Color.YELLOW);
btrotateCounterClockwise.addActionListener(this);
btZoomIn=new JButton("ZOOMIN");
btZoomIn.setBackground(Color.MAGENTA);
btZoomIn.addActionListener(this);
btZoomOut=new JButton("ZOOMOUT");
btZoomOut.setBackground(Color.PINK);
btZoomOut.addActionListener(this);
btPrevious=new JButton("BACK");
btPrevious.setBackground(Color.ORANGE);
btPrevious.addActionListener(this);
btNext=new JButton("NEXT");
btNext.setBackground(Color.GRAY);
btNext.addActionListener(this);
btSlideShow=new JButton("PLAYALL");
btSlideShow.setBackground(Color.WHITE);
btSlideShow.addActionListener(this);
panel=new JPanel();
panel.setLayout(new FlowLayout());
panel.add(btrotateClockwise);
panel.add(btrotateCounterClockwise);
panel.add(btZoomIn);
panel.add(btZoomOut);
panel.add(btNext);
panel.add(btPrevious);
panel.add(btSlideShow);
panel.setBackground(Color.BLACK);
add(panel, BorderLayout.SOUTH);
imgDraw=new ImageDraw();
add(imgDraw,BorderLayout.CENTER );
setVisible(true);
panel.setVisible(false);
}
//*handling buttons and sub-menu items clicks
public void actionPerformed(ActionEvent e){
if(e.getSource()==btrotateClockwise)
{
imgDraw.rotate=true;
imgDraw.rotateClockwise();
imgDraw.repaint();
}
else if(e.getSource()==btrotateCounterClockwise)
{
imgDraw.rotate=true;
imgDraw.rotateCounterClockwise();
imgDraw.repaint();
}
else if(e.getSource()==btZoomIn)
{
imgDraw.zoomIn();
imgDraw.repaint();
}
else if(e.getSource()==btZoomOut)
{
imgDraw.zoomOut();
imgDraw.repaint();
}
else if(e.getSource()==btPrevious)
{
imgDraw.movePrevious();
}
else if(e.getSource()==btNext)
{
imgDraw.moveNext();
}
else if(e.getSource()==btSlideShow)
{
if(stop){
startClick();
}
else{
stopClick();
}
}
else{
JMenuItem source = (JMenuItem)(e.getSource());
if(source.getText().compareTo("Open...")==0)
{
imgDraw.storeImages();
imgDraw.moveFirst();
panel.setVisible(true);
}
else if(source.getText().compareTo("Exit")==0)
System.exit(0);
}
}
//The stopClick method invoked when you click the Pause button
//*to stop the slideshow
public void stopClick(){
btSlideShow.setIcon(new ImageIcon("playall.png"));
stop=true;
Slider.stopShow();
}
//The startClick method invoked when you click the Play button
//to start the slideshow
public void startClick(){
btSlideShow.setIcon(new ImageIcon("pause.png"));
stop=false;
Slider=new ImageSlide();
Slider.start();
}
//The ImageSlide class handle the photo slideshow process
//When you click the Play button the run method of this class is invoked
//When you click the Pause button the stopShow method of this class is invoked
class ImageSlide extends Thread{
boolean started;
HashMap map;
ImageSlide(){
started=true;
map=imgDraw.getImgFiles();
}
public void run(){
int i;
try{
for(i=0;i<map.size();i++)
{
if(started!=false){
Thread.sleep(1000); //time interval between each photo show
imgDraw.moveNext(); //show the next photo
}
}
stopClick(); //stop show when all photos are displayed
imgDraw.moveFirst(); //show the first photo again
}catch(InterruptedException ie){System.out.println("Interrupted slide show...");}
}
public void stopShow(){
started=true;
}
}
}
when ever i am executing this program & pressing the PlayAll button getting some exception like NullPointerException. Can anyone tell me why i am getting this type of exception over here?And what is the Solution?
Thanks in Advance.
Ajitesh.
|
|
|
|

|
- Please edit the above and use the code button to put <pre> tags around your code so it is readable.
- Show us the line in the code where the error occurs.
|
|
|
|
|

|
java.lang.ClassNotFoundException: Could not load requested class : com.mysql.jdbc.driver . This is coming while executing..I have also updated the buildpath by hibernate jars & mysql connector bin jar.still it is not working
|
|
|
|

|
you can post your query on javatpoint forum.
www.javatpoint.com/forum
|
|
|
|

|
Have you written mysql dialect in hibernate.cfg.xml??
|
|
|
|

|
Hello My Fren,please help me
I have serious problem here
whts the code or how to connect to database for input/save data and to show the data pleaseee
Thanks
|
|
|
|
|

|
Can any one explain why we can not create an object for Abstract classes, although we can create a constructor of an abstract class?
|
|
|
|

|
An abstract class is just that, it is abstract, it is not a 'real' thing. It is used as the basis for real classes so it may contain some implemented methods that will be common among all derived classes. But it will also contain some methods without implementation, as place holders for the derived ones. See http://docs.oracle.com/javase/tutorial/java/IandI/abstract.html[^] for more details.
|
|
|
|

|
Because otherwise there would be no difference between abstract and non-abstract.
|
|
|
|
 |