 |
 |
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
|
|
|
|
 |
Please can someone help with a good document to learn CORE JAVA part? Also, please can you suggest me with some important concepts to get a very good hold on the core part?
Thanks.
|
|
|
|
|
 |
How can i get time of sending and receiving messages between computers through time of flight based technique ?
i want the java code for it..
im doing the project called "discover and verification of neighbour position in MANET" ..IF U CAN PLEASE SEND THE JAVA CODE ..
|
|
|
|
 |
What does "time of flight" has to do with time APIs in Java?
Anyway, you can work your way around from this Oracle Java developers document[^]. You can get the time before sending the message, and at the time of recieving the message from the network.
The sh*t I complain about
It's like there ain't a cloud in the sky and it's raining out - Eminem
~! Firewall !~
|
|
|
|
 |
can you please send the java code?
It is for calculating the distance between two position from time information..i need to get the transmission time from one system and reception time of my message in another system..please send the java code for the above..
It is for doing the project called"Discovery and Verification of neighbour position in MANET"..Thank U ..
|
|
|
|
|
 |
can you please send the java code?
It is for calculating the distance between two position from time information..i need to get the transmission time from one system and reception time of my message in another system..please send the java code for the above..
It is for doing the project called"Discovery and Verification of neighbour position in MANET"..Thank U ..
|
|
|
|
 |
I already told you "don't ask for code". This site is not here to do your work for you. If this project is beyond your abilities then you need to talk to your supervisor/manager about it.
|
|
|
|
 |
Does anyone know how to find a median of an array? How do we sort it first?
|
|
|
|
|
 |
Why is it giving me a zero.
double percent = 0;
if(condition) {
percent = scrollpane.getHeight() / origIcon.getImage().getHeight(scrollpane);
System.out.print(scrollpane.getHeight() + " / " + origIcon.getImage().getHeight(scrollpane));
System.out.println(" = " + percent);
} else {
}
This returns 309 / 1668 = 0.0 value should be 0.1852..
I know this is basic but I DON'T KNOW. sorry, too tired I guess but I need this to figure out
Thanks
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.
- Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
|
|
|
|
 |
Because that's what scrollpane.getHeight() / origIcon.getImage().getHeight(scrollpane) returns, due to integer datatypes.
I don't know Java, but I expect you could do something like:
percent = scrollpane.getHeight();
percent = percent / origIcon.getImage().getHeight(scrollpane);
|
|
|
|
 |
well that gives me an idea.. casting should do the trick
Thanks
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.
- Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
|
|
|
|
|
 |
thank you very much it works
- Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.
- Most of the problem in your life are due to two reasons: you act without thinking, or think without acting.
|
|
|
|
 |
Hello. Can anybody help me create a program that lets user input positive integers and exits if a negative integer is input? the program that outputs max,min, and average of the integers. i have tried to do it since a week and i am stuck in an infinite while loop :(
|
|
|
|
 |
If you show the code* that is failing then people will try to help you.
*Please ensure your code is formatted between <pre lang="java"></pre> tags so it is readable.
|
|
|
|
 |
Richard MacCutchan wrote: If you show the code* that is failing He did. In the Quick Answers post that was then closed because it was flagged as a duplicate.
/ravi
|
|
|
|
 |
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("Enter a positive integer");
int userinput=in.nextInt();
int maxer=0;
int miner=0;
int sum=0;
int counter=1;
if(maxer<userinput){
maxer=userinput;
counter++;
sum=sum+userinput;
}
if(miner>userinput){
miner=userinput;
counter++;
sum=sum+userinput;
}
int avg= sum/counter;
System.out.println("Your maximum integer is "+maxer);
System.out.println("Your minimum integer is "+miner);
System.out.println("Your average is "+avg);
}
}
This is my code here
|
|
|
|
 |
