- Upvotes Received
- 2
- Posts with Upvotes
- 2
- Upvoting Members
- 2
- Downvotes Received
- 0
- Posts with Downvotes
- 0
- Downvoting Members
- 0
22 Posted Topics
Hello Members, I have a basic java question about non-terminating float values: public class FloatandDouble { public static void main(String args[]){ float a = 1.0f/3.0f; System.out.println (a); System.out.println (b); } } The output of the program is 0.33333334. Why is it not 0.33333333? Thank you | |
Hello, The program below has two JPanels. The first JPanel, panel contains the labels, buttons and combobox. The second JPanel, panel_1 has the image.I am using BoxLayout to line up the belows vertically. The issue I am having is when I run the program, the compoments of the panel do … | |
Hello, In the following programs, I am trying to add multiple clients. The Client program remains unchanged. For the Server program, I am using a thread (custom class implements the Runnable interface) to open a new socket and process every client request. My questions follow the programs. **ChatServer.java:** import java.net.*; … | |
Hello, I am trying to display text(JLabel) above a 3 x3 tic tac toe grid. The JLabel is not displayed. Only the grid shows up. I would be grateful for any help. Thank you! import java.awt.*; import javax.swing.*; import java.applet.Applet; public class Game extends JApplet { LayoutManager layout; private JPanel … | |
Hello, I am trying to learn how to use the JGrapht API and a sample program on the web has the following line on how to create a SimpleGraph: SimpleGraph graph = new SimpleGraph<String, DefaultEdge>(DefaultEdge.class); The above line is clear execpt for the "DefaultEdge.class" in the parenthesis. What's the significance … | |
Hello, As per wikipedia, a complete binary search tree is defined as: A complete binary tree is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible Can someone give me an application of complete binary trees … | |
Hello, I am trying to understand what a byte array is. public class ByteArrayExample { public static void main (String args[]) { byte[] array = "1".getBytes(); System.out.println (array); } } The output of this program is : [B@44770739 Is this a hexadecimal representation? If any of the members can explain … | |
Hello, I have a class (Buttons.java) which inherits from JButton and implements the ActionListener interface. The second file (ButtonsTest.java) creates a GridLayout of Buttons and adds them to the applet. The issue I am having is when I click on any of these buttons, the event is not registered. I … | |
Re: James: Thank you for the reply. I am eager to hear about your approach. If you could, kindly let me know. Thank you! | |
Hello, I am writing a Java applet which uses the JExcel API to write to an Excel file. I have pasted the run-time error that I get below. After some research about the Exception, I added a policy entry using the policytool command for any Java program by selecting CodeBase<ALL>. … | |
Hello, I am unable to register the right key event from this program. Besides setting the focus of JPanel to the KeyListener, I am not sure what else can be done. I will be grateful for any help. Thank you! import java.awt.*; import java.awt.event.KeyListener; import java.awt.event.*; import javax.swing.*; public class … | |
Hello, The program below selects two shapes at random from a choice of four shapes (line, rectangle, oval and rounded rectangle) and draws them onto an applet. Once six such shapes have been drawn, the screen is cleared and the above process continues indefinitely. The issue I am having is … | |
Hello, Are any of the older exams for the Sun Certified Java Programmer certification available online? I was able to find mock exams and other test prep material. Just wondering if earlier exams are available. Thank you! | |
Hello, The following program computes the value of Pi using the Hit/Miss method. Since I am doing all the drawing in the JPanel, I am not calling super.paintComponent(g). The program works well, but since I am not using the super.paintComponent, it does not draw the background. Is there any way … | |
Hello, The following program displays two images (ImageIcon type) inside the JTextArea. Is there a way I can make both of these images transparent sothat what I type on them is visible? Thanks in advance! import javax.swing.*; import java.awt.event.*; import java.awt.*; import java.awt.image.BufferedImage; import java.io.File; import javax.imageio.ImageIO; import java.io.IOException; public … | |
Hello, The following program has a JFrame which contains an image, JTextArea and and a textfield. How can I display the image inside the text area? I will be grateful for any help! Thank you! import javax.swing.*; import java.awt.*; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.awt.event.*; public … | |
Hello, I am working with the AudioClip class. It has methods for playing, stopping and looping an audio file (.wav/.au). Is there a way I can check when an audio file has completed playing? The stop() method is void. Is there any other class I can use? Thank you! | |
Hello, The following is a bouncing ball applet. When I do double buffering (variables, g1 and image), I still see the flickering . I would be grateful for any help. [CODE]import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.lang.Thread; public class Ball_Bounce extends JApplet implements Runnable { private Thread blueBall, redBall; … | |
Hello, The following applet displays two .jpg files (ImageIcon objects - x and y) on a JPanel. I would like to display the second ImageIcon object (y) as transparent. Is that possible? Thank you! [CODE] import javax.swing.*; import java.awt.*; public class PicPanel extends JApplet { ImageIcon x, y; JPanel panel; … | |
Hello, When I run the following program, the applet window displays nothing. I will be grateful for any help. [CODE] import javax.swing.*; import java.awt.*; public class BoxPanel extends JPanel { private JTextField label1, label2; public BoxPanel() { setLayout(new BoxLayout(this, BoxLayout.X_AXIS)); label1 = new JTextField(20); label2 = new JTextField(20); add(label1); add(label2); … | |
Hello, The following program has three JPanels - one to hold the image, one for the JComboBox and the last one for holding the JLabel, JTextArea and JButton. Once a selection is made in the JComboBox, the user will enter text in the textarea and press the button. The button … | |
Hello, The following program displays the text area for the entire JFrame even though I have set the dimensions of the text area to be 10 x 15. Any help will be greatly appreciated. Thank you! [CODE]import javax.swing.*; import java.awt.*; public class Scrollers extends JFrame { JTextArea area; JButton button; … |
The End.