jframe

Setting fullscreen using other ways besides getting screen size in Java

本秂侑毒 提交于 2019-12-02 18:11:47
问题 I was wondering if there was a way that is better than using the Toolkit.getDefaultToolkit().getScreenSize().getHeight()/getWidth(); and then using that as the dimensions for the JFrame and then setting the JFrame to undecorated ? Would there be some sort of pre-built function in Java that takes control of the graphics card for a true fullscreen? 回答1: You're after what's called "full-screen exclusive mode" Have a look at Full-Screen Exclusive Mode for more details. Understand though, it doesn

How to draw on top of an image in Java?

自闭症网瘾萝莉.ら 提交于 2019-12-02 18:06:19
问题 I used JFrame to import and display an image, and used mousemotionlistener to detect the mouse clicks, and I want to be able to draw on top of the image. I want to be able to, if the user makes a click, make that pixel a certain color while preserving the rest of the image, however, I couldn't find out how to use Graphics to do so without deleting the rest of the image or opening a new window. public class Simple extends JFrame{ static ImageIcon icon; static JFrame myframe; static JLabel

Java - Move undecorated program on dual monitors

北战南征 提交于 2019-12-02 17:23:19
问题 I made an undecorated Java program. I work on a dual monitor. But when i try to move the program on the second monitor, it doesn't works.. Here is a screenshot explanation So i have 2 Classes: Class Main.java : package undecorated; import java.awt.CardLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.sql.SQLException; import

Java - draw circle after clicking button

三世轮回 提交于 2019-12-02 17:09:21
问题 I am trying to draw a circle with the press of a button in java. I put the System.out.println() inside the action method to make sure my code was working. The println shows up but no circle drawing anywhere. Any Suggestions? Thank you import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; public class CircleViewer { public static void main(String[] args) {

Why is my JFrame empty?

安稳与你 提交于 2019-12-02 17:07:30
问题 I can't seem to figure out why my JFrame is empty. Where am I going wrong? import javax.swing.*; import java.awt.FlowLayout; public class GUIExample extends JFrame { JCheckBox box1 = new JCheckBox("Satellite Radio"); JCheckBox box2 = new JCheckBox("Air Conditioning"); JCheckBox box3 = new JCheckBox("Manual Tranmission"); JCheckBox box4 = new JCheckBox("Leather Seats"); JRadioButton radio1 = new JRadioButton("Car"); JRadioButton radio2 = new JRadioButton("Pickup Truck"); JRadioButton radio3 =

can't draw on JFrame

笑着哭i 提交于 2019-12-02 16:38:32
问题 I'm trying to make a simle java program that draws a circle at the mouse localization, it gets the mouse X and Y coordinates but it doesn't draw anything, i tried to draw a String, a circle and a line but nothing worked, i changed the code a bit but it still doesn't works class Test4 { public static String a; public static JFrame frame = new JFrame(); public static Point Gett(){ PointerInfo h = MouseInfo.getPointerInfo(); Point b = h.getLocation(); return b; } public void paintComponent(int x

Create JInternalFrames and save the one which is selected

一世执手 提交于 2019-12-02 16:13:19
问题 I am learning Java now and I was wondering how to create JInternalFrames in a JFrame and save them as files. I draw some objects on the internal frames and I have a button 'Save'. For example, there are several of the internal frames and I want to save the one which is selected. May someone provide me with simple code on how to do this? Only the frames and how to save them. 回答1: Read the JDesktopPane API. You will find a method that will get you the currenctly selected internal frame. Check

Cannot refer to non variable inside Action listener (Jframe)

我是研究僧i 提交于 2019-12-02 16:06:15
问题 The following program's goal is to ask the user to input a resistor value, then of which the program will output the corresponding colors for each digit. This thus not include all the digits. However, that program is done, I've made an attempt to incorporate JFrame as an extra thing, except I am hung up on how to print the corresponding colors in the action listener. This line calls the specific methods, for the 3 digits then proceeds to print the colors, except how do I incorporate that and

Difference between JPanel, JFrame, JComponent, and JApplet

ぐ巨炮叔叔 提交于 2019-12-02 16:04:54
I'm making a physics simulator for fun and I was looking up graphics tutorials when I tried to figure out the difference between all these J's. Can somebody elaborate on them or perhaps provide a link to a helpful source? Those classes are common extension points for Java UI designs. First off, realize that they don't necessarily have much to do with each other directly, so trying to find a relationship between them might be counterproductive. JApplet - A base class that let's you write code that will run within the context of a browser, like for an interactive web page. This is cool and all

Loading a .Jar Applet inside of a JFrame(Panel)

流过昼夜 提交于 2019-12-02 15:03:15
问题 I'm trying to make a JFrameable "Loader" of one of my favorite Java games, but I don't know how to load the actual .Jar into a JFrame panel (I was told this was called an Applet, guess I'm behind a little bit) I have the JFrame set up with panels and everything where I want it, but I have no idea how to go about loading the .jar and sending parameters to it and telling it where i want it to be at. Any help or links would be greatly appreciated... as I can't find anything 回答1: Since you haven