jframe

Java :Painting Random Shapes on JFrame against Music Played

坚强是说给别人听的谎言 提交于 2019-12-11 08:15:06
问题 I am trying to paint JFrame when music is played , these shapes are created on random no calculation and when a there is some music played there pops up a JFrame and these shapes are painted there, problem is that when i run this code there is no musical sound and shapes drawn but just a frame pops up and nothing else , Plase check this code and help me to correct it .. public class MusicBeatsDrawing { static JFrame frame; DrawPanel dp =new DrawPanel(); public static void main(String[] args)

what is Alternative of Paint and repaint function?

时光总嘲笑我的痴心妄想 提交于 2019-12-11 07:52:12
问题 Is there any function which can be replaced with paint() and repaint() in java. I have a scenario. There is a triangle (Triangle 1) . when user will click in triangle another triangle (Triangle 2) will appear and 1st (Triangle 1) will be removed from screen. (coded using JFrame , paint() and repaint() ) I have achieved it so far. but problem is when I minimize or change size of window with mouse the output window, it just paint again Triangle 1 rather than Triangle 2 . OR Clear the whole

Removing a Frame's title bar keeping the resize mechanims - Java

こ雲淡風輕ζ 提交于 2019-12-11 07:29:52
问题 My problem is related with what Jonas asked on the next topics: How to add support for resizing when using an undecorated JFrame? How can I customize the title bar on JFrame? I want to create a custom window without the native title bar. This can be done by calling: setUndecorated(true); However, this also removes the re-size mechanism. So now I am using the next code: public UndecoratedFrame() { this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME); menu.add(item); menuBar.add(menu);

How can I change the size of a System.out.println local variable inside a JFrame

眉间皱痕 提交于 2019-12-11 06:54:55
问题 I modified some code I found to display a local variable instead of set text inside of a JFrame, but I'm unable to find a way to change the size of the text. I keep reading about frameName.setFont(new Font(____)), but that doesn't seem to be working for the println. How would I modify the text size? Here's my current code. (P.S. I'm new, so I'm sorry that i don't know what I'm talking about.) import java.util.*; import java.io.*; import java.awt.*; import javax.swing.*; import java.time.*;

Deleting last keystroke in JTextField if invalid

守給你的承諾、 提交于 2019-12-11 06:37:28
问题 Working on my 1st program. I figured out how to identify characters I do not want to be able to be inputted. I would like to know how do delete the last character entered so that from a user perspectvive it will appear as only numbers can be entered. @Override public void keyPressed(KeyEvent e) { char keyChar = e.getKeyChar();; char[] badCharArray = "abcdefghijklmnopqrstuvwxyz-`~!@#$%^&*()[]{}<>_+=|\"':;?/ ".toCharArray(); for (int i = 0; i < badCharArray.length; i++) { if (badCharArray[i] ==

How to setVisible a JinternalFrame in the center of the JdesktopPane?

China☆狼群 提交于 2019-12-11 06:37:10
问题 Actually i wanna show the JinternalFrame in the center of the JDesktopPane and i used this methode as i use it in Jframes but it didn't work : Extraction ex=new Extraction();//Extraction is the name of the JintenalFrame jDesktopPane1.add(ex); ex.setLocationRelativeTo(this); ex.setVisible(true); So i am asking if there is another methode so i can display the JinternalFrame in the center of the JdesktoPane. Thank you 回答1: A javax.swing.JInternalFrame lacks the convenient setLocationRelativeTo

How to create customize title bar with close button on jFrame?

你离开我真会死。 提交于 2019-12-11 06:26:34
问题 I want to create a customised title bar for my JFrame . I can remove the default title bar with JFrame.setUndecorated(true) Now i need to create a customised title bar for my JFrame with a close button? 回答1: Without having done that ever, I think I would go this way: Indeed set the JFrame to undecorated Extend JRootPane to add an additional field titleBar Create a TitleBar component holding the title, the close button, etc... Set a new LayoutManager on that JRootPane (have a look at JRootPane

How do I make a JFrame a certain size, not including the border?

走远了吗. 提交于 2019-12-11 06:25:46
问题 I have a JFrame that I've set to a certain size, using setBounds. However, that makes the window, including the borders, that size (which in hindsight makes complete sense). But what I want is for the size of the window it be, say, 800x600 plus the borders. This is important because I'm drawing to a Graphics object from the BufferStategy from the JFrame, but I've been drawing underneath the title bar when using a y value of less than about 20. I imagine different OSs (or even different OS

Deleting a single Line through a JButton in a TextArea

為{幸葍}努か 提交于 2019-12-11 06:09:39
问题 I want to delete a single line through a JButton in Jframe. But I don't know how... I allready tried: public void button1_ActionPerformed(ActionEvent evt) { int count = 1; count = TextArea1.getLineCount(); But it's not working... I appreciate every kind of help :)) Or anyone knews another method to solve this problem? 回答1: You need to use GetText() to get what is already in the TextArea and then remove the line. Once you have modified the text you can put it back using SetText(). Of course

JFrame Resizing in Desktop Application - NetBeans

混江龙づ霸主 提交于 2019-12-11 05:58:19
问题 I'm developing Java Desktop Application in NetBeans IDE. I want to show the login screen in JFrame with small size. Then after getting login i want to extend JFrame to full screen with other panels.The problem is its showing once properly and from the next time it used to show the login screen with full screen.How can i avoid it? I'm placing different panels on the same frame. While login this.getFrame().setExtendedState(Frame.NORMAL); this.getFrame().setSize(360, 233); this.getFrame()