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 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 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 would like to get commas in my output for bigger numbers like 1,000.00 10,000.00 etc...This is my program. Everything compiles just fine and I get the right output but again would like commas.
import java.text.DecimalFormat; import java.util.Scanner; import java.io.*; public class propertyTax { public static void main(String[] args) throws IOException { String fileName; double assessedValue;
[Code] ....
These are some of the values that are in/outputted :
Where can I find tutorials about how you like have a big image, bigger than the specified screen, for the map of a game, and then you have camera view, the image is being printed on the screen continously as the character moves in different areas depending on what area of the map the character is in?
NOTE!!! I don't want to move objects around, I just want a camera view on a large image!
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.
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);
I am writing a small app to automate some actions on my computer this requires me to open an application and click on a button I am using
Process child0 = Runtime.getRuntime().exec("/home/user/application");
to do this. The problem is every time it opens at a different lcation on the screen so i cannot click on it using the robot class due to x,y coordinates being different every time. with selenium you can use .setlocation(x,y) method but how can this be done for other applications.
I have an assignment to create a circle with a radius of 40px in a 100px by 100px window and move the circle with the arrow keys.The circle can't move past the the edges of the window. I believe I have the code right but the window won't create the window or pane with a width of 100 px because of the close, minimize, maximize buttons. Is there a way to remove those or force JavaFX to create it with a width of 100px? Here's what I've got so far.
If I do try to do ChatFrame.setResizable(false); it gives me this error:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem: Cannot make a static reference to the non-static method setResizable(boolean) from the type Frame
at com.ui.ChatFrame.<init>(ChatFrame.java:37) at com.ui.ChatFrame$5.run(ChatFrame.java:403) at java.awt.event.InvocationEvent.dispatch(Unknown Source)
I have a WindowClosing(WindowEvent e) method, but when I close my window it isn't doing anything inside the method. I am making a launcher and I want to make it so when the actual game window is closed it makes the launcher window visible again.
Java Code: public void windowClosing(WindowEvent e) { this.jf.setVisible(true); } mh_sh_highlight_all('java');
That's my third day working in Java using Swing and the IntelliJ Idea IDE.I'm trying to do something as simple as displaying a PNG in a window, and I'm doing this:
public class AboutRapide { public JPanel mainPanel; private void createUIComponents() { mainPanel = new ImagePanel();
[cod]....
the problem is that, in the paintComponent method, the Image is never found when I run my app from the IDE, but it is when I run it from Finder in my Mac. Same application. I think it relates to how the application is launched so I guess what's a proper way to refer to a resource file with an image so it can be displayed no matter how the application is launched?Also if I generate a Jar for the application, as the resource gets into the Jar compressed file, it can't also be loaded.
I am trying to repaint a window from another class. the class Window handles an interface that displays pictures of movies. Via a JMenuBar you can add a new movie and its picture but in order for it to show in the Window i need to repaint certain aspects in the Window class GUI;
The window class constructor:
public Window() { addComponents(); configurFrame(); addMenu(); }
The functions i want to repaint:
public void repaintWindow() { this.getContentPane().validate(); this.getContentPane().repaint(); }
From my other class where i add a movie to an ArrayList i have made a "private Window myWindow;" there i call the function repaintWindow via mywindow.repaintWindow(); But this gives me an NullPointerException related to the repaintWindow function.
Whenever I make something in Swing, I always need to resize the window for me to see the graphics on the window. I have been told to use the pack() method on it, which I have, but the problem with it is that it just sets the window to a minimal size, only displaying the x + and -.For one of the "games" I made, it at first didn't work until resize, then I added a repaint() after the constructor and it worked for me, but when my friends download it they cannot see it.
So I have basic java knowledge from 1st year of college and I wrote a program recently that sends keystrokes with the Robot class. Now I would like it to do the same but to send it to a window that isn't my active one.. I've searched and from what Ive found it seems like you cant do that in java, I need another language like C# (whick sux for me since i dont know any other then java).. Is this true? If not how would i send something to notepad for example while it is not the active window?
I am trying code that When i press a button(New user), i want the event to send me to a new windows that i have created in Scenebuilder... I dont know why it wont work, i get this exception:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source) at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source) at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
I started a text based game, but I am dissatisfied with the console that PrintF prints to. How can I set up a window and have text output to that window, and have my player type responses in the window?
I am relatively new to java, and i am trying to create a window inside of a 2d char array, and eventually i will have to draw other shapes in this window. so for example
The problem is my window is not drawing correctly too the border, but a couple extra chars on the x columns. Here is code. The dimensions of the window will eventually be passed through scanner in main, if i ever work out how to even draw it.Also, in class we never learnt to use the Graphics class, so im pretty sure we are not supposed to use it.
public class Window { //default values private int xRow; private int yCol; private char ch; public char[][] windowz = new char[30][20]; //30,20 (yx)flat values cuz doesnt work
I am trying to create a gambling POS system and having problems with a method trying to get a value right after it was set. A jbutton sets another jframe visible which contains buttons. Upon action of the button, a value is set and the jframe is disposed.
private void btnPrizeActionPerformed(java.awt.event.ActionEvent evt) { PrizeSelling prize = new PrizeSelling(); prize.setVisible(true);//create prize selection window bin = getButton(); //gets what button is selected to load the correct prizes for correct game prize.DBconnect(bin);//sends bin number to prize loading method
[Code] ....
As soon as btnPrize is clicked it gets the total value of the prizes selected which of course is 0 because it is ran before it is set. How can I make it wait until the window is closed before continuing?
I am looking for a solution that will allow me to use a custom background image to replace the JFrame window. I am able to add a background Image, however I am not able to remove the "white" that is supposed to be transparent.
For example; if the image was shaped like a bird with transparent background (.PNG), I would like that to be put on the JFrame. Usually it will be a square with the image in the middle with white background, which I am unable to remove.