jframe

How to create partly transparent JButton on fully transparent JFrame?

徘徊边缘 提交于 2019-12-01 03:28:43
问题 I am able to make JFrame totally transparent and the JButton is partly transparent just fine until I move my mouse on the button ( do not click ) and move the mouse off from the button ( MouseExited called via MouseListener ). What happens is that the background of the JButton is drawn again, so after couple of mouse movements on and off the button the button is totally opaque. public class ButtonExample extends JWindow { public ButtonExample( ) { JButton But = new JButton( "Testing" ); But

Why isn't JMenu always on top?

≯℡__Kan透↙ 提交于 2019-12-01 02:10:14
The JMenu behaves normally until a JButton is used to update a JTable on the JFrame. Then the JMenu is mostly hidden by a JPanel (see images below). Shouldn't the JMenu always be on top when it is selected? Why has it been pushed to the back? The code that updates the table on jButtonAddActionPerformed is. public class MyClass extends javax.swing.JFrame { private void jButtonAddActionPerformed(java.awt.event.ActionEvent evt) { DefaultTableModel model = (DefaultTableModel) jTable.getModel(); model.addRow(new Object[]{"", DEFAULT_ON, DEFAULT_OFF}); int lastRow = jTable.getRowCount() - 1; jTable

Exiting an application gracefully?

ぐ巨炮叔叔 提交于 2019-12-01 01:28:09
问题 I have an application with a well defined Try/Catch/Finally chain that exits and executes the finally block just fine under normal conditions, however when someone prematurely hits the red X in the GUI, the program fully exists (code = 0) and the main thread's finally block isn't called. In fact, I do want the program to exit upon a click of the red-X, but what I do not want is a skipping of the finally{} block! I sort of put in the most important part of the finally block manually in the GUI

Is it possible to have a translucent windows in java 7 including a title bar?

元气小坏坏 提交于 2019-12-01 01:12:16
问题 Related to this question: Is The Java Tutorials Translucent Window example giving trouble to those playing with jdk7? with jdk1.6.0_26 I seem to be able to apply translucency to a JFrame, but not so with jre7: NativeException: java.awt.IllegalComponentStateException: The frame is decorated ex (jruby scripting java, works jdk1.6 not with jdk7 though): require 'java' class MouseDraw def self.go java_import 'javax.swing.JFrame' java_import 'com.sun.awt.AWTUtilities' f = JFrame.new AWTUtilities

Program not repainting upon JFrame height maximizing

自作多情 提交于 2019-12-01 01:03:51
You can resize JFrame with mouse dragging in several ways: You can resize it's height (top/bottom edge) You can resize it's width (left/right edge) You can resize both (in corners) You can maximize it by dragging the whole window to the monitor top edge You can maximize it's height by dragging it's top/bottom edge to the top/bottom edge of the monitor My program is being repainted on every one of this actions except the number 5. Why is that? Could that be bug in my program? It doesn't seem so. I don't know where would I put repaint request for that particular case... It seems that JFrame

JFrame : Getting actual content size

此生再无相见时 提交于 2019-12-01 00:48:54
问题 I have created a JFrame, and attempting to get it's size is giving an incorrect result, compared to what I expect. I have determined that it is including the operating system borders around the edges, and the title bar. How can I get/set the real size which I have available for rendering? 回答1: The size you are getting is the size of the content and the size of the insets. If you use Jcomponent.getInsets(), you can find the size of the content with simple subtraction. 回答2: Your question is

How to use setVisible in JFrames?

房东的猫 提交于 2019-12-01 00:38:34
In my program I have two JFrame instances. When I click next button I want to show next frame and hide current frame. So I use this.setVisible(false) and new Next().setVisible(true) . But in Next window if I click back button I want to set previous frame to be visible again and next frame must be ended (which means it must be exited). Is there any special method(s) to do this? How can I do it? mKorbel Consider using CardLayout instead of hunting for how many JFrames there are. Then.. only one JFrame would be needed any of Next/Back Actions will be only switching between cards There are lots of

Is there a way to have the Nimbus Look&Feel render its own windows decorations for a top level JFrame?

谁都会走 提交于 2019-12-01 00:20:11
Is there a way to have the Nimbus Look&Feel render its own windows decorations for a top level JFrame ? I've been digging through the Internet, and I'm starting to suspect it might not be possible at all. Has anyone actually succeeded with (and cared about) that? Nimbus decorations are nice and neat for internal frames , but apparently there is no way to have the same effect on JFrame s and JDialog s. I tried nimbusx (Nimbus Extensions), a library that subclasses JFrame and JDialog and allegedly applies nimbus-styled decorations to them (then you just have to instantiate nimbusx classes

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

浪尽此生 提交于 2019-11-30 23:17: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(pic); } } This code as it is just displays a collapsed frame. I would expect that the pack(); method call

How to replace JPanel with another JPanel

 ̄綄美尐妖づ 提交于 2019-11-30 20:54:34
I want to replace a Jpanel with another one in a JFrame I already search and try my code but nothing's happen this is my code : public class Frame extends JFrame { private Container contain; private JPanel reChange,reChange2; private JButton reChangeButton; public Frame() { super("Change a panel"); setSize(350, 350); setLayout(null); setLocationRelativeTo(null); setResizable(false); reChange = new JPanel(null); reChange.setBackground(Color.red); reChange.setSize(240, 225); reChange.setBounds(50, 50, 240, 225); add(reChange); reChangeButton = new JButton("Change It"); reChangeButton.setBounds