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 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 want to create a borderless window with a background; I want this background's transparency set at full, so that the corners show the image of whatever's underneath, just as in the picture. Then, I want to add an image (or button) to a specific x, y location in the window (which is NOT resizeable, which is my desire) and then have the user able to click the button; button1 does function1, button 2 does function2, etc. But the images (or buttons) must ALSO have transparency, so that you can see the background image.
I wrote this program in VB.NET already; I'm trying to rewrite it in Java, as I can no longer work in VB... the program is simply taking up too much memory and is far too slow. Java should handle the whole process better.
In my Java 2D game, two tanks are controlled as follows:
Tank 1
- Move forward: UP arrow - Adjust angle of movement: LEFT and RIGHT arrows
Tank 2
- Move forward: W key - Adjust angle of movement: A and D keys
It is possible to adjust the angle of a tank while it's moving forward (e.g., striking the left arrow or the right arrow while striking the up arrow). It's also possible to move both tanks forward simultaneously.
However, while one tank is moving forward and changing its angle (e.g., striking the up and the left/right key at the same time), the other tank is only able to move forward. That is to say, it cannot adjust its angle (e.g., striking W and A at the same time won't work, while the other tank is doing the same thing; the A key is ignored).
Why is that? Here's the relevant code:
In the Board class, that has most of the game logic:
I am developing a game where a player has to find a path in a maze. Right now the player can only click the buttons on the maze. I need an option to use the arrow keys.
I have picked up pieces from my code to illustrate my problem. Below is the code. If I call "AnyClass" in the "AppletClass" it works but when I call "MiddleClass" in the "AppletClass" and MiddleClass" calls "AnyClass" it does not work. In my project at www.hiredforoneday.com I call 4 panels in CardLayout before I call "AnyClass" which is the "Maze"
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 am developing in Android Studio and I made a simple background, the actual resolution of the image is 1440 by 2560. I made it that resolution so, 1, it is easier to scale down than up, and 2, in android studio i use a nexus 6 as my preview. When I plugged in my gs4, not a 1440 by 2560 display, the background wouldn't show up when I ran it on my gs4(galaxy s 4). How do i get my background to scale and display on any display size.
Exception in thread "main" java.lang.RuntimeException: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is: java.net.SocketException: Permission denied: connect at com.readAlerts.SendEmailUsingGMailSMTP.main(SendEmailUsingGMailSMTP.java:63) Caused by: javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 587; nested exception is:
[Code]...
Tried every permutation and combination but all leading to this same error.
I want to send a message to a specific client in a server. This is my code and what I tried(I have only given you 3 classes in which I believe I have the problem).
TextClient: import java.io.*; import java.net.*; import java.util.ArrayList; import java.util.Scanner; import java.util.concurrent.TimeUnit; public class TextClient { public TextClient() {
Isn't changing my backgrounds in my MouseAdapter I keep getting these errors:
at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
JFrame{ JPanel(That MenuBar at the top) JPanel(That panel at center with table){ JScrollPane{ JTable } } }
I want to add my custom image to that grey space right there. I guess it is a JScrollPane, because I added that orange background on JPanel that contains it. But when I add this code to my custom class of JScrollPane:
@Override public void paintComponent(Graphics g) { super.paintComponent(g); if(background == null){ background = new ImageIcon(ClassLoader.getSystemResource("tableBg.png")).getImage(); } g.drawImage(background, 0, 0, null); }
The result is the same, no changes.
Then I read some documentation. I found this method:
scrollPane.getViewport().setBackground(Color c);
It works, but it accepts only color and I want to add image. Is there any way to do that? Do I need to subclass JViewport and use paintComponent ? If yes, then how to make getViewport() method return my custom subclassed version?
This is my code and it works! But how/where do I set a background image for it to appear as the background of my calculator? The code I have for it is this -
import javax.swing.*; import java.awt.*; import java.awt.event.*; /** * Program using SWING components to create a Christmas themed Calculator. */ public class ChristmasCalculator implements ActionListener
I have made a little chat program with java(ecplise) but i want build it and if a user opens it is is going to run in the backgroundprocess. I don't know if i have to edit my code or Export it differently.
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class sample{ public static void main(String args[]){ JFrame frame = new JFrame(); frame.setSize(300,300);
[code]....
To limit the amount of drawing done i want unmoving objects to be painted once. So i set a boolean. When it first load the boolean is false so it draws then after first draw i never want it to draw the objects agian but leave them on the screen. Now in this if you run it you get a black screen.
If you didnt have the "getContentPane().setBackground(Color.black)" it would work fine and show a blue brick. Is there something I don't understand about the setBackgound Function that makes it automatically redone even when not called? and if so how do i overwrite this?
I have to send a request with post parameters from one web application to another web application,both are running different servers.
In my application i don't have any JSP,html only controller part which will handle request extract request parameters & based on request params i'll do a web service call.
My current requirement is based on request parameters i'll send request to another web application with received parameters.
I tried with sendRedirect() ,but it support only get() method.
I have a Java application this application sits on a Dedicated server and gets information about the machine and run commands on the machine.
I need it so that i can run these commands from pressing buttons on a website. For example i press a button to retrieve CPU info, it goes to the app, and the app sends the CPU info back.
I'm fine with the website and app its just the middle bit. How do i get the app to run commands sent from a webpage. Been ratting my brains for a couple weeks now.
In my jsp, I have a table with some file paths with this I have to get the file and send it to server. I am able to read the file name, size and file as binary using files of javascript. But after that I need to send those files by storing in a byte array to servlet which I am not able to that. Is there any way I can send that. My requirement is I need to upload those files to server side.