One of the problems with this code is there's no loop present; so the summing and min/max computation (which may not be correct anyway) will only execute once. You may want to use a construct like this:
do {
get user input;
if (input is not negative) {
compute new min/max;
compute sum;
}
while (input is not negative);
display results;
/ravi
|
|
|
|
 |
but how do i write input is not negative in code?
i am in new in java so i am still not aware of the syntax.
|
|
|
|
|
 |
can u plz tell how many integers do u want to take in program? for max,min and average?
|
|
|
|
|
 |
i wanna make a class in JComponent library in the following way :
class HelloComponent extends JComponent {
but the "JComponent cannot be resolved to a type" message would show up . any idea ?
|
|
|
|
 |
You need to show a bit more of your code and the actual line that the message occurs on. Did you import the JComponent definition?
|
|
|
|
 |
Eclipse can't find the type JComponent
What kind of JComponent is it? What kind of GUI are you creating?
That name is used way to.
regards Torsten
I never finish anyth...
|
|
|
|
 |
I have a task at hand for designing persistence layer for an application that should be generic. It is kind of application that will provide infrastructure for doing activities.I need help regarding how should my approach be towards it . Persistence can be through either XML or through database or through configuration files. Please provide me points to keep in mind as well as any special design considerations I should be aware of.
|
|
|
|
|
 |
Hello! Can you please help me with this kind of scenario
"I have Jtable with contents and checkbox every row
and my checkbox outside is the Select All function to select the content inside of my table"
I dont know the method of it but i have already my code in JTable, i just want to add it to my application.
Any article or sample code?
Thanks in advance!!!
|
|
|
|
 |
on checkbox action -> get Entries from TableModel, edit each entry.
Where is the problem?
|
|
|
|
 |
Thanks
|
|
|
|
 |
This is the code of my table
I have to column but the value is repeating.
public class TableContent extends JFrame{
final TableConstruct constructTable = new TableConstruct();
JMenuBar menuBar = new JMenuBar();
JMenu File = new JMenu("File");
JMenuItem openFile = new JMenuItem("Open File");
public static void main(String []args)
{
EventQueue.invokeLater(new Runnable(){
public void run(){
new TableContent();
}
});
}
public TableContent() {
setSize(500, 500);
setTitle("Create Table");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
setVisible(true);
setJMenuBar(menuBar);
menuBar.add(File);
File.add(openFile);
openFile.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent event) {
JFileChooser fileChooser= new JFileChooser();
fileChooser.setMultiSelectionEnabled(true);
int result = fileChooser.showOpenDialog(TableContent.this);
if(result==JFileChooser.APPROVE_OPTION)
{
File file[];
file = fileChooser.getSelectedFiles();
Vector addData = new Vector();
for(int i =0; i<file.length;i++)
{
String name = file[i].getName();
long bytes = file[i].length();
long kilobytes = (bytes / 1024);
addData.add(name);
addData.add(kilobytes+"KB");
constructTable.addRow(addData);
}
}
}
});
JTable table = new JTable(constructTable);
JScrollPane scrollPane = new JScrollPane(table);
getContentPane().add(scrollPane, BorderLayout.CENTER);
}
class TableConstruct extends AbstractTableModel{
Vector DataResult = new Vector();
String[] filenames;
private String[]columnNames ={"Name","Size"};
@Override
public int getColumnCount() {
return 2;
}
public void addRow(Vector addData) {
DataResult.addElement(addData);
fireTableDataChanged();
}
@Override
public int getRowCount() {
return DataResult.size();
}
@Override
public Object getValueAt(int row, int column) {
return DataResult.elementAt(row);
}
public String getColumnName(int column)
{
return columnNames[column];
}
public void setValueAt(){
}
}
}
|
|
|
|
 |
Member 11144357 wrote: I have to column but the value is repeating. What columns, what values, where is it repeating?
|
|
|
|
 |
I mean, I have two columns and the values inside is repeating or the same. As you can see in my codes, i put a vector that holds in my selected file and i want the value of it print in the table.
I want my output example in the console:
System.out.print(name+"\t"+size);
but i got like this:
System.out.print(name+size+"\t"+name+size);
|
|
|
|
 |
