I have the following problem:I have 4 components in my GUI that goes like this in the CENTER of the BORDERLAYOUT:
1. JLabel
2. JTextArea
3. Jlabel
4. JTextArea
Everytime i make the GUI window bigger, all these elements spread out. How can i get these elements to have a BREAK line (i.e. a break line after 1. Jlabel) so that no matter how i stretch the window, it will stay in-tact and the other elements will follow underneath.
I have the following classes { package cmd; import java.io.IOException; public class CMD {
[Code]....
I cannot seee the output from wndows command : del *.* and the java class execution does not finished. I I will replace the above command with the dir command then the output of the command is visible. how to modify the above clases in order to parse the output of the del *.* ? note that the above example is important because I am developping a tool and it is mandatory for that tool to parse the output from a windows batch command.
I would like to learn how to add an image background to a window in java that I can put controls like buttons, textboxes, and checkboxes in front of. I already tried using a JLabel with an ImageIcon but I cannot overlay controls over the JLabel. From what I understand there are multiple ways to do this. What is the best way and how can I do it?
I am trying to make a method that takes in a cmd command (nslookup, systeminfo, etc), and outputs the response to a text file. I have tried a dozen different ways with no success. below is my most current failure. It succeeds when i run it, but nothing shows up in the text file.
public static void runSystemCommand(String command) { command = "ping 192.168.1.3"; try{ Process proc = Runtime.getRuntime().exec(command); InputStream in = new BufferedInputStream(proc.getInputStream()); OutputStream out = new BufferedOutputStream(new FileOutputStream("C:NetPanelDataping.txt"));
I made the program below in java and compiled with javac command in Window7 (64bit machine). It simply post my machine IP and Mac address to my server application.
When i run this script with java as >java Macregister
I get what is expected, the program runs well on my machine.
When I try to run it on other machines (Win8 - 32 Bit) I get error message and nothing works.
My problem is 1) to make it compatible for all machines 2) to convert it into JAR application so that it is self executable on different machines.
I am a new to Java and am struct,
import java.net.*; import java.io.*; public class Macregister{ public static void main(String[] args) throws Exception { InetAddress add=InetAddress.getLocalHost(); NetworkInterface network = NetworkInterface.getByInetAddress(add); byte[] mac = network.getHardwareAddress(); StringBuilder sb = new StringBuilder();
I am trying to learn Java and while i was playing a bit with the basic knowledge that i have i encountered a problem. When i run the program, the lines and the picture appear in two separate windows when i compile the program. how can i make them appear in the same? The code is this:
public class Game { private int x; private Picture pic;
I am writing a code that requires a user to input a number, then output the individual digits and then add the sum of the digits. I have the entire program written, but I cannot figure out how to make zeros output as individual digits. If I input 400, it only shows 4 and not 4 0 0. Here is the code:
import java.util.*; public class week4program { public static void main(String[] args) {
How do I put this code in a way that it works because I know it is probably something obvious but I cant find how to make the array readable without error. It is supposed to intake two values and output what day of the week it is.
Testing Program
Initial day: Monday Next day: Tuesday Next day again: Wednesday Previous day: Tuesday Next week: Tuesday Add 4 days from initial day: Friday
I had to make a program that allows the user to enter 3 sides and it should output "invalid" if it does not make a triangle and if it does make a triangle it calculates the area of the triangle and it doesnt seem to do anything but say "invalid" as the out put.
import java.util.Scanner; public class MyTriangle { public static void main(String[] args) { Scanner input = new Scanner(System.in); boolean valid = true; double side1, side2, side3, area, A;
I've been trying this for hours but it's not working. I'm trying to add the sea glass look and feel library to my project but I still get the error:
Exception in thread "main" java.lang.NoClassDefFoundError: List (wrong name: list)
What should I do? I've added the library to "project settings >Required Libraries" and did not forget to check the box. I've also imported the L&F so it can't be that.
I am new to javafx I start using it instead of swing i used the scene builder for my forms the problem i faced i don't know how to have main screen with menu bar at top and depending the select from the menu it will open other windows and those window must be inside my window just like for example netbeans.
I don't need to open new window in separate i need all windows inside my main window and controlling over them minimize maximize perhaps.
I pulled off an all nighter in order to finish off this project for my computer studies class but i keep getting an error cannot find symbol at line 96?
import java.io.*; import java.util.*; import java.util.Random; public class SlotMachine { //Generates 3 random numbers for slot machine public static void main(ArrayList<Integer> slotMachine) {
I am trying to execute a program from the command prompt. I type java -jar zuul.jar (zuul is the name of my project) and I get a message that java is not recognized as an internal or external command. What do I do wrong?
I search this source code in google about library system then i run this in my JCreator then that error appear . I think that problem is all about "main". where can i put that main ?
We are making a tic tac toe game for my CS120 class and I am having trouble figuring out how to make our X's and O's. Is there a way to make shapes besides making two lines for an X and an oval with a white smaller oval inside to make an O? We have only learned the basics so far in class (i.e. events, inheritance, client-supplier, etc.)
These are our instructions:
Write a controller that controls the game. There is one human player (the X player) and the computer player (the O player). The name of the class must be TicTacToeController. In a sense, the controller is the game since the controller will 1) create a TicTacToeModel 2) create a TicTacToeView and 3) create a TicTacToeButton (you must write this class following the design pattern covered in class lectures), a label, and text field such that when the button is pushed, the player moves into the cell selected by the text field. After every player move, the computer moves into a randomly selected empty cell. When the game is over, a text message must be displayed somewhere on the screen the gives the status of the game. While you are free to change the appearance of the controller, the basic elements must be provided (a view of the game, a button, and a text field to enter the cell). A sample screenshot is displayed below.And this is the code i have thus far:
[import java.awt.*; import javax.swing.JFrame; public class TicTacToeView extends Rectangle public TicTacToeView(int x, int y, int w, int h) { super(50,60,w,h); this.setBackground(Color.red); JFrame win = new JFrame("Tic Tac Toe"); win.setBounds(10,10,w+100, h+100); win.setLayout(null); win.setVisible(true); win.setBackground(Color.gray);
my output fails to display me the 2nd output.Here's my code.
import java.util.Scanner; public class year { public static void main (String [] args) { Scanner console = new Scanner (System.in); System.out.print("Enter the choice of book(A-ABC,D-EFG):"); String x = console.next(); System.out.print("Enter the rate (1-3):"); int y= console.nextInt(); System.out.print("Enter number of kids reading:"); int k = console.nextInt();
[code]....
When I key '0" for kids, it did not appear the second print out. I don't want the first print out to be the output.
i would like to ask what does exactly do the command mvn compile. What is happening with the code, when i write this command? And why is it necessary for running the code?
Now everything works in Netbeans but running it from the command line, i get an error message ".java uses unchecked and unsafe operations".I have added a bit more code to the code above
for (int i = 0; i < args.length; i++) { System.out.println("args[" + i + "]: " + args[i]); }
Just not sure how to run it from the command line,