JFrame « Button « Java Swing Q&A





1. JButton expanding to take up entire frame/container    stackoverflow.com

Hey everyone. I'm trying to make a swing GUI with a button and a label on it. im using a border layout and the label ( in the north field ...

2. closing my jframe without using the close(X) button and terminating the JVM    stackoverflow.com

i have a frame that instantiates another frame but i don't want to use the close(x) button on the instantiated frame., so i created a button. how do i code that ...

3. managing parent frame from child frame on java swing    stackoverflow.com

I have a jframe (parent) which creates an input frame (child) where I get some parameter. In the "child" frame I have "ok" and "cancel" buttons. When "ok" button is pressed, the ...

4. using buttons in netbeans gui frame    stackoverflow.com

Ok, so I'm pretty noob at JAVA, and programming in general really. I'm trying to make a rock, paper, scissors app that with run with a GUI interface. What ...

5. How to make a JFrame have no taskbar button?    stackoverflow.com

I would like to have a normal JFrame with its full functionalities (decoration, title, icon, resizing, minimizing, maximizing, etc.), with the only thing that it wouldn't appear in the system's taskbar. (Typically, ...

6. How to adjust position of JButton if the parent JFrame is resized?    stackoverflow.com

I have some JButtons in a JFrame. The layout of JFrame is null. i have given absolute position to button. But when i minimize or maximize frame, the postion of the buttons ...

7. Java Swing Maximize button of JFrame disappearss    stackoverflow.com

I have created a java frame. It contains a JSplitPane. In the right partition of the splitpane , I have put JTextPane. Now I have kept JButton somewhere on the frame. ...

8. Closing JFrame with button click    stackoverflow.com

I have the jButton1 private member of JFrame and i wanted to close the frame when the button is clicked.

jButton1.addActionListener(new ActionListener() {
          ...

9. How can I close a JFrame by click on a button?    stackoverflow.com

I would like to have a button in my window such that if I click it (button) the window is closed. I found out that I can close a window in the ...





10. How to close a JFrame based window with a JButton click event    stackoverflow.com

I am new to the whole Java Swing/AWT dialogs (which explains how amateurish this dialog below looks like, any help in arranging it better is welcome :) and I am struggling ...

11. How to place a JButton at a desired location in a JFrame using java    stackoverflow.com

Hey, I want to put a Jbutton on a particular coordinate in a JFrame. I put setBounds for the JPanel (which I placed on the JFrame) and also setBounds for the ...

12. JButtons fail to appear in the JFrame    stackoverflow.com

I have code that displays a menu and 4 JButtons in a JFrame. I tested the code last night and everything was working fine. Now the JButtons do not appear in ...

13. What affects the enabled status of the zoom button on a JFrame for Mac?    stackoverflow.com

I have a Java program that I wrote that changes whether or not a JFrame is resizable depending on application state. In Windows this works great, when it is resizable the ...

14. actionlistener returning a nullexception on jbutton    stackoverflow.com

I have an action listener set up on my main jframe menu for the buttons listed on it, and they work fine, bringing up other jframes as needed. The problem is ...

15. How do I save preference user settings in Java?    stackoverflow.com

For example, I have a window with a preference button. I want to make it so that when user press the preference button and checks his/her appropriate options and press ok, it ...

16. Launching JFrame from a button    stackoverflow.com

I've got the following button...

    public void actionPerformed(ActionEvent arg0) {
    Contacts contact = new Contacts();
    contact.setVisible(true);
    }
Contacts is just ...





17. How would I be able to access (click buttons, type text) to Java AWT / Swing Frames from another application?    stackoverflow.com

I work with application testing and would like for our integration testcode (written in Java and using among other stuff Selenium Webdriver) to access frames executed in a different JVM (launched ...

18. refresh JFrame and adding buttons in loop    stackoverflow.com

i am adding new compnent to jframe at run time than i write validate(); and repaint(); but nothing is happing also is there a way to add buttons using loop so each ...

19. How to make JButton event modify JFrame (this)    stackoverflow.com

I'm trying to make a JButton click event modify the JFrame the button is on. The problem is the class itself is the JFrame (extending from it), so I can't ...

20. How would I use a button in Java to open an existing frame in the same package?    stackoverflow.com

I have a bunch of jFrames in the same package. How would I go about opening all of them using buttons from one "Master Frame". i.e

  • Master Frame named "Bob" has a bunch ...

21. Opening a static form/jFrame on clicking on button    stackoverflow.com

I have two JFrames. The first one is defined as public firstJframe and the second one is defined as public static final jFrame. I want to open the second JFrame on ...

22. Maximizing JFrame components on clicking windowmaximize button    stackoverflow.com

i have build a jframe in eclipse using windobuilder pro plugin .
now,i want that when i maximize the jframe ,the textarea and panel in which it is contained also maximizes.
here is ...

23. Can I add more than on button to a java JFrame?    stackoverflow.com

I am facing a problem, I want to add more than a button to a JFrame, but it only takes the last one and puts it into the frame, a sample ...

24. Trying to create a clickable button but get thrown error when compiling    stackoverflow.com

CountingNumbers is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener is the error i get. My Code:

//Create an application that counts the number of each letter in a given word/phrase
//have ...

25. closing a JFrame with a button without terminating the program    stackoverflow.com

There are two frames and when you click on a button on the first frame it opens the second frame. On the second frame I'm trying to create a button which ...

26. Having 2 separate close buttons for 2 JFrames?    stackoverflow.com

I am making a small application, with a JMenuBar, now, I got a menuitem, which is a store, which opens a new JFrame. When I click the button, a new JFrame ...

27. JButton subclass that sets itself to be the default button for a JFrame    stackoverflow.com

How to create a subclass of JButton that makes itself the window's default button? I understand that designating a default button is set on the JRootPane rather than the button itself. Instead ...

28. How can i add this button inside the canvas of Java?    stackoverflow.com

How can i add the button ontop of this canvas? like floating... on top instead of having it in the grid using add(button);

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Myscreensaver extends Window 
{
 ...

29. How do I go about putting a JButton in the chrome of a JFrame?    stackoverflow.com

Possible Duplicate:
How can I customize the title bar on JFrame?
Firefox 4 introduced a button that is flush to the edge of its frame. Opera ...

30. Buttons all over the window - Java    stackoverflow.com

I am trying to learn java and i am practicing with a simple program with 2 simple buttons. Here is my code :

 import javax.swing.*;

public class Main {

    ...

31. Java Swing inactive button for window close    stackoverflow.com

I am trying to create a gui using swing. I have a main frame and I want it to only show the x button at the top right corner. I would ...

32. Start and Reset Button    stackoverflow.com

How I could create a Start Button, which start my calculation and repaint in Java(Eclipse)? I try it with if(permission==true) but this do not work. The same is the with the Reset Button. In ...

33. Close JFrame from a JButton process remain alive    stackoverflow.com

I have a class developed with windowbuilderpro that i want to close also from a JButton further than with the standard X button on the window, so here the example of ...

34. JButton Form within Click    stackoverflow.com

is it possible when I click a JButton in my Java UI they'll be another JFrame that pops out and it includes other Forms or other layout? for example, I click ...

35. Using buttons to modify a new JFrame - How do I make it so the button opens the frame just once and not open up a new frame each time?    forums.netbeans.org

I'm able to modify the new JFrame just fine... but I'm not sure how to make it so the buttons modify just that one frame only and not keep having to ...

36. question about jframe, is actually about programming a button please help    forums.netbeans.org

hi guys, im new at this forum, well im making a project about a simple math operation in netbeans in jframe swing, the thing is that i need the code to ...

37. Invoke jFrame with jButton    forums.netbeans.org

Hi, I am pretty new in java and netbeans. I have 2 jFrames in my project. Both of them have separate controls on it like jbutton, jlabel, jtextbox etc. Now what i want is the when i click on jButton on jFrame1, it should display the other jframe. Can anyone please help me. Thanks in advance.

38. Minimize button in JFrame    coderanch.com

I shall try to tell my understanding (it is not an absolute truth): "The delegation event model is more selective, delivering events only to components that indicate interest in the particular type of event by calling enableEvent(long) or adding a listener to the component." Window.WINDOW_ICONIFIED event happens without any listener adding. It is because it is OS event, external to application. ...

39. New button to JFrame    coderanch.com

40. JFrame Maximize button    coderanch.com

41. trying to creat JFrame with buttons    coderanch.com

42. Adding a button to a JFrame    coderanch.com

44. how to open a new form or jframe while clicking a button in swing    coderanch.com

Hi friends, This is the first time i'm working with swing.I dont know how to accomplish certain tasks! so i need your help. Can any one please tell me how to open a jframe or a gui while clicking a button. I tried a lot but i cant figure it out. I have given my sample coding here.If it is wrong ...

45. closing jframe with button question.    coderanch.com

46. JFrame freezing when a Start button is added    coderanch.com

Hello all, My program has a SimController class which holds most of the logic for executing a simulation run. Before, it was in the method startSimulation(), which the constructor ran. The first thing this code does is fire a JOptionPane message. Upon clicking OK, the code executes. We now want to control when the startSimulation() method runs by adding a Start ...

47. How to create a JButton with an ActionListener that will allow me to quit JFrames .    coderanch.com

package mygui; import javax.swing.*; import java.awt.*; import java.awt.Color; import java.awt.event.*; public class FirstFrame { public static void main(String[] args) { JFrame myframe = new JFrame("my frame title"); myframe.setVisible(true); myframe.setSize(300,200); myframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JMenuBar mymenu = new JMenuBar(); mymenu.setOpaque(true); mymenu.setBackground(new Color(154, 165, 127)); mymenu.setPreferredSize(new Dimension(300,20)); myframe.setJMenuBar(mymenu); JPanel mypanel = new JPanel(); JLabel label = new JLabel("my label"); JButton mybutton = new JButton("New Window"); JButton ...

48. Creating new JFrame on click of JButton    coderanch.com

Hi.. I am creating a swing applicaiton. I have created a Jframe with a button. when I click on this button it should display data which I retrieved from DB in a different window. After disposing new window control should come back to main window. Or is it possible to use anyothe component/container for new window. Can any one help me? ...

49. How To Open a JFrame Form from a jButton    java-forums.org

yeah it wont compile....and i dont know what code to add around it that makes this button work here is the MainMenu form Java Code: /* * MainMenu.java * * Created on March 18, 2010, 2:29 PM */ package javaapplication2; /** * * @author sachinparmar */ public class MainMenu extends javax.swing.JFrame { /** Creates new form MainMenu */ public MainMenu() { ...

50. JFrame-buttons missing    java-forums.org

Hi helpers, I have two small JFrame-problems (second is worst). First wat I want. I want to serialize a drawing in an applet. Because of disk-access being blocked I decided to use XMLSerializer and let the user copy the XML by hand. It works. Therefore I use a custom JDialog (called TextFrame) with a JTextArea in scrollbars. The constructor needs a ...

51. How to open new JFrame with clicking on button?    java-forums.org

Hi, I have another question. I need to create a "log in" window. I created username text field, password field button ok and button cancel. My question is: What I need to do if I want that after a user enters username and password and then click button ok, that the application opens new window with some other options, new JFRame. ...

52. How to make JButtons as big as possible and rezise when resizing JFrame?    java-forums.org

import java.awt.Font; import java.awt.GridLayout; import javax.swing.*; public class Foo5b extends JPanel { private static final String TEXT = "Text"; private static final float TEXT_POINTS = 40; private static final float BTN_POINTS = 28f; private static final int EB_GAP = 10; private String[] btnTexts = {"Play", "Load", "Stop"}; public Foo5b() { JLabel textLabel = new JLabel(TEXT, SwingConstants.CENTER); textLabel.setFont(textLabel.getFont().deriveFont(TEXT_POINTS)); textLabel.setBorder(BorderFactory.createEmptyBorder(EB_GAP, EB_GAP, EB_GAP, EB_GAP)); ...

53. How can i close a Jframe window using a jbutton applied in my program?    java-forums.org

here is my code., pls help me., import java.awt.Color; import java.awt.Cursor; import java.awt.GridLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JButton; public class MyWindow { private static JPanel myPanel () { final JPanel panel = new JPanel(); panel.setLayout(new GridLayout(6,2)); panel.setBackground(Color.green); panel.add(new JLabel("Rf:")); // Add JLabel object final JTextField textField1 = new JTextField (); panel.add(textField1); // ...

54. Calling another JFrame from a JFrame through a JButton...(Help Reqired)    java-forums.org

I have a JFrame(say, JFrame A) that consists of a JButton. This action calls another JFrame(say, JFrame B). B consists of a method that has Thread.sleep(2000) statement. Now what happens is that, when i click the button, only the window for B appears and no contents are displayed. The Thread.sleep() statement is executed first and then rest of the components in ...

55. little help for Jframes,buttons and quicktime    java-forums.org

little help for Jframes,buttons and quicktime Hi to all My name is Dimitrios and i am developing a program which is consisted by a client program and a server program. The purpose of the application is to stream video (TV channels) to the client.The server program is used to authenticate the client (at the moment) where the client after ...

56. Link between two JFrame using JButton    java-forums.org

57. Help with JButtons into JFrame    java-forums.org

public class TicTacToe { public static void main(String[] args) { createMode(); } public static void createMode() { Settings mode = new Settings(); mode.setSize(400,400); mode.setTitle("Mode Of The Game"); JButton cmp=new JButton("Player vs Computer"); cmp.setSize(150,50); cmp.setLocation(150,50); JButton plyr=new JButton("Player vs Player"); plyr.setSize(150,50); plyr.setLocation(120,150); mode.add(cmp); mode.add(plyr); mode.setVisible(true); } } class Settings extends JFrame { public void paint (Graphics g) { super.paint(g); g.setColor(Color.black); String str="Choose ...

59. JFrame button question!    java-forums.org

I'm working on a simple artificial intelligence program as my final project for my Java class. I am currently having trouble locating example code both in my textbook and on the internet. I am trying to make an existing window open when I click on a JButton in another window. Nothing I have tried has worked, so if someone could simply ...

60. JFrame close button    forums.oracle.com

61. Strange Isuue with Jframe and Jbutton program    forums.oracle.com

I'm extremely new to Java. I do have a background in general programming with PHP and C++. I'm currently enrolled in a java class, and one of the projects is giving me a strange error. I've had the teacher look at it, and I've spent 4ish hours poking and prodding it trying to get it to work. The Idea is a ...

62. Close JFrame by button    forums.oracle.com

63. Closing a Jframe with a button    forums.oracle.com

You also need to set the default close option if you are using a decorated JFrame: (from the API docs) setDefaultCloseOperation public void setDefaultCloseOperation(int operation)Sets the operation that will happen by default when the user initiates a "close" on this frame. You must specify one of the following choices: DO_NOTHING_ON_CLOSE (defined in WindowConstants): Don't do anything; require the program to handle ...

64. Linking Jframes via a button    forums.oracle.com

import java.awt.*; import javax.swing.*; public class frontPage extends JFrame { public frontPage() { setTitle("Learning tool for Natural Deduction"); Container contents = getContentPane(); contents.setLayout(new GridLayout(0, 1)); contents.add(new JLabel("Front Page")); JPanel fp = new JPanel(); contents.add(fp); fp.setLayout(new GridLayout(2, 0)); JButton myButton = new JButton("Hello World!"); fp.add(myButton); setDefaultCloseOperation(EXIT_ON_CLOSE); pack(); } public static void main(String [] args) { frontPage thefrontPage = new frontPage(); thefrontPage.setVisible(true); } ...

65. how to call a class after clicking a button from jFrame    forums.oracle.com

Thank you so much for your immediate reply, AnanSmriti Probably you were not able to get my point. Please allow to explain it again. I have a jFrame with jButton1. After I click the button using actionperformed event it will call the class. The content of the class basically the method with a content of System.out.println("Hello World!!!"). This is what I ...

66. Changing Jframe color with a Jbutton    forums.oracle.com

67. showing a new JFrame when clicking a JButton    forums.oracle.com

68. Having Trouble Closing a JFrame With a Button Click in Swing    forums.oracle.com

That handles the NullPointer, but still doesn't close my second Frame. The editDetailFrame should not be null at this point as I am clicking a button on the editDetailFram itself so I think the problem is that I just don't have a reference to the actual object at that point and my variable is just an empty one.

69. How add buttons to Jframe from other class    forums.oracle.com

70. Override minimize button of JFrame    forums.oracle.com

Is there a way to change the default action of the minimize button of a JFrame? By default it just iconifies the window to the taskbar, but I want it to "minimize to system tray". I want to just toggle the visibility of the window instead of ever minimizing, since minimizing then changing visibility causes problems.

71. Linking Jframes via a button    forums.oracle.com

73. Very strange problem... about locate buttons in JFrame    forums.oracle.com

i dont know what happens but i use null layout ... and when i locate buttons in my frame i run the program and see them in other place... but after two or three runs i see them in the correct place and its suddenly happen what can i do? thank you

74. Change the tabbing order for JButtons within a JFrame    forums.oracle.com

Hi, I have a GUI that consists of a JFrame, a couple of JPanels and some JButtons and JTextFields in the panels. I now want to change the order of the fields when pressing the tab button. At the moment I have a GridLayout, which contains 3 text fields and 2 buttons. The tabbing order is: TextField1, Button1 TextField2, Button2 TextField3. ...

75. How to build JFrame with only exit button?    forums.oracle.com

76. JFrames with only the close button    forums.oracle.com

I have been writing a notepad as my first java project and have done most things but cant seem to fix this: coding a JFrame with only the close button. Most of us know that when you click Help > About... a window pops up describing the company that wrote the software. Please help....

77. maximize components when click maximize button in jframe    forums.oracle.com

thank you sooooo much for your reply but i think i didnt explain clearly enough. i have a frame which contains a panel (named A), panel A contains serveral panels so when i run the program, user will only see a rectangle which contains some components. ps. i tried to add BorderLayout in the frame. but when i click on the ...

78. [NetBeans][JFrame] - JFrame Button    forums.oracle.com