You need to use your debugger to step into the following method of your TableConstruct class:
public void addRow(Vector addData) {
DataResult.addElement(addData);
fireTableDataChanged();
}
to see exactly what is happening.
|
|
|
|
 |
Thanks a lot!
I'm on it.
|
|
|
|
 |
Hi frnds, Wants to read a gz file(contains million lines) from bottom to top. plz help me.
Thanks in advance
|
|
|
|
|
 |
This is like a number guessing game. The computer generates a random number between 1 to 100. The user has one number like 53 in his mind. And the example goes like this
example:
computer:75(random number)
User:higher(input which says 75 is greater than the user guess 53)
Computer:38(almost half of the first generated random number)
User: lower
Computer:57(like 38+(38/2))
User:higher
I want to implement like that but the code i am using is generating the values more than 75(random number) and getting more number of guesses to the user.
The computer asks a series of questions to arrive at the number the user has in mind. The user can only
respond with “higher”, “lower” or “yes”.
The game ends when the user responds with “yes” or “end”.
Example:
Example:
Note:
The program should be written to arrive at the answer asking the least number of questions.
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Random;
public class NumberGuess
{
public static void main(String[] args) throws IOException
{
int max=0,min=0;
Random rand=new Random();
int ComputerNumber=rand.nextInt(100);
while(true)
{
System.out.println("Is the number:"+ComputerNumber);
System.out.println("Please give higher or lower or yes:");
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(input);
String value=reader.readLine();
String yes="yes",lower="lower",higher="higher";
int temp;
if(value.equals(yes))
{
System.exit(0);
}
if(value.equals(lower))
{
int temp1=ComputerNumber; temp=ComputerNumber+(rand.nextInt(ComputerNumber))+1;
ComputerNumber=temp;
System.out.println("New number:"+ComputerNumber);
}
if(higher.equals(value))
{
int temp1=(ComputerNumber%10)/2-10; int temp2=(ComputerNumber/10)*10;
temp=(ComputerNumber-rand.nextInt(ComputerNumber));
System.out.println(temp1);
System.out.println(temp2);
ComputerNumber=temp2+temp1+1;
System.out.println("New number:"+ComputerNumber);
}
} }}
modified 2-Jan-15 11:13am.
|
|
|
|
|
 |
Will you please help me with the logic to implement that program I tried something but it is wrong thank you
|
|
|
|
 |
Leela Krishna Yadav wrote: I tried something but it is wrong OK, but we cannot guess what that is supposed to mean. Please edit your question and explain exactly what is wrong, and what you need help with.
|
|
|
|
|
 |
You should use "binary chop", not random values. For each response you need to take half the distance between the current and previous guess. If the user says "higher" then add it to the guess, else subtract it. So the sequence for your values would be something like:
Computer : 75 User : chose 53
Lower
subtract half of 75 - 0 : 38 Higher
add half of 75 - 38 : 57 Lower
subtract half of 57 - 38 : 48 Higher
add half of 57 - 48 : 52 Higher
add half of 57 - 52 : 54 Lower
subtract half of 54 - 52 : 53 Correct!
|
|
|
|
 |
Thank you Richard for that help i really appreciate it
|
|
|
|
 |
i have created a jar to copy two files using Variable argument whichis working correctly
e.g java jar filecopy.jar file1 file2
i want to provide a -help option in this which will be like below and user must aware what he has to pass in arguments
e.g java jar filecopy.jar -help
how do i do this not getting any idea :new to java,urgent help required !!!!
modified 31-Dec-14 4:09am.
|
|
|
|
 |
You just add the code to check for "-help" as a filename, and branch to the code which displays the help.
|
|
|
|
 |
did you men alike this ...
public static void main(String[] args) {
String filename1 = args[0];
String filename2 = args[1];
if ((!(filename1.length() > 0)) || (!(filename2.length() > 0))) {
System.out
.println("please provide the foldername and string to be replaced ");
return;
}
if(args[0] == "help" )
{
System.out
.println("please run the utility as filecopy file1 file2");
}
can you edit it if wrong
|
|
|
|