35,618 Topics
![]() | |
how do i change the background to a custom one. code JButton button = new JButton(); JButton quit = new JButton(); public Mainmenu() { Icon b = new ImageIcon(getClass().getResource("play.jpg")); play = new JButton(playb); add(button,BorderLayout.CENTER); Icon quitb = new ImageIcon(getClass().getResource("quit.jpg")); quit = new JButton(quitb); add(quit,BorderLayout.SOUTH); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent … | |
I just started learning Java and I have been playing around with it. I am trying to make this program return a double value like 1000/3 = 333.33333..... but it returns 333.000 what am I doing wrong in Java. It works in C though :P. Thanks in Advance! //Exercise : … | |
public class arraChange { public static void main(String []args){ int arr [] = {2,3,4,5,6,7,8}; public class arrayCounter { public static void main(String args []){ Random rand = new Random(); int freq[] = new int [7]; considering the above two seperate lines of codes, i just want people to explain to … | |
please help me how to close the window. code: JButton quit = new JButton(); public Mainmenu() { setLayout(new FlowLayout()); Icon quitb = new ImageIcon(getClass().getResource("quit.jpg")); quit = new JButton(quitb); add(quit); quit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); | |
I need to get printed documents name and from which ip it is printed using java. | |
I am trying to develop the genetic algorithm to solve Traveling Saleman problem and part of my challenge is to generate random tours long enough and write a fitness function to evaluate the cost incurred for each of the random tour. I have attempted to write the following. My objective … | |
For example, How do I use this custom print method to display something in the main method? public static void print(Stack<String> myStack ) { int count = 1, sizeOfStack = myStack.size(); System.out.println("\nYour stack has size: " + myStack.size()); for (String myString : myStack) {System.out.print(count + ". " + myString); if(count!=sizeOfStack) … | |
Hi Dw I've recently created an application in java on this post:www.daniweb.com/software-development/java/threads/458306/how-to-work-with-jpos and now I just want to improve this by enabling a feature of mixing the cash notes when dispensing the required amount. The machine has these bills notes: 10, 20, 50, 100, and 200 so now what I … | |
I'm writing this code for one of my projects. can you please help me with line #6,#7 and #10? I'm not sure if I am writing the code for those correctly. package waffles; import java.util.Scanner; import java.util.Stack; /** * */ public class Waffles { /** * @param args the command … | |
package die.java; import java.util.Random; class DieGame2 { private final int sides; private final Random generator = new Random(); public DieGame2(int s) { sides = s; } public boolean throwDie() { int faceValue = generator.nextInt(sides) + 1; System.out.print(faceValue); return faceValue == 6; } public static void main(String[] args) { DieGame die1 … | |
Hi, Is there any java functions are availble to find mostly repeated characters in string ? Thanks | |
Hi. I am very new to hashtable concept. Here is a skeleton of the methods I need to implement; BUT, my biggest question is the inner Entry class. Am I implementing the entry class correctly?Is my constructor correct? Thanks public class HashTable<K, V> { /** define an inner class to … | |
Hello everybody i have a little problem with making a java command for program i have some code but i do not know how to continue i stuck in one place BTW the command i want to make is > /sendcash [username] [money] // how it looks like I have … | |
Basically I've created an **app drawer** and placed a **seekbar** within it. This app drawer is made up from **app_drawer.xml** whilst my fragment below is made up from **main_activity.xml**. The issue I'm having is, although the seekbar shows up perfectly and the app drawer pulls in and out as it … | |
I a software engineering student who took a Java course last semseter.But currenlty I'm self-studying Java for expanding my Java knowledge.The problem is that Java is a very vast programming language and I'm confused where to head next. I would say I'm on the intermediate level with regards to Java; … | |
Trtying to figure out how to add 5 different methods into this class when the program already does all that is required but my prof will knock me if I dont put them in here, do thet need to be put in as private? | |
i need good java eclipse tutorial iv'e watched theCherno,Thenewboston etc.i learned GUI,anonymousclass etc.i just need a good beginner tutorial on java eclipse. | |
Hello. I am working on this project and it asks me to make two columns of words that are ascending in one column and descending in the other. This is the Project: Call both your project and class AscendDescend. The first column should be in ascending order and the second … | |
i want code of Sorting techniques like insertion sort , merge sort , bubble sort , quick sort. i want their output in gui or in any animation form in any language like c , c# or java. can any one help me plz ?Any one sorting technique is ok. | |
pls help me to build an applet form merge sort for our project | |
Hi, I am trying to read a html page and convert into xml and copy the content into a txt file in the local drive. The code below is to read the html page: def cleaner = new HtmlCleaner() def node = cleaner.clean(address) // Convert from HTML to XML def … | |
Hi Im new to learning java so far ive picked up the basics of it but now im trying to create a first and best fit algorithm for the purpose of memory managment now my question is what to i specifcally need to learn to be able to to this … | |
Hi, I'm trying to use the replace() method to take out all instances of " " , (space) with an underscore, ("_"). I'm doing this because I'm using URLs to connect to a servlet. I keep getting this error: [code] replace(char,char) in java.lang.String cannot be applied to (java.lang.String,java.lang.String) url.replace(" ", … | |
how to upload and display profile picture using jsp and servelet. | |
Hi All, i am here with a problem in file handling in java. i need to search all the files on system with extention *.fdr. which are not less den one day old. then i need to convert the selected file to csv which is perfomed by a command in … | |
I recently started coding in Java and have been trying to use the native methods to link code from other languages like C and C++. My code for the file is: [code=java] public class NativeDemo { int i; public static void main(String args[]) { NativeDemo ob = new NativeDemo(); ob.i … | |
Hi everyone I need a suggestion on detecting the faults/bugs in a java program. To say I should check whether my program is faultless. Thanks, Varun Krishna. P | |
import java.util.Scanner; import java.lang.Math; public class Exercise1 { public static void main(String[] args){ double x,sum = 0.0 ; Scanner scan = new Scanner(System.in); System.out.print("Enter the number : "); x = scan.nextInt(); for(double i=0;i<=(x+1);i++){ Math.pow(x, i); fact(i); double y = (Math.pow(x, i)/fact(i)); sum += y; } System.out.println("The e^"+x+" for "+x+" is … | |
I have problem with Java session. I have a TplanServlet where I request values from html form and I am going to create Monday object with createMonday(). So I pass my form to this sevlet if (option.equalsIgnoreCase("createMonday")) { String title = request.getParameter("tpName"); String g1 = request.getParameter("g1"); String a1 = request.getParameter("a1"); … | |
I have UDP socket as below. I need to send back data to the client. I tried to capture both the ip and port but it shows me as Port is : -1 and InetAddress : null. What can I do to rectify on this? class ReceiverThread implements Runnable { … |
The End.