jframe

Transparent JPanel

六月ゝ 毕业季﹏ 提交于 2019-11-28 10:01:58
I want to create a semi-transparent JPanel. I've done it by simply using RGBA value of color constructor but problem is when i m using event handling is not woking properly. My requirement is a semi transparent Jpanel when mouse enters it border of this panel became visible and if mouse exit the border shoud not visible. I have done this by following code but problem is its not working properly for transparent backgroud (RGBA) but it working fine for RGB color. import javax.swing.*; import javax.swing.border.*; import java.awt.*; import java.awt.event.*; public class MDCW extends JFrame {

Undecorated JFrame shadow

北慕城南 提交于 2019-11-28 09:59:21
问题 How do you add a shadow to a undecorated jframe? From what I found online, you might be able to add the jframe to another black translucent window to give a shadow effect. Or somehow apply something like this to a JFrame: Border loweredBorder = new EtchedBorder(EtchedBorder.LOWERED); setBorder(loweredBorder); Either way I just want to know the best method or maybe a completely different way of getting the same effect like extending from another class and not jframe. I'm new to Java so I might

How to disable main JFrame when open new JFrame

亡梦爱人 提交于 2019-11-28 09:51:10
Example now I have a main frame contains jtable display all the customer information, and there was a create button to open up a new JFrame that allow user to create new customer. I don't want the user can open more than one create frame. Any swing component or API can do that? or how can disabled the main frame? Something like JDialog. I would suggest that you make your new customer dialog a modal JDialog so that you do not allow input from other dialogs/frames in your app while it is visible. Take a look at the modality tutorial for details. I think you should use this code for the main

Frame and Canvas grow larger than specified

血红的双手。 提交于 2019-11-28 09:42:19
问题 I have no idea why I am getting an extra-large window, this is making me run hoops to fit my sprites in the game-window. The constructor should make it so all the subcomponents fit into eachother, but it seems like there is some extra padding in the canvas or frame. I am having a tough time figuring out what the culprit is. The size of my frame should NOT be larger than 800x600 (OS decoration not included, talking about the containers). Panel: java.awt.Rectangle[x=0,y=0,width=810,height=610]

Setting minimum size limit for a window in java swing

早过忘川 提交于 2019-11-28 09:39:10
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 { public static void main(String[] args) { JFrame frame = new JFrame("Hello World"); frame

Change Jframe Shape

情到浓时终转凉″ 提交于 2019-11-28 09:23:39
问题 In c# you could change the form shape to be as some picture shape that you draw.. I wonder if there is the same option to do this on jFrame in java? (I'm using netbeans) and for example this is the picture I want to be used as the jFrame shape so inside the "phone screen" I want to add some buttons.. is it possible? 回答1: Android Look and Feel Everything on an Android screen is a rectangle. Widgets are rectangles. Launcher icons are 96 x 96 pixel squares. The text under a launcher icon makes

Drawing an Image to a JPanel within a JFrame

坚强是说给别人听的谎言 提交于 2019-11-28 09:19:14
I am designing a program that contains two JPanels within a JFrame, one is for holding an image, the other for holding GUI components(Searchfields etc). I am wondering how do I draw the Image to the first JPanel within the JFrame? Here is a sample code from my constructor : public UITester() { this.setTitle("Airplane"); Container container = getContentPane(); container.setLayout(new FlowLayout()); searchText = new JLabel("Enter Search Text Here"); container.add(searchText); imagepanel = new JPanel(new FlowLayout()); imagepanel.paintComponents(null); //other constructor code } public void

Java Swing JFrame Layout

柔情痞子 提交于 2019-11-28 09:15:53
I just wrote a simple code where I want a textfield and a button to appear on the main frame, but after running all I see is the textfield. If I write the code of the button after the textfield then only the button is displayed. Any idea why? JFrame mainframe=new JFrame(); mainframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mainframe.setBounds(0,0,200,200); JButton jb=new JButton(); jb.setText("Leech"); mainframe.add(jb); JTextField link=new JTextField(50); mainframe.add(link); mainframe.pack(); mainframe.setVisible(true); Ibrahim Add your components to a JPanel and then add that panel

Java Swing on high-DPI screen

与世无争的帅哥 提交于 2019-11-28 09:08:40
I have a Java Swing program that uses the System Look And Feel: UIManager.setLookAndFeel (UIManager.getSystemLookAndFeelClassName ()); The problem is that on a high-DPI system, the fonts in the frames are way too small. How can I make the text on my frames readable without having to change the fonts for ALL the frames? My program was written using Java 6 and has too many frames to modify. You could physically modify the look and feel's font settings... import java.awt.EventQueue; import java.awt.Font; import java.util.Set; import javax.swing.JFrame; import javax.swing.JLabel; import javax

How do you make key bindings for a java.awt.Frame?

二次信任 提交于 2019-11-28 08:57:39
问题 Background My window is a java.awt.Frame, and inside of the Frame are two Panels (java.awt.Panel). I'm trying to make it so that the window handles buttons I press. Try Number 1 I tried using a KeyListener, making the Frame implement the KeyListener. I added the KeyListener to the Frame, but the KeyListener functions didn't do anything when I pressed keys. (I tried printing with System.out.println().) Try Number 2 I tried following this tutorial: http://tips4java.wordpress.com/2008/10/10/key