32,199 Topics
| |
In this code i did not understand something. In one class, a variable is declared as private, but then this value is used in another class. import java.awt.Graphics; import javax.swing.JPanel; public class DrawRect extends JPanel { private int choice; //user's choice of which shape to draw. public DrawRect (int userChoice){ … | |
> I have asked this question before, but i think i could not totally understand the diffefence between bitwise and logical operands. According to the book i am using to learn java, the bitwise operands can change the value and this is described as side effect. Also, in bitwise operands, … | |
I have a panel(JPanel) and it has FlowLayout by default. It has no preferredsize. I have a JScrollPane. So When I am adding buttons to the panel, the buttons are horizontally added. I want that to be added vertically. panel = new JPanel(); JButton clearButton = new JButton("CLEAR"); panel.add(button); JScrollPane … | |
It compiles but my JButton won't work... when i run the applet and press the Exit button.. it just prints some errors(or i dunno what they are) in the black window that opens when you run the applet. import java.awt.event.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; ; public class CheckRadioTest … | |
This only does either BOLD or ITALIC... import java.awt.event.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.applet.*; public class CheckRadioTest extends JApplet implements ItemListener { //private String CurrentComboName = "Select One"; private JLabel headingLabel; private int currentStyle = Font.PLAIN; //private int intBold = Font.PLAIN; //private int intItalic = Font.PLAIN; private … | |
I tried to convert this GUI to a JApplet but then I get the error message. > D:\JAVA\PROGRAMS\whiteboard\whiteBoardapplet.java:9: error: whiteBoardapplet is not abstract and does not override abstract method actionPerformed(ActionEvent) in ActionListener > public class whiteBoardapplet extends JApplet implements ActionListener > ^ > 1 error > > Tool completed with … | |
This is a JApplet. the Radio Buttons for colos work.. why won't the Checkboxes work? import java.awt.event.*; import javax.swing.*; import java.awt.*; public class CheckRadioTest extends JApplet implements ItemListener { //private String CurrentComboName = "Select One"; private int currentStyle = Font.PLAIN; //private int intBold = Font.PLAIN; //private int intItalic = Font.PLAIN; … | |
I'm working on a Graph based Image editor. My current plan is to have Nodes of the graph be operations on the image, an operation will take a number of input buffers and manipulate them in some way (be it invert a single input, composite two inputs, draw a rectangle … | |
In the below code, I want to know the significance of 10 while creating a PrioriyQueue. I know its the initial capacity but what does it mean?? I replace 10 with any positive number and the output remains same. import java.util.*; class Test { static class PQsort implements Comparator<Integer> { … | |
I am new to Regex... I need to split by "|&|" -- three characters in that exact order. For example, **"abc|&|e&f**" should return *"abc"* and *"e&f"*. I tried string.split("|&|") , but it return all single characters. | |
I wrote a class called Creature.java that creates a random creature object with various body stats. The Creature class extends MonsterGUI. I used Netbeans to create a new jFrame form, called MonsterGUI.java to create a GUI to display the creature objects' stats using jLabels. In MonsterGUI I have a private … | |
public void compareStrings() This method will prompt the user to type two strings and will put them into different String variables. Then it will compare those strings to see if they are the same, i.e. have the same letters in the same order. If the strings are the same, “same” … | |
Just need some understanding on the various Prime number calculations.Please explain 1. verify by brute force that a number is evenly divisible only by 1 and itself.(dont implement the Sieve of Eratosthenes algorithm) 2. writing and running the program with upper limits of n/2 and the square root of n. … | |
| I am trying to cast vector to a string players = (Vector<Player>) inStream.readObject(); And I get error: java.lang.ClassCastException: java.util.Vector cannot be cast to java.lang.String Can someone tell me is there a way to do it? Thanks |
Hello, java noob here, in the code below, why is it when declaring a class that '<E>' is used in stead of the brackets ? '(E)'?? public class LLStack**<E>** implements Stack<E>{ private Node**<E> **head ; public LLStack ( ){ head = nul l ;} //creates an empty stack public boolean … | |
hi, I have installed the IIS FTP server in my PC and I want to monitor this server with the SNMP protocol ,I have searched in mib files and I didn't found any information concerning this server,is there any other way to monitor a server programatecly and thanks. | |
Simple code to see if array of primitives has duplicates. The aim is to only check if there are any duplicates, but not to check what element is repeated, or its position etc. PS: Do you know some handy snippet? Don't way, post it! | |
So this is mainly a Design/Clean Coding sort of question, I know I've read something about this previously but I can't find it, I believe it's in one of my reference books on C/C++ so it wouldn't likely be useful to my predicament. This question includes a lot of Java … | |
Hello, I need to create a JDBC that connects to a mySQL database, retrieves the data from a table and displays it into a JTable. I have done this successfully, but have ran into a problem. The initial values I entered into the database (for testing) are permament. If I … | |
I was wondering how is it possible to receive a "key-pressed" event in Java even when my program is in background. | |
i having trouble adding the JSeparator into GUI. It just won't come out =( i write it like this, but nothing happen... JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL); pane.add(separator); | |
Everyone watch my code and help me. I'm building a simple program like Paint the windows. Here, I just do the free drawing button. But when I press the button and draw freehand drawing, then the panel draw the toolbar to copy the image above and press a button every … | |
OK so what would I need to change to the following code so it would produce the following: xxx xoo xoo As at the moment it is producing: xxxooo xxxooo xxxooo My code that I have used can be seen below: import javax.swing.*; public class test { public static void … | |
Im creating a Chess game. Im stuck at getting the pieces to move within the rules Aka bishop can only move diagonally. I Create Panels - 64 of them within a lager panel then add JLabels - The pieces - into those panels ` JLabel bb = new JLabel(new ImageIcon("bb.gif")); … | |
I am newbie in java. I am facing problem now. My purpose is to put the time in textfield. I need press "Start" button and then the time will start go. But after i compile this code. It got error. I have no idea to do it. Can anybody help … | |
Hi, I'm new to this site, and I thought this place might help me with some of the problems I am hitting. I am currently in grade 12 Computer Science, and I am coding a third-dimensional snake game (isometric view, so can all be drawn in 2D) I have taken … | |
Ok so when I run the following code nothing occurs so could someone look at the code and tell me where I have gone wrong? public class somee { public static void main(String[] args) { somee f = new somee(); } public void f() { int anInt = g(7); System.out.println("ffff"+anInt); … | |
This is my program import java.util.*; class Triangle { public static void main(String Vinod[]) { int i,j,n; Scanner sc=new Scanner(System.in); System.out.print("Enter a height of triangle : "); n=sc.nextInt(); for(i=1;i<=n;i++) { for(j=1;j<=i;j++) { System.out.print("*"); } System.out.println(); } for(j=n;j<=1;j--) { for(i=j;i<=1;i--) { System.out.print("*"); } System.out.println(); } } } I dont know what … | |
Hi all, i have installed jdk1.7 , now i want to set the class path.. because i am compiling my program its giving an error.....javac is not recognized as an internal or external commond. please help me to set the class path.......and how to able to run my program. | |
newbie here in java pls help how to compile java.... pls help.. :( |
The End.