jframe

How to display html in a java application?

╄→尐↘猪︶ㄣ 提交于 2019-11-30 19:52:57
问题 Now I am working on implementing a browser in Java. I need to display the contents of a website (provided a url-address) inside a JFrame window. Is there a simple way of doing that? I tried JEditorPane, but it only supports HTML 3.2, so the contents of the website looks very weird. Thanks 回答1: I have good experience with: http://djproject.sourceforge.net/ns/ Lets you cleanly embed a browser window within a Swing application, lets you manipulate the DOM and enables calling the host application

How to make JFrame transparent?

ⅰ亾dé卋堺 提交于 2019-11-30 18:54:01
How to make JFrame transparent? I want to make my JFrame transparent. User should see the background when my JFrame is on top of it. I found another solution. Set the background color of your frame to // Set the frame background color to a transparent color yourFrameHere.setBackground(new Color(0, 0, 0, 0)); And remember to set the opacity off of the contentpane (your JPanel or other component) // turn off opacity of the content pane yourContentPaneHere.setOpaque(false); If you do not have any objection in using restricted API classes then you can do this with AWTUtilities class and

Find the location/Position of JFrame in the window

ⅰ亾dé卋堺 提交于 2019-11-30 18:37:58
I am trying to find the Starting location/position of the JFrame in order to map the mouse cursor from the JFrame window to desktop. Is there anyway to find the X,Y position of JFrame ? You can use getLocation() or getLocationOnScreen() method of JFrame which are inherited from java.awt.Component. Ajmal Muhammad P you have to implement the MouseListener Interface and call the override methods public void mouseEntered(MouseEvent me) and use MouseEvent.getX(); MouseEvent.getXOnScreen(); Jframe.getX() // that will give you location of top left X coordinate of your jframe Jframe.getY() // that

Java setFullScreenWindow() keep on top

自作多情 提交于 2019-11-30 18:29:19
I'm writing an application that is intended to be run on a dual monitor setup, with a "Display" JFrame going fullscreen on one monitor and a "Control" JFrame on the other monitor, sending instructions to the Display. I've tried two separate methods of setting the Display fullscreen; the success of each seems to depend on the OS. display.setUndecorated(true); display.setExtendedState(JFrame.MAXIMIZED_BOTH); Works in Windows, but the JFrame gets hidden under the dock/panels in OS X and Linux. My other method, utilizing GraphicsDevice.setFullScreenWindow(display); Works in all three OSes that I

Drawing shapes in JPanel over an image

若如初见. 提交于 2019-11-30 18:18:26
问题 I need to draw shapes (circle or free line) over an image that is shown in a JLabel of a JPanel. I based my code on the questions How to draw thin line with no gap while dragging the cursor? and Draw a circle using 2 mouse clicks. The code is bellow. The problem is that when I start drawing the image disappears and only reappears after I stop. If I comment the line super.paintComponent(g); that doesnt happen but when I draw the circle it maintains a path of the previous positions. public

I took this code straight out of 'Java all in one for Dummies' …why doesn't it work?

心不动则不痛 提交于 2019-11-30 17:26:34
问题 import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; @SuppressWarnings("serial") public class Picture extends JFrame{ public static void main(String[] args){ new Picture(); } public Picture(){ this.setTitle("Picture"); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); ImageIcon pic = new ImageIcon("TestImage.jpg"); p.add(new JLabel(pic)); this.add(p); this.pack(); this.setVisible(true); System.out.println

How to make JFrame transparent?

£可爱£侵袭症+ 提交于 2019-11-30 16:57:28
问题 How to make JFrame transparent? I want to make my JFrame transparent. User should see the background when my JFrame is on top of it. 回答1: I found another solution. Set the background color of your frame to // Set the frame background color to a transparent color yourFrameHere.setBackground(new Color(0, 0, 0, 0)); And remember to set the opacity off of the contentpane (your JPanel or other component) // turn off opacity of the content pane yourContentPaneHere.setOpaque(false); 回答2: If you do

Why JFrame redefine the “EXIT_ON_CLOSE” which it inherits from interface “WindowConstants”?

爷,独闯天下 提交于 2019-11-30 15:51:37
问题 WindowConstants is defined as this: public interface WindowConstants { public static final int DO_NOTHING_ON_CLOSE = 0; public static final int HIDE_ON_CLOSE = 1; public static final int DISPOSE_ON_CLOSE = 2; public static final int EXIT_ON_CLOSE = 3; } JFrame is defined as this: public class JFrame extends Frame implements WindowConstants, Accessible, RootPaneContainer, TransferHandler.HasGetTransferHandler { /** * The exit application default window close operation. If a window * has this

JFrame and Nimbus Look And Feel

别等时光非礼了梦想. 提交于 2019-11-30 15:42:53
I use Nimbus Look and Feel in a project. However, although every GUI JComponent have a Look and Feel of Nimbus, JFrame always have Windows Look and Feel. How can JFrame have Nimbus Look And Feel? Edit: Operating System : Windows XP Marek Sebera Try using this: JFrame.setDefaultLookAndFeelDecorated(true); //before creating JFrames For more info., see How to Set the Look and Feel in the tutorial. import javax.swing.*; class FrameLook { public static void showFrame(String plaf) { try { UIManager.setLookAndFeel(plaf); } catch(Exception e) { e.printStackTrace(); } JFrame f = new JFrame(plaf); f

JFrame: How to disable window resizing?

青春壹個敷衍的年華 提交于 2019-11-30 12:41:42
问题 I am creating a JFrame and I call the method setSize(500, 500) . Now the desired behaviour is that JFrame should not be resized by user in any condition. Either by maximizing or by dragging the borders. It should be 500x500. How can I do it? I have also attached the code in case you can guide me better. package com.techpapa; import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MainWindow extends JFrame{ private JTextField write; private JRadioButton rb1, rb2, rb3;