32,204 Topics
| |
[CODE]public JLabel SetImage(String path) throws IOException { ImageIcon myPicture = new ImageIcon(path);//ImageIO.read(new File(path)); JLabel picLabel = new JLabel(); picLabel.setBounds(0, 0, 2, 2); picLabel.setIcon(myPicture); pnlImage.setLayout(null); pnlImage.add(picLabel); pnlImage.repaint(); pnlImage.revalidate(); return picLabel; } try { String Ref = txtRef.getText(); SetImage(); JLabel label = new JLabel(); label = SetImage("C:\\Users\\Documents"); App\\ImagesDoc_001.jpg"); pnlImage.setLayout(null); pnlImage.add(label); pnlImage.repaint(); pnlImage.revalidate(); … | |
Hi all I'm wondering how i add Action listener to this Button It has no text, just an image, from an ImageIcon I tried I3 for the action listener but i doesant work [CODE] ImageIcon I3; I3 = new ImageIcon ("carrier.gif"); J1 = new JButton (I3); J1.addActionListener (this); J1.setBounds (420, … | |
| Hi guys, I was doing my project when i came across this error: Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:686) at Screen.screenRunner(Screen.java:84) at Screen.main(Screen.java:90) I am also having problems getting my program to accept user input(height and width). [CODE]import java.util.Scanner; public class Screen { … |
hey there. Im using Netbeans. i have a form where there is a button edit. when i press it, other form opens, and the selected item on the previous page has to be edited in the databse. So bottom line, i have to get a String / int that i … | |
hi What is the difference between in JFrame and JWindow? If I want to develop a a desktop application either I have to use JWindow or JFrame. | |
When I run the following lines of code the following erroe from the compiler is displayed [CODE]cannot find symbol - method start()[/CODE] CODE: [CODE]import java.lang.Thread; import java.util.concurrent.*; public class MyThread { public static final int MAX = 15; private String message; /** * Constructor with parameters * * @param message … | |
Hey guys, i've been spending some time writing a pokemon clone game in java and was wondering if anyone would like to help me out, it's quite a big project since i'm planning on making it much more than a simple clone, but if you'd like to perhaps help out … | |
i have programming assignment which is to make UDP and TCP client now i already finished UDP ,TCP client and GUI now i want to make the command line class So the assignment tell me that "CLIENT: The client should read input from the command line: • -x <number>, where … | |
Hello! I'm studying right now as an exchange student in Germany and taking my first programming course in Java, and in the last week, things have just started to go over my head and I'm kind of drowning while trying to get all the homework done! The assignment was supposed … | |
I'm been working through my textbook and just can't seem to understand the section on covariant return types. ie) what are covariant return types, what they are used for, etc. The definition in the book is as follows. [QUOTE]An overridden method in a derived class can return a type derived … | |
Hi Can any one tell me how to call a subclass method from a superclass? For example: I have a class A,B and C. Now B and C extends A. So is there any way that we can call a method of B in A? Thanks Abhishek | |
now i'm try to make the delete and successor method for BST in java[CODE]public void delete(BinarySearchTree<V> pointer) { // 1. The node is a leaf. // 2. The node has no left child. // 3. The node has no right child. // 4. The node has two children. BinarySearchTree<V> current … | |
hi all i am facing a problem with the below code i used keylistener so that when i click letter 'v' the program has to exit. But the following code is not working. Help me please.. i think we should add listener to the code but how to add listener … | |
| I think my issue is in line 18. The program runs just fine, but my answer isn't correct when I enter a radius and height. Not sure what I am doing wrong here. [CODE]import java.util.Scanner; import java.text.DecimalFormat; public class ConeA { public static void main (String[] args) { double surface; … |
A snippet: package com.deitel.jhtp7.ch14; public class AccountRecord { ..... Doubt: 1. What does the above package statement imply. As in how(path) this AccountRecord.java will be stored? As in what folder hierarchy should I create? 2. In Command prompt I have set my Current Directory as : E:\RDL\Dropbox\Coding\Core Java\File So will … | |
I wouldn't normally ask for help like this but im getting quite desperate. I really need help with a java assignment that I'm really struggling with (I haven't done any coding in over 2 years so lost just about any knowledge i had) the assignment needs to have a collection … | |
Well hello, i'm about to start my little app. The only task i want it to perform is a left mouse click on a button on the browser, IE, Firefox, Safari... I wonder if this can be done as the click will be performed outside the program window or frame. … | |
[code]public class StringBuilderConstructors { public static void main(String args[]) { StringBuilder sb3 = new StringBuilder("hello"); System.out.printf("buffer3 = %s\n", sb3.toString()); //written in textbook System.out.printf(sb3); //i tried System.out.println("buffer3=" + sb3); // i tried }} o/p: buffer3 = hello hello buffer3=hello[/code] doubt: The book says toString() gives the string representation an object. That … | |
hi i want to use hibernate in java+postgresql but when i run it receive NullPointerException [code]import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.postgresql.Driver; public class FirstExample { public static void main(String[] args) { Session session = null; try{ SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory(); session =sessionFactory.openSession(); Transaction tx = … | |
I'm creating a small java program that use some special graphics to draw a picture to a certain format. The program will be run as a jar file, and needs some graphics definitions as arguments at initiation. These definitions exist in a small C# class, and should contain only small … | |
Hi, I have been trying to look for some code to add a comment box where people can add or delete comments in my program when viewing items any ideas pls? | |
Hello guys i'm trying to send data to same socket at different times from different java classes. I can easily send the data from one class but after logging in when i try to send data to same socket from another java class ,there is an error. suggest me some … | |
i'm use Netbeans i create JframForm and add a panel to it ,and create new jpanel and add components to it like buttons & textboxs ,finally I'm add the panel 2 to panel 1 but the components of panel 2 not appear and their is no errors. "how i add … | |
Hi, I am working on a tool where the user on click of the button opens a URI, takes screen shot and copies the image in a word document and sends the report to list of users. Im now working on invoking a URI from Java application, I am successful … | |
Hello everybody, I'm trying to make a connection between my mobile and my pc. Im using J2me midp 2.0 to create my code. The jar of my mobile wants to make a connection to the bluetoothaddress of my pc. My mobilecode is based on a MIDlet. But everytime the connection … | |
[B]Hi i wanted to know how to implement a checking system so that whenever my program randomizes a horse it will always be unique. Thanks![/B] [ICODE]import java.util.Scanner; public class Horses { public static void main(String args[]) { String[][] horses = {{"Black ","White ","Gray ","Old ","Young ", "Pink ","Yellow ","Brown ","Orange … | |
Newbie questions. I laid out the controls in shell by GridLayout(2, false). And when user click a checkbox, I wantto to hide one or several lines. I tried to set the exclude to true, and set the control in that line GridData(0, 0) to hide those lines. However there were … | |
G'day everyone, I'm doing at a tutorial on Oracle website and still following it so far. I have come across this formatter "%,8d" and can't seem to work out how it works. I know it's adding a coma to the integral number. The thing that I can get my head … | |
[CODE]import javax.swing.*; import javax.swing.border.*; import java.awt.*; public class ConnectFour { // the grid used for storing the game layout. private int[] [] grid; // the player whose turn it is. private int currentPlayer; public ConnectFour () { // create the grid grid = new int [7] [6]; // initialize the … |
The End.