jframe

Setting minimum size limit for a window in java swing

♀尐吖头ヾ 提交于 2019-12-28 14:01:06
问题 I have a JFrame which has 3 JPanels in GridBagLayout .. Now, when I minimize a windows, after a certain limit, the third JPanel tends to disappear. I tried setting minimizing size of JFrame using setMinimumSize(new Dimension(int,int)) but no success. The windows can still be minimized. So, I actually want to make a threshhold, that my window cannot be minimized after a certain limit. How can I do so? Code:- import java.awt.Dimension; import javax.swing.JFrame; public class JFrameExample {

Open a new JFrame

有些话、适合烂在心里 提交于 2019-12-28 06:36:42
问题 I have a main JFrame that has all kinds of panels in it for different functions and people can calculate things in them. I want to open a new JFrame when the user hits the first calculate button and serve as a Output window (Simlar to SPSS output windows if you are familiar with them). The New JFrame will be completely separate and will have its own menu bar ... A simple JDialog is not the way to go here. 回答1: can't resist, simple disagree with answers JFrame frame = new JFrame( ); and frame

How do I remove the maximize and minimize buttons from a JFrame?

懵懂的女人 提交于 2019-12-28 05:58:41
问题 I need to remove the maximize and minimize buttons from a JFrame. Please suggest how to do this. 回答1: import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; public class Dlg extends JDialog { public Dlg(JFrame frame, String str) { super(frame, str); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent evt) { System.exit(0); } }); } public

Background image in a JFrame

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-28 04:28:09
问题 This question has been asked a lot but everywhere the answers fall short. I can get a JFrame to display a background image just fine by extending JPanel and overriding paintComponent, like so: class BackgroundPanel extends JPanel { private ImageIcon imageIcon; public BackgroundPanel() { this.imageIcon = Icons.getIcon("foo"); } @Override protected void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(imageIcon.getImage(), 0,0,imageIcon.getIconWidth(),imageIcon.getIconHeight()

Drag and Resize undecorated JFrame

ε祈祈猫儿з 提交于 2019-12-28 03:59:05
问题 Currently, I am using the following code to drag and move my undecordated JFrames. private void initialiseGUI(Component component){ //<editor-fold defaultstate="collapsed" desc="code"> component.addMouseListener(new MouseAdapter() { public void mousePressed(MouseEvent e) { posX = e.getX(); posY = e.getY(); } }); component.addMouseMotionListener(new MouseAdapter() { public void mouseDragged(MouseEvent evt) { //sets frame position when mouse dragged Rectangle rectangle = getBounds(); getGUI()

How to remove title bar in JFrame

泪湿孤枕 提交于 2019-12-28 02:06:10
问题 I'm using the following code for practising, http://docs.oracle.com/javase/tutorial/uiswing/examples/layout/BorderLayoutDemoProject/src/layout/BorderLayoutDemo.java I also add frame.setSize(frame.getMaximumSize()); in createAndShowGUI() method, What is more I want this window not to have the title bar, close and minimize buttons. I tried the following code, frame.setUndecorated(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); If I added this code before the pack(), it goes into

贪吃蛇系列之二——游戏窗口的建立

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-27 19:27:57
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 下面,我们废话不多说,就开始我们的贪吃蛇小项目。首先,我们打开我们的Eclipse,孤狼用的呢是比较新的版本,Eclipse 4.2.0的,没有Eclipse工具的朋友呢,可以到Eclipse的官方网站 http://www.eclipse.org/platform 进行下载。在接下来的博文中,孤狼将分多个版本来逐步的完善我们的贪吃蛇游戏。 我们建立一个新的Java项目,Snake01,在这个版本中,我们将先将游戏的窗口创建出来,那么下面,我们就开始Coding吧。最为一名好的程序员,我们最好再一开始就养成比较好的编程习惯,学会建包就是一个好的开始。首先,我们创建游戏的主窗口类GameView类,并将这个类放在com.gulang.snake.view下面,如下图: 接下来,我们开始对GameView进行编码,大家直接看代码,我会在后面进行解释: package com.gulang.snake.view; import java.awt.Color; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; public class GameView extends

I am new to programming need guidance [closed]

…衆ロ難τιáo~ 提交于 2019-12-27 07:04:40
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 days ago . I am trying to create a Jbutton and which can call my program once i click on to that button. but no luck i am pretty sure i am doing something wrong can someone help. so i have made a class demoapp. java and i want to call that using jbutton. I tried activelistener concept no help. This what i want

I am new to programming need guidance [closed]

。_饼干妹妹 提交于 2019-12-27 07:02:31
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 days ago . I am trying to create a Jbutton and which can call my program once i click on to that button. but no luck i am pretty sure i am doing something wrong can someone help. so i have made a class demoapp. java and i want to call that using jbutton. I tried activelistener concept no help. This what i want

I am new to programming need guidance [closed]

為{幸葍}努か 提交于 2019-12-27 07:02:07
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 days ago . I am trying to create a Jbutton and which can call my program once i click on to that button. but no luck i am pretty sure i am doing something wrong can someone help. so i have made a class demoapp. java and i want to call that using jbutton. I tried activelistener concept no help. This what i want