35,618 Topics

Member Avatar for
Member Avatar for easyscript

Am trying to draw image on jpanel or jlabel when button is been click on, so i added actionperformed on my button as follows. private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: Image imag = new ImageIcon(this.getClass().getResource("img/top_bg.jpg")).getImage(); showPix1.setLayout(new BorderLayout()); showPix1.add(new paintPhotos(imag,20,20), BorderLayout.CENTER); } I have a …

Member Avatar for mKorbel
0
826
Member Avatar for rahul.ch

StringBuffer sb = new StringBuffer(new String("Hello")); //Case 1 StringBuffer sb1; //Case 2 String s = new String("Hello"); // Case 2 sb1=s; //Case 2 StringBuffer sb3; //Case 3 sb3 = new String("Hello");//Case 3 Case 1 compiles fine and outputs *Hello* but Case 2 and Case 3 gives compiler error saying incompatible …

Member Avatar for rahul.ch
0
198
Member Avatar for rssk
Member Avatar for stultuske
0
128
Member Avatar for hwoarang69

so i know japplet, jframe, jdialog, jwindow, jpanel windows to create gui. japplet = you use japplet for website with no resizeable or main buttons jframe = ??? ... try to explain as much as you can. i want to know adv and dis of these window.

Member Avatar for jalpesh_007
0
190
Member Avatar for jack_hehe

`** # I know it should be written that : ArrayList ar = new ArrayList(); while(rs.next){ int mxtype = rs.getInt("mxtype"); } int mxtypes[] = ar.toArray();//here will be point out ,need to convert to ...... # **`

Member Avatar for jalpesh_007
0
144
Member Avatar for Jlearner

My logic for run background music when click button. b.addActionListener(new ActionListener(){ public void actionPerformed(ActionEvent e) { ContinuousAudioDataStream loop=null; AudioPlayer mgp=AudioPlayer.player; try{ AudioStream bgm=new AudioStream(new FileInputStream("C:/Users/Public/Music/Sample Music/Sleep Away.mp3")); AudioData md=bgm.getData(); loop=new ContinuousAudioDataStream(md); } catch(IOException ex){ } mgp.start(loop); loop=null; } }); Hello EveryOne, I am new to Java and creating a small …

Member Avatar for harinath_2007
0
289
Member Avatar for capt_nemo

I am writing a java netbeans platform application that alerts end users when certain dates, conditions are met, etc... So I want to give the option when the end user installs the program of whether or not the program starts when they log into the computer or not. I also …

Member Avatar for capt_nemo
0
187
Member Avatar for cmps

Hello!!! mmm am learning OOP in Java ... and now I'm facing a prob in reading/writing .txt file here's my code: import java.util.Scanner; import java.util.Formatter; import java.io.File; import java.io.FileNotFoundException; public class Tester { public static void main(String[] args) { Scanner scan = null; Formatter formatter = null; File fileI; File …

Member Avatar for cmps
0
2K
Member Avatar for deadsolo

Hi, I am currently working on a script that will compare two numbers from a file. I am thinking that I need to use a regular expression in order to get the numbers, however I don't know what the regex would be since there are multiple numbers through out the …

Member Avatar for deadsolo
0
297
Member Avatar for MegaBigBigYo

Hi all - I am having a little trouble getting going on the methods for this assignment. I need to use a method which passes a Scanner as the object to create an array that is the correct size, but has null values. It reads in a file which contains …

Member Avatar for MegaBigBigYo
0
189
Member Avatar for cmh0114

For part of my project, I need to write a piece of code that will perform a task (beeping) once per second for ten seconds. I found this code online and tried to modify it to fit my needs, but I couldn't seem to get it. This code doesn't beep, …

Member Avatar for JamesCherrill
0
854
Member Avatar for somjit{}

this code is my attempt at modifying a simple game i found in the book "head first java".. (pg-98 if anyone's interested) the game is about sinking battleships! ... actually... its just about declaring some blocks of a virtual array to comprise a battleship, and the user makes guesses about …

Member Avatar for JamesCherrill
0
238
Member Avatar for Kronolynx

I wrote this program, when i run it, everything seems to work ok, but in the eclipse console i get a long list of errors, what is wrong with my program and how should i fix it? thanks import java.applet.Applet; import java.awt.Color; import java.awt.Graphics; import java.awt.List; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; …

Member Avatar for Kronolynx
0
269
Member Avatar for gourav_rao

1. need to read details of customer in a Account class 2. need to inheritence Account class to define a method for fixed deposit & saving deposit in main class i have to just call all this class pls help ....

Member Avatar for JamesCherrill
0
83
Member Avatar for Shanti C
Member Avatar for agca

Hi, what is the best way to provide followings? 1) Server Client sides 2) File serving by client request 3) Streaming by segments with iteration sample code also please.

