jframe

Java - Vertical “FlowLayout” with Horizontal Scrolling

那年仲夏 提交于 2019-11-27 01:36:29
问题 As described in the title, I've been trying to set up sort of a vertical flow layout with horizontal scrolling. The components within the layout will be JLabels. Let me draw a picture: +-------------------------+ <--- window |Label1 Label4 Label7| |Label2 Label5 Label8| <--- labels |Label3 Label6 Label9| |<===============>========| <--- scrollbar +-------------------------+ Same window, expanded vertically +--------------------------+ <--- window |Label1 Label5 Label9 | |Label2 Label6 Label10

How to remove all components from a JFrame in Java?

给你一囗甜甜゛ 提交于 2019-11-27 01:30:19
问题 I'm writing a program where I have a JFrame and I want to remove all components from it, then add just one component to it and repaint the frame. What I have so far is something like the code below (called in an object that implements JFrame, where StartPanel implements JPanel): removeAll(); startPanel = new StartPanel(); startPanel.setVisible(true); add(startPanel); revalidate(); repaint(); However, when I run the code it shows an empty window (not the startPanel) and when I minimize/resize

Jframe not the right size when its executed, any reason why?

一个人想着一个人 提交于 2019-11-26 23:43:32
问题 I am making a game but whenever i run the second jFrame I have to resize it in order to get the right size for the second jFrame, anyone know why? here is the method in the first jFrame class that opens the second one: private void playButtonMouseClicked(java.awt.event.MouseEvent evt) { if (playerOneNameText.getText().equals("")) { } if (playerTwoNameText.getText().equals("")) { } else{ pOneName = playerOneNameText.getText(); pTwoName = playerTwoNameText.getText(); ChessBoardUI class1 = new

Print the whole program layout

家住魔仙堡 提交于 2019-11-26 23:42:53
问题 I have made a Java program ( JFrame based) using Netbeans, I would like to know if it is possible to print the layout of the program I wish to have a button and set the function to "print" and the final layout of the frame will be printed, is it possible? If yes, any reference source? 回答1: This will depend on what it is you hope to achieve. You could simply print the contents of the frame to a BufferedImage . This allows you to control what you want to capture, in that you could print the

Embed .swf file to my Jframe

北战南征 提交于 2019-11-26 23:42:29
问题 I'm having a problem in adding my swf file to my jframe. They say that i should try the JFlashplayer but it is only a trial one. Can you give me some sample code for this? 回答1: Here is my flash player adapted from the example on their website. BCFrame is essentially a JInternalFrame. You can have it extend whatever. It will need slight modification to work, but should be strait forward. You can rip out anything that doesnt exist. Other possible solutions are: jffmpeg - do a search for it http

How To Call JFrame from another Java class

别等时光非礼了梦想. 提交于 2019-11-26 23:38:06
问题 I am trying to do a simple Jform and call it from another class. I want to use this Jframe in a server client application, but I don't know how to open the JFrame class from another class. Like user has to chose 1- to open Jframe. 2- To Exit. So What am I doing wrong? Below are the codes: Jframe Class named Calculas.java /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author user */ public class Calculas extends javax.swing.JFrame { /*

JFrame not showing a picture

。_饼干妹妹 提交于 2019-11-26 23:25:58
问题 Following is the code I have so far: All the imports are correct. I'm sure. :D When I run the program, all I get is a blank frame, without the picture. It should show up. public class WindowPractice extends JFrame { final static int width= 800; final static int height= 400; int x; int y; Image steve; Dimension gamesize= new Dimension (width, height); public WindowPractice(){ setTitle ("Hangman"); setSize (gamesize); setVisible (true); setResizable (false); setLocationRelativeTo (null);

How to remove window box from any java gui

眉间皱痕 提交于 2019-11-26 23:19:41
问题 How do i remove the window box from any java program. Because i want to make it look border-less. I know any jar files running on jre automatically gets a window like this. So i want to know if there is workaround about this. Thanks in advance here is a photo what i want to do exactly 回答1: See Frame#setUndecorated You could also use a JWindow which is undecorated by default. Check this and this for example uses Updated If you remove the border, you become responsible for moving and resizing

Java Drag-n-Drop files of specific extension on JFrame

久未见 提交于 2019-11-26 23:12:30
问题 I would like to implement DnD for my application to accept only files of certain extension (eg. wrl). I would like to change the cursor to a drag cursor if the file will be accepted and revert back to normal cursor when the file of wrong extension is drag and dropped. I have been following the following tutorial/example from http://docs.oracle.com/javase/tutorial/uiswing/dnd/toplevel.html The change that I make is in the canImport function public boolean canImport(TransferHandler

Java Swing : why must resize frame, so that can show components have added

不羁的心 提交于 2019-11-26 23:08:36
I have a simple Swing GUI. (and not only this, all swing GUI I have written). When run it, it doesn't show anything except blank screen, until I resize the main frame, so every components have painted again, and I can show them. Here is my simple code : public static void main(String[] args) { JFrame frame = new JFrame("JScroll Pane Test"); frame.setVisible(true); frame.setSize(new Dimension(800, 600)); JTextArea txtNotes = new JTextArea(); txtNotes.setText("Hello World"); JScrollPane scrollPane = new JScrollPane(txtNotes); frame.add(scrollPane); } So, my question is : how can when I start