jframe

How to restart a JFrame when creating a multiple level game?

人走茶凉 提交于 2019-12-08 11:33:44
问题 I have a one level computer game that I created , and I want to add another level . Here is the Main : public class Main extends JDialog { private static final long serialVersionUID = 1L; protected static TimerThread timerThread; static JStatusBar statusBar = new JStatusBar(); private static JFrame frame; private static final int FRAME_LOCATION_X = 300; private static final int FRAME_LOCATION_Y = 50; private static final int FRAME_SIZE_X = 850; // animator's target frames per second private

Is it possible to draw an image or text on a JFrame?

♀尐吖头ヾ 提交于 2019-12-08 11:28:34
问题 Is it possible to draw on a JFrame without adding a JPanel to it? i override paintComponents() but it didn't show anything. @Override public void paintComponents(Graphics g) { super.paintComponents(g); g.drawString("for test", 10, 10); } 回答1: Yes, it is. You'll want to work with the one of the panes in the JFrame such as the content pane or the glass pane, which you can access via getContentPane, etc. For example the content pane is a Container, with a variety of add methods. To that you can

Displaying Google Calendar in Java JFrame

﹥>﹥吖頭↗ 提交于 2019-12-08 11:17:34
问题 I am having trouble displaying a google calendar in a java jframe. Edited: I do see the google calendar, but it is has a blue background and it makes it difficult to view events. Here is a snipit of my code temp is the google username. private void getGoogleCalendar(){ googlepane=new JPanel(new BorderLayout()); String s="https://www.google.com/calendar/b/0/htmlembed?src=groupboba@gmail.com&ctz=America/New_York&gsessionid=OK"; JEditorPane tp=new JEditorPane(); try { HTMLEditorKit kit = new

How to get transparent JFrame?

匆匆过客 提交于 2019-12-08 09:12:33
问题 When I try to run to get transparent frame it shows exception. My code is: public class NewJFrame extends javax.swing.JFrame { public NewJFrame() { initComponents(); com.sun.awt.AWTUtilities.setWindowOpacity(this, 0.05f); } Exception is: Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated at java.awt.Frame.setOpacity(Frame.java:960) at java.awt.Window$1.setOpacity(Window.java:4032) at com.sun.awt.AWTUtilities.setWindowOpacity(AWTUtilities

Can you put JFrames inside Full Screen Exclusive Mode?

自古美人都是妖i 提交于 2019-12-08 08:24:45
问题 To be honest, I didn't quite know how to express my question in the title. So if someone has a clearer idea of what i'm trying to ask, then please be so kind as to edit it, for the greater good of mankind. I have the following code: public class Main { public static void main(String[] args) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); GraphicsDevice gd = ge.getDefaultScreenDevice(); JFrame frame = new JFrame(); Window window = new Window(frame); JButton btn =

Layering many JPanels and adding them on the fly

醉酒当歌 提交于 2019-12-08 08:15:30
问题 I'm developing a sim game based on Theme Hospital, which is quite an old game. I've made lots of progress on the underlying workings, however now I am coming to the GUI elements, which I haven't done alot of before. I am still rather new to java. The effect I am trying to create is like shown here... http://www.tubechop.com/watch/18438 Click on a button, opens up a panel with tabs to select from different selections, and then click a button to build a room. I believe for the "tabs" I can use

Java, How to refresh JTable in one frame from another frame

帅比萌擦擦* 提交于 2019-12-08 08:09:49
问题 So I have a MainFrame class which has a JTable in it, listing all Products stored in DB. The JButton with the help of listeners will open AddProduct (another class, and another window/frame) in which I can add product in the DB. Unfortunately, I'm not exactly sure how can I update/revalidate JTable in MainFrame once AddProduct adds new product and autocloses. Could some please give me some idea as how can I easily resolve this? Since program is rather large, here are relevant parts of it:

Adding text to a label from another class - Simple Logic Issue

我的未来我决定 提交于 2019-12-08 07:37:20
问题 I have a label and a button in a class called FrameTest , when i press the button, a method named buttonpressed get's executed from the class Test . In this buttonpressed method i will set a text to the label found in the FrameTest class. The problem i have is that, the text for the label is not getting set. The reason is that i am creating a separate object to call the buttonpressed method; public void actionPerformed(ActionEvent arg0) { Test t = new Test(); t.buttonpress(); } and i am

How to add a time delay in JFrame?

喜夏-厌秋 提交于 2019-12-08 07:28:49
问题 I am building a chat room in JFrame . I want the JFrame to refresh each 200ms so that whenever a new text is entered, it will appear inside the JFrame . I tried using while(true) but JFrame freezes. How to add timer to the code? 回答1: I am building a chat room in JFrame. I want the JFrame to refresh each 200ms so that whenever a new text is entered, it will appear inside the JFrame. I tried using while(true) but JFrame freezes. How to add timer to the code? disagree, JFrame can't be refreshed

Adding JFrame to JApplet

╄→尐↘猪︶ㄣ 提交于 2019-12-08 06:33:55
问题 Can I add program based on JFrame to JApplet ? How can I do that, when I try to do it like: public class Test extends JApplet{ public void init(){ JFrame frame=new JFrame(300,400); add(frame); frame.setVisible(true); } I got an error when i try to use appletviewer. Can anyone help me ? 回答1: You can't add a frame to an applet, but you can add an applet to a frame: import javax.swing.*; import javax.swing.event.*; import java.awt.*; import java.awt.event.*; public class AppletBasic extends