Create A Borderless Window With A Background Transparency Set At Full
Feb 15, 2014
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.
I'm currently making a Breakout clone to learn about different ways of organizing my code and whatnot but I've run into a problem with the positioning of some pieces versus the position of the mouse.
I've created a blue rectangle on the screen that turns white when the mouse hovers over it, BUT it actually only ends up turning white about halfway down and then continues on off the block. I moved the rectangle to 0,0 to see where it draws and it looks like it is drawing to the very top left corner of the window itself but for the mouse coordinates, the top left is just where the black area is and excludes the borders of the window.
Here is the class rendering the rectangle, it extends from a class that in turn extends from the JPanel class:
public class MainMenuState extends MenuState { JFrame gameFrame; Graphics2D g; // PlayButton variables int playPosX = 0; int playPosY = 0; int playWidth = 100; int playHeight = 50;
[Code] ....
A few other things I tried that I can think off the top of my head: Play around with different layouts (at times this caused the screen to shrink to a small size as well as using pack()), using setSize() setLocation() or setBorder() in the MainMenuState class which had no effect.
Someone on another forum also suggested trying to utilize component.getLocationOnScreen(): I tried two things with the getXOnScreen method, first subtracting with the location of the JPanel which of course gave me the same problem. After that I tried
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'm working on a GUI application, I'm building it based on an example of a image provided and I am having an issue with my radio boxes, well the easiest way to explain will be if you look at the too attached images , the example im working from has the radio-boxes transparent they are the same color as the background image, my radio boxes seem to sit ontop of the background image with their default grey border, How can i make my radioboxes blend into the background like in the given example?
Im using Netbeans GUI toolkip to build this app, for the background image in the jpanel i just created a label and set the icon to the image i wanted.
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.
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'm trying to make a canteen class that holds water. It holds two quarts of water and two quarts is 100%.
public double maxVolume; public int percentFull;
Right now the Canteen is empty.
public void Canteen() { percentFull=0; maxVolume=0; }
And right now I'm trying to make a constructor that specifies the amount of liquid the canteen can hold and specifies the percent full.
public Canteen(double maxVolume, int percentFull) { }
Should I make this second Canteen an integer, a double, or something else? Also, how do I make sure the Canteen never reaches higher than 100%. I'm also curious how I can keep maxVolume and percentFull connected so the % of water is consistent with the number of quarts(2) the Canteen can hold.
I am trying to create a JScrollPane with buttons in it, but I noticed that when I try to scroll, the items all move into ONE row at the top of the JScrollPane. How do I have them vertical? Is there something wrong with the way I am setting up the JScrollPane?
I have read through some of the posts on insert sort /arrays and see close but not exactly what I'm looking for. I don't want to use a library to do work for me, I want to do it myself and understand it.
OrderedArrayList.java // import static org.junit.Assert.assertEquals; public class OrderedArrayList<T extends Comparable<T>> { // T is a variable that contains a class type, array of T things private T[] arrayA; // changed to private per example private T[] arrayB; int numElements = 0;// number of elements full (not null), used in multiple methods. numElement -1 = back
I want to make swing form full screen even on taskbar on linux machine. But after trying so hard unable to achieve it. I am using fedora as operationg system.
Below i am giving you my swing code. but whenever i run this file form comes up on the screen and waits for a second and it goes in background.
I am using linux OS Fedora 64 bit.
public class ThankYou { JFrame f; JTextArea nameField; JLabel lable; String str;
/** * Compute shortest paths in a graph. * * Your constructor should compute the actual shortest paths and maintain all the information needed to reconstruct them. The returnPath() function should use this information to return the appropriate path of edge ID's from the start to the given end. * * Note that the start and end ID's should be mapped to vertices using the graph's get() function. */ class ShortestPaths { Multigraph graph; final int INF = Integer.MAX_VALUE; PriorityQueue<Integer> Q;
[Code] ....
I followed someone else psuedocode very closely but for whatever reason, my edge[] array is just full of null data, which means I can't actually return the shortest path. Why that's happening/how to fix it? Maybe I'm not understanding dijstra's correctly.
Basically the code is for a game which is displayed in a window. The statement if(false) //full screen mode is confusing me a little. How does this if work? it doesn't seem to be testing for anything so how does it ever get set to full screen mode? Is the if even needed? why not just code windowed mode?
public class Window extends JFrame{ private Window() { // Sets the title for this frame. this.setTitle("My test"); // Sets size of the frame. if(false) // Full screen mode
I'm trying to set a variable to point to the last full cell of an array and then create a new larger array and then have the variable be updated to point to the new array's last full cell index value.
a) Should the variable be declared static? b) What would be the best initial value to set this variable to? Shouldn't it correspond to a <for> loop index rather than a solid integer?
private lastfullcell = a[i]; private int [] a;
c) How would you update <lastfullcell> because if you passed the index through a method's loop index isn't the array index value garbage collected after the method completes?
Following is the code for my assignment where a user inputs his full name in a string from keyboard. It should be done using BufferedReader. The program will give his initials as output.
############################
For example: User inputs-> Ram Kumar Das
Program Returns-> R.K.D.
I am written the following piece of code. It does not return the correct output. If "Ram Kumar Das" is given as input, it gives R.K.K. as output. Arrays and objects are strictly not allowed.
Java Code:
import java.io.*; public class Assignment { static int i=0; static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main (String args[]) throws IOException
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.
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?