32,204 Topics

Member Avatar for
Member Avatar for Razer13

[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(); …

Member Avatar for NormR1
0
135
Member Avatar for scheppy

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, …

Member Avatar for scheppy
0
141
Member Avatar for timmy568

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 { …

Member Avatar for timmy568
0
229
Member Avatar for Mr.BunyRabit

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 …

Member Avatar for stultuske
0
170
Member Avatar for syeda amna

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.

Member Avatar for mKorbel
0
2K
Member Avatar for kyriacos1986

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 …

Member Avatar for forkmartin
0
136
Member Avatar for thanatos1

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 …

0
115
Member Avatar for enterpise

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 …

Member Avatar for enterpise
0
199
Member Avatar for ThaiAmL

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 …

Member Avatar for ThaiAmL
0
998
Member Avatar for VinC

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 …

Member Avatar for DavidKroukamp
0
156
Member Avatar for connect2abhi

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

Member Avatar for DavidKroukamp
0
12K
Member Avatar for enterpise

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 …

Member Avatar for enterpise
0
155
Member Avatar for NIES
Member Avatar for sharathg.satya

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 …

Member Avatar for stultuske
0
183
Member Avatar for krejar

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; …

Member Avatar for krejar
0
186
Member Avatar for rahul.ch

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 …

Member Avatar for DavidKroukamp
0
241
Member Avatar for mortanto

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 …

Member Avatar for StephNicolaou
0
150
Member Avatar for stay_alive

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. …

Member Avatar for peter_budo
0
2K
Member Avatar for rahul.ch

[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 …

Member Avatar for rahul.ch
0
236
Member Avatar for ab_omid

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 = …

Member Avatar for ab_omid
0
291
Member Avatar for torkolort

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 …

Member Avatar for peter_budo
0
212
Member Avatar for Razer13

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?

Member Avatar for Razer13
0
202
Member Avatar for 47pirates

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 …

Member Avatar for 47pirates
0
181
Member Avatar for mohamed moamen

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 …

Member Avatar for mohamed moamen
0
112
Member Avatar for ajacintha

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 …

Member Avatar for ajacintha
0
115
Member Avatar for MeandJava

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 …

0
189
Member Avatar for Eragah

[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 …

Member Avatar for peter_budo
0
110
Member Avatar for hhheng

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 …

0
90
Member Avatar for rotten69

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 …

Member Avatar for rotten69
0
106
Member Avatar for moonstar3910

[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 …

Member Avatar for roxin_phoenix
0
122

The End.