jframe

How do I rework my Java applet code to use a JPanel instead of a JFrame?

假装没事ソ 提交于 2019-12-24 05:45:45
问题 I'm a .net programmer just learning Java. I've been working on this issue for the past 2 weeks... Here is my code to show my security system webcams and update the images in a JFrame running in an applet: (I need to convert this code to work in a JPanel instead!) public class Streamer extends JApplet { String PATH = "C:/Security/CamCap/"; Integer UPDATE_INTERVAL = 100; String CAM1FILE = "current1.png"; String CAM2FILE = "current2.png"; String CAM3FILE = "current3.png"; String CAM4FILE =

How can I set the size of this GUI?

99封情书 提交于 2019-12-24 05:27:11
问题 I have an applet (and this is an SSCCE): package tutoringcalculator; import java.awt.BorderLayout; import java.awt.FlowLayout; import javax.swing.*; public class TutoringCalculator extends JApplet { private JPanel _root; public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JFrame frame = new JFrame("Tutoring Calculator"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JApplet applet = new TutoringCalculator(); applet.init();

Can I place image outside JFrame?

十年热恋 提交于 2019-12-24 04:12:29
问题 Can I place an image outside JFrame ? I am developing an app, and I wanted to make the Gui good looking and some part of the buttons should go outside. Is there a way to do this? 回答1: Yes, but it's not going to be easy, as you going to constantly need to monitor the position of the parent frame in order to maintain the position of the child window. Essentially, what you can do is create a second, undecorated and transparent window. You would need to align and size the window next to the

Can I place image outside JFrame?

為{幸葍}努か 提交于 2019-12-24 04:12:21
问题 Can I place an image outside JFrame ? I am developing an app, and I wanted to make the Gui good looking and some part of the buttons should go outside. Is there a way to do this? 回答1: Yes, but it's not going to be easy, as you going to constantly need to monitor the position of the parent frame in order to maintain the position of the child window. Essentially, what you can do is create a second, undecorated and transparent window. You would need to align and size the window next to the

Swing menu item selection not setting content in the contentpane

回眸只為那壹抹淺笑 提交于 2019-12-24 02:45:25
问题 I have a Swing JFrame, which has a bunch of menu items. The below code tries but fails to set the content of the JFrame on selection of 'Add Address' menu item. JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setResizable(false); frame.setVisible(true); JMenuBar menuBar = new JMenuBar(); JMenu clientMenu = new JMenu("Client"); JMenuItem address = new JMenuItem("Add Address"); clientMenu.add(address); menuBar.add(clientMenu); address.addActionListener

Multiple instance of ONE JFrame

て烟熏妆下的殇ゞ 提交于 2019-12-24 02:43:16
问题 In Java, I have 2 classes. One contains a JFrame. On startup, that class is called. The JFrame shows. But in the other class, when I press a button on it's own frame, it opens a new instance of that class which should make another frame. But it just focuses on the old frame already opened... Source: FrameToOpen.java public FrameToOpen() { JFrame frame = new JFrame(); // Just the most simple settings to make it appear... frame.setSize(400, 200); frame.setVisible(true); } OtherClass.java public

Multiple instance of ONE JFrame

浪尽此生 提交于 2019-12-24 02:43:08
问题 In Java, I have 2 classes. One contains a JFrame. On startup, that class is called. The JFrame shows. But in the other class, when I press a button on it's own frame, it opens a new instance of that class which should make another frame. But it just focuses on the old frame already opened... Source: FrameToOpen.java public FrameToOpen() { JFrame frame = new JFrame(); // Just the most simple settings to make it appear... frame.setSize(400, 200); frame.setVisible(true); } OtherClass.java public

What should I use instead of FlowLayout()?

不打扰是莪最后的温柔 提交于 2019-12-24 01:47:22
问题 So, my JFrame is not turning out the way I want it to, because of the FlowLayout() but I don't know what else to use to fix this. It just makes my JButton fill the entire JFrame . Is there a way I can get FlowLayout() to apply my custom sizes and location for the JFrame components, or is there an alternative that could easily replace it? Here is my code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class MTGSAMPServerReference extends JFrame implements

JPanel size is not known on start

▼魔方 西西 提交于 2019-12-24 00:20:06
问题 When I create a Board instance from my Square instance, I try to assign the size of the window to the integers x and y. I fail to do this because it seems like on start the size is 0. In the constructor in Board.java, x and y shouldn't be -50 like they end up now. Square.java: package Square; import javax.swing.*; public class Square extends JFrame { public Square(){ add(new Board()); setSize(800, 800); setVisible(true); } public static void main(String[] args){ new Square(); } } Board.java

How to left align JFrame Title text between different OSs

烈酒焚心 提交于 2019-12-24 00:15:31
问题 It looks like the OS is controlling the whole JFrame title bar. I tried using: UIManager.setLookAndFeel() To change the Look and Feel, but it doesn't seem to affect the title bar. On my Windows machine the default is left aligned, but on my Linux machine it's centered, and somehow, I'd like to try to always show the title text left aligned. I saw one example where they basically built every element of the title bar from scratch, and I'd rather not go there. Is there any other way to do it?