Member Avatar for JamesCherrill
-2
183
Member Avatar for engrjawad

What is a flag in java? when do we need it in our program? what it is used for?

Member Avatar for jalpesh_007
0
184
Member Avatar for jg1405

Thanks for the support! I have been working on a program with 7 classes, one the main and one starts the program, and I have been troubleshooting for a few hours trying to see why for one of the output constructors I'm not getting the classes to update the output. …

Member Avatar for Taywin
0
193
Member Avatar for hwoarang69

note i want to do this code in background class. not in main class. so i have a main class and a background class. getting error at url = getDocumentBase(); also getting error at getImage drawImage background class import java.awt.Color; import java.awt.Graphics; import java.awt.Image; import java.awt.Rectangle; import java.net.URL; //#2 public …

Member Avatar for JamesCherrill
0
113
Member Avatar for lo0lo0999

import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Bank1 extends JFrame { private JLabel l1; private JLabel l2; private JTextField t1; private JPasswordField p1; private JButton b1; public Bank1() { super("Bank System"); Container container = getContentPane(); container.setLayout(new FlowLayout()); l1=new JLabel(" ID :- "); container.add(l1); t1=new JTextField(25); container.add(t1); l2=new JLabel(" Password …

Member Avatar for mKorbel
0
216
Member Avatar for JamesCherrill

Like me you may be curious about the "closures" or "lambda expressions" that were supposed to be in Java 7 and are now the centre-piece of Java 8 (due next year). Also like me you may have Googled for some info, and discovered a smattering of technical articles explaining the …

Member Avatar for JamesCherrill
0
169
Member Avatar for hacker260

i need help finish this program for an assignment, It should play the Rock, Paper, Scissors game. The nextPlay methoded needs to be filled in with nested switches. thanks for your help import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Rps extends JFrame implements ActionListener { private final char moves[] …

Member Avatar for stultuske
0
303
Member Avatar for hwoarang69

note x = player x postion y = player y postion so iam trying to set up collsion between player and enemy. i want it so my player touch the enemy than my player should stop. and not go though it. this code below kind of works. if my player …

Member Avatar for JamesCherrill
0
317
Member Avatar for Goldfinch

I was trying to building a java project with a run function. Problem is, the build file is located at the base directory and file with the main method is in the /contents/username/ subdirectory - I can't seem to properly call the file even though when I run Ant compile, …

Member Avatar for Goldfinch
0
172
Member Avatar for kedxu

I have two classes: (1) **Class A**, which extends JApplet, implements Runnable + some Listener stuff (2) **Class B**, which has a main method and is not an applet My question is, how do I create **class A** with **class B**'s main method? Is this even possible? What I'm doing …

Member Avatar for kedxu
0
253
Member Avatar for renzlo

Hi, Jim and All, How do you handle a java applet in a webbrowser control? It seems that no event fires up when a java applet is loaded in webbrowser control, by the way, the applet is in full screen and this is a company applet, meaning I did not …

Member Avatar for renzlo
0
163
Member Avatar for Amiro

**I am doing a mini project, I need help with how I can store the scores in an array. ** import javax.swing.*; // import the swing library for I/O class fi_project { public static void main (String[] param) { questionfilm(); System.exit(0); } // END main //************************************************************ public static void questionfilm() …

Member Avatar for JamesCherrill
0
226
Member Avatar for forjustincase

Today , i came across this code class Something { public static void main(String[] args) { try { System.out.println("In try block"); return ; } catch(Exception e){ System.out.println("Hello World in catch!"); } finally { System.out.println("Hello World in finally!"); } } } Now can anyone tell me the output with reason plz... …

Member Avatar for JamesCherrill
0
95
Member Avatar for trd360

The instructions are long but here goes. The starting code they provided me is after the instructions. The bar codes used on products in a store are visual encodings of Universal Product Code (UPC) numbers. For example, 036000291452 is a UPC code (in this case for a box of tissues). …

Member Avatar for ken_taiken
0
356
Member Avatar for forjustincase

ok here's what i am trying to do. i ask user for a value or just assign a value my self for example int a=150; now i want the output like this: 1 5 0 so is this possible?? please use simple programming i guess it can be done with …

Member Avatar for JamesCherrill
0
261

The End.