jframe

Java Fullscreen mode not working on Ubuntu

血红的双手。 提交于 2019-11-28 11:20:21
So I'm using Ubuntu and when I want to enter fullscreen mode in Java, a normal window appears with max screen size, instead of a fullscreen window without title bar etc. I admit, I'm not even sure what the fullscreen mode should look like in Java, because I have not tried it on any other OS. But I assume it should be a screen without title bar. Anyone else who has this problem? This is the code I use. ; pretty straight forward. public static void main(String[] args) { GraphicsEnvironment env = GraphicsEnvironment .getLocalGraphicsEnvironment(); GraphicsDevice vc = env.getDefaultScreenDevice();

Setting a background image on a JFrame using Swing

佐手、 提交于 2019-11-28 11:19:36
问题 I have been learning Java for a few weeks now and I am really stuck when it comes to applying a background image to a JFrame. Every tutorial I've come across doesn't create Frames the way I do ( I extend JFrame ) or if they do, the instructions aren't clear enough for me to understand. The code below is from a project of my own so help me practice what I've learned so far. Please could you build on the code below and explain to me what to add and where, so I may have an image as the

Why do people run Java GUI's on the Event Queue

六月ゝ 毕业季﹏ 提交于 2019-11-28 11:11:47
In Java, to create and show a new JFrame , I simply do this: public static void main(String[] args) { new MyCustomFrameClass().setVisible(true); } However, I have seen many people doing it like this: public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { new MyCustomFrameClass().setVisible(true); } }); } Why? Are there any advantages? The rules governing what needs to be performed on the EDT (I see "EDT" more often used than "Event Queue") have changed during Java's lifetime. And everytime the "rules" changed, Sun advised doing more and more "GUI

How to update a jFrame in a second window?

对着背影说爱祢 提交于 2019-11-28 11:11:08
问题 I am working on a school project on limited time, leading to obfuscated code and much confusion. I am trying to have two jFrames open, one displaying a chat interface, the other displaying an image. Upon a call to actionPerformed() from the first window, I would like to call a method which changes the image that is on the second window, several times, with some delays in between. The image, however, does not change. I think my issue has arose due to using a piece of example code for the text

Changing and Updating JPanel Components externally, from JFrame is not Working, Swing

时光怂恿深爱的人放手 提交于 2019-11-28 11:09:26
问题 I was working with JPanel (Changing its component), but I want to change it from External JFrame. Sorry, I make this code with Netbeans (I know it put some stuff not needed for this question) and try to clean editing it, because the real code it is more large Here the code of the JPanel, with name 'MyPanel'. public class MyPanel extends javax.swing.JPanel { private javax.swing.JButton filling = new javax.swing.JButton(); private javax.swing.JScrollPane jScrollPane1 = new javax.swing

Swing - Changing the content of a panel using UpdateUI

岁酱吖の 提交于 2019-11-28 10:52:30
问题 I am going through a legacy application which is using Swing and i am struggling to figure out how the screens are changing when a user clicks a button. One of the reasons i cant figure this out is because this is the first time i am using Swing. I have read a book and got the basics but still struggling. Basically, the screen i am looking at has a JSplitPane which has a number of shortcut buttons on the left and an empty pane on the right. When i click on the button, the right side pane is

Firing delay between JFrame components

给你一囗甜甜゛ 提交于 2019-11-28 10:49:07
问题 I want to show how merge sort perform visually using JFrame . What I want to do is to make visible subsequent JLabel with some time delay. I tried many way but all of them appears at same moment with no intermediate delay. private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) { // TODO add your handling code here: // jLabel1.setVisible(false); jLabel2.setVisible(false); jLabel3.setVisible(false); jLabel4.setVisible(false); jLabel5.setVisible(false); jLabel6.setVisible(false);

How to show different cards in a CardLayout?

穿精又带淫゛_ 提交于 2019-11-28 10:24:16
I looked at a code example that used this code: cl.show(cardPanel, "" + (currentCard)); But when I use show I get a message in Eclipse that it's deprecated and I wonder if there is another way to show the different cards in the CardLayout when I click on the buttons? Below is the code for my CardLayout class. Suggestions are also welcome if some part of the code are bad practise. Thanks! import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; public class CardLayoutTest extends JFrame implements ActionListener { // Ref private JPanel

Can't repaint my JFrame/JPanel

断了今生、忘了曾经 提交于 2019-11-28 10:23:37
问题 I have created a program that just moves a ball across a screen. I used to have it all in one class, but decided that it looked too messy so I split it up into three different classes: Main... initializes everything, Game... which paints everything and is a JPanel, and AL which is a KeyListener (which is also where the problem is). The problem is that I can't get the program to repaint from my AL class no matter what I try to pass into it. Can anyone help with this? Here are my three classes:

Adding image to JFrame

断了今生、忘了曾经 提交于 2019-11-28 10:06:58
So I am using Eclipse with Windows builder. I was just wondering if there was anyway I can import an image that'll show up on the JFrame that I can easily move around and re-size instead of setting the location and size and drawing it. There is no specialized image component provided in Swing (which is sad in my opinion). So, there are a few options: As @Reimeus said: Use a JLabel with an icon. Create in the window builder a JPanel, that will represent the location of the image. Then add your own custom image component to the JPanel using a few lines of code you will never have to change. They