36,051 Topics
![]() | |
Hey I'm trying to add pairs of numbers into an array by placing them into objects then putting the objects into the arrays but I seem to be having a problem with some part of my code. When I run the following example I just get the following back : … | |
All, I wonder if anyone has an opinion on this. What's better, this: // Diagonal checks if (board[0][0] == turn) { if (board[1][1] == turn) { if (board[2][2] == turn) { System.out.println(); System.out.println(turn + " IS THE WINNER!!!"); writeBoard(); return true; } } } Or this: // Diagonal checks if … | |
public class Numberpyramid { public static void main(String[] args) { int x = 9; for (int i =1; i<=x; i++){ for (int j =1; j<=x-i; j++) { System.out.print(" "); } for (int k=i; k>=1; k--) { System.out.print((k>=10)?+k:" "+k); } for(int k=2; k<=i; k++) { System.out.print((k>=10)?+k:" "+k); } System.out.println(" "); } … | |
Help, I'm trying to get which object has the greater area of the 3 triangles. Also want to print out the info for each triangle object by calling toString(). If any one would check my work I have done if for any change I need it. Thank you. // testerTriangle … | |
I am trying to call two methods from another class which is linked to the current class i am working in. basically if it is a left-button click from the mouse, i want to call the addCounter method (of the myAbacus object). If it is a right button click, i … | |
i am new in Java. i would like to know how to find the nth root of any positive number using recursion. Is there any way i can do this without using math.pow()? | |
I am trying to use a simple println(...) statement to display the value of a variable from a separate class. The two separate classes are linked. AbacusModel class has an array 'peg_array' which stores the number of counters present in each of the elements of the array. AbacusModel has a … | |
i have problem when i am accessing package of different directory. can we access a package in a single java file that are lies in two different drive/directories? Eg. My one package p1 is in d:/ having class abc.java My another package p2 is in e:/ having class pqr.java can … | |
how to install jdbc driver for mysql java connector | |
I have two question in my mind. can we create java file having two classes and both have main methods? is it possible or not? why? if possible then we have to save it with which class name? and one more question is: `BufferedReader br = new InputStreamReader(new FileInputStream(new File("abc.txt")));` … | |
I have .exe file called Myapp.exe.. Now i want to convert .exe to jar file.. That jar file should work in non java system also? I dont have any idea to implement it.. Can anyone plz suggest me how to do it? Thanks in advance.. | |
I have seen many questions on autocompeletion for *java text components* like `JTextField` `JTextArea` `JTextEditorPane` etc. There are not many options either: 1) 3rd party library (like SwingX) 2) DIY (i.e using `DocumentListener`, `JWindow` with `JLabel` etc and a few requestFocusInWindow calls) I chose number 2 and put the code … | |
Hi everyone, I have made a desktop application in NetBeans IDE 7.3. In the dist folder ,there is my project's executable jar file. But by double clicking it is not opening. Can anybody make suggestions about it, Thanks in advance | |
Hello, I am new in trying to figure out how to use two classes together. One class is called circle, and is supposed to hold attributes of radius and area. It is also supposed to have the methods of print and computeArea. public class Circle { //global data private double … | |
hello i have problem with sending emails i have good SMTP and port but the message cant be sendend gives me this error: Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1 and here is the code: final String username = "stefanrafaa@gmail.com"; … | |
Hi, I am having a problem overriding methods in a subclass when they contain private methods from the master class. The is the master: package blabla; public class Person { private String firstName; private String secondName; private String familyName; public Person() { firstName = ""; secondName = ""; familyName = … | |
I have the following code which is in a class called customerModel. How do I call this method to another method inside another class called customerController? I am abit new to this and have been trying for ages but have had no luck. Please help thank you. public class customerModel{ … | |
Hey Lads, I Have a problem involving my save method , basically i want it to actually save a file which is of type JTable UnFortunetly its not , a Push in the right direction would be great. save.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e){ JFileChooser fc = new JFileChooser(); int … | |
i wanna send a username and password securely from php page(Apache server) to the Java api (Tomcat server). That api should verify them and open the api in the browser. How can i achieve it guys??? I tried to use webservice but the response from the api is sent to … | |
Base on my understand a mediator is a central authority that varies the interaction between objects in the same group. So can I classify the code below as a mediator? package com.mediator; public class BaseMediator { public void store(){ System.out.println("store"); } public void retrieve(){ System.out.println("retrieve"); } } package com.mediator; public … | |
Hi frnds, I am developing a struts2 project, I do require how to multiply to variable using struts tag ... I tried with this code below, <s:set var="total" value="var1" /> <s:set var="tot" value="%{var2 * #attr.total}"></s:set> <s:property value="%{'' + #attr.total}"/> AM getting the output as 0.0 .. Please any help ... ![]() | |
package pkg2.pkg3; import java.io.*; import java.util.logging.Level; import java.util.logging.Logger; class pachet { double adresaS; double adresaC; String com; String raspuns; pachet(double adrS, double adrC, String c, String r) { adresaS = adrS; adresaC = adrC; com = c; raspuns = r; } } class Client extends Thread { pachet p; double … | |
A temperature converter GUI. Converts from Celsius to Fahrenheit and vise versa. Tests JLabels, JButtons and JTextFields. *Two separate programs, Converter and Thermometer (Thermometer Class)* | |
Write in pseudocode the algorithm for determining the average value of an UNSORTED array of numbers, given an array of "a" with number of elements that have a value "length". Additionally, what is its order in Big-O? If the array of numbers were ordered, can the algorithm change? If so, … | |
I have an jar called Myapp.jar.. It is working fine in java installed system.. And my task is to Bundle jre inside jar(Not along with jar(i.e we can put jre and jar in same folder to run a jar as given in following url http://www.mindfiresolutions.com/Run-jar-without-jre-on-windows-machine-76.php )). and I should not … | |
Actually i've a page named(vehicle.php) inside apache server and Java api page (someheader://someip:someport/track/Track?page=map.fleet) inside tomcat server. I created a Restful Webservice in PHP using this link "http://viralpatel.net/blogs/restful-web-service-tutorial-introduction-rest-restful/" And then i sent a username and password from apache server to the java api through webservice, it sends the request correctly and … | |
I have created two socket file,But it is not working in proper way. please let meknow where the porblem is. TCPClient.java import java.io.*; import java.net.*; class TCPClient { public static void main(String ar[]) throws Exception { String fromserver; String toserver; Socket clientsocket=new Socket("localhost",10000); BufferedReader infromuser=new BufferedReader(new InputStreamReader(System.in)); PrintWriter outtoserver=new PrintWriter(clientsocket.getOutputStream(),true); … | |
dear all, I will stuck with one problem.I have one java program in which frame will be there. I am fetching some data from database and i am selecting background image from dialogbox. Now i have used BuffereImage class, i want to print that image with text through the printer. … | |
I want to compare between nodes in BST to find the highest salary and im using recursion function in implementing my BST. Below is the question: A company needs to keep all records of its employees. Employee record should contain employee id(4 digit integer numbers), name, department, salary and an … | |
Hi.. My java desktop application runs every time the computer starts up and runs as long as computer is ON. It monitors all the activities and interacts with database more often and will tell me some updates by looking on the internet at regular intervals etc..etc.. So what I usuallly … | |
how assign a none static var to a static var in Java/Android? String top5=scoreSaveReturn2(this.x); public static String totalPoints3;//=top5; CannonGame.totalPoints3=top5; // gives error here In a Canvas game if we have a class like: public class CannonView extends SurfaceView implements SurfaceHolder.Callback how transfer from this a var value to this public … | |
Hello, I'm having an issue with set and get method. When i clicked on a button, i set index as 1 however when i use the get method to get the index, the index is returned as 0. I want to call a method if the index is 1. here … | |
i have to create a queue where the dequeue operations will be random. that is , a random location will be chosen, and deleted after returning the data stored at that location. i was going through the two underlying datastructures that im allowed to use **:** linked list , and … | |
Hi, I've been trying to send a `BufferedImage` through a socket. I can get it to work once, but when I try to get another screenshot, it fails. The server usually gives me a `java.lang.IndexOutOfBoundsException` at `ImageIO.write(capture, "png", client.getOutputStream());` Server Code: //already told server i'm expecting an image try { … | |
I'm learning about threads and Producer-Consumer model . I haved copy-paste the code from a book and i have a issue. When I run the program sometimes the Consumer gets the next number from the buffer even if the producer hasn't put nothing in the buffer. Example : Producatorul a … | |
I am making an ABACUS MODEL program which adds counters to pegs. The program compiles fine but when i use the test that was issued to me (as pictured) it appears as though my program does not work as intended. I don't know if anyone will be able to help … | |
The above code computes the value of a mathematical expression supplied at command line by using the concept of converting infix to postfix,then evaluating the postfix expression. Any comments are appreciated. | |
Here's a simple thing that I can't find a simple solution for - so any suggestions will be very welcome... I have a `Map<String, MyClass>` and if it has more than 1 entry I let the user pick a MyClass instance by displaying the keys. No problem there. If it … | |
hello i want to stop the music after pressing other song i tryed much different ways of doing it but no results please anyone help me i have this code ... package passwordsaver1; import java.awt.Dimension; import java.awt.Toolkit; import java.net.URL; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Clip; import javax.swing.JOptionPane; /** * * … | |
Hello generous java coders!I am really in a desperate situation now. I have a working gui code here: import java.awt.event.*; import java.awt.*; import javax.swing.*; public class CountdownTimer extends JFrame { JLabel promptLabel, timerLabel; int counter; JTextField tf; JButton button; Timer timer; public CountdownTimer() { setLayout(new GridLayout(2, 2, 5, 5)); promptLabel … | |
| |
basically i am working on a project for uni, which is to create a form of an abacus model. - peg_array[] stores the number of counters/beads present in each of the pegs(lines) of the abacus. i am trying to use 2 boolean methods: "boolean removeCounter(int thisPeg)" "boolean removeCounter(int thisPeg)" thisPeg … | |
Hi I am trying to write a binary search function to search for a specific character in a character array sorted in ascending order. Whenever I run the code though nothing happens, there are no errors or anything, just nothing happpens until I terminate the program myself. Below is my … | |
I'm going through a netbeans tutorial on Java ecommerce located here: http://netbeans.org/kb/docs/javaee/ecommerce/setup-dev-environ.html When I get to "running the web project, step 1", I click the green run button in the NetBeans IDE. In my browser, it goes to http://localhost:8080/AffableBean, but no HTML is displayed. If I view the admin domain … ![]() | |
Hello, well this suddenly surprised me .. dunno why ... i was trying to solve the binary-tree implementation ... where i noticed using root.left = new node bla bla My question insert(Node root,int value) root.left = new node(null null value) Etc ... The function doesnt create a copy of the … | |
Hello i am trying to use cookie at my site. I used this code for set the cookie try{ Cookie cookie1 = new Cookie("thesiteid", Integer.toString(site_id)); cookie1.setDomain("localhost"); cookie1.setPath("/"); cookie1.setMaxAge(24*60*60*365); response.addCookie(cookie1); System.err.println("Set cookie"); } catch (Exception e){ System.err.println("Error in creating the cookie: "+e.getMessage()); } The problem is that is not working at … | |
import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Burger extends JFrame implements ActionListener { JLabel lblForAll, lblBelow, pic, pic1, pic2, pic3, pic4, pic5, pic6, pic7; JRadioButton rBtn, rBtn1, rBtn2, rBtn3; JCheckBox cBtn, cBtn1, cBtn2, cBtn3; JTextField txt, txt1, txt2, txt3, txt4, txt5; JButton btn1, btn2; ButtonGroup btnG; int ham=25, egg=15, … | |
pls help me the coding.. | |
can i change toggle button's state to another (play state to pause),by clicking another button(stop) | |
any one help me???????????????????????????????? how to convert text file to kml file using java??? |
The End.