I'm trying to make a JFrame with a usable content area of exactly 500x500. If I do this...
public MyFrame() {
super("Hello, world!");
setSize(500,500);
}
... I get a window whose full size is 500x500, including the title bar, etc., where I really need a window whose size is something like 504x520 to account for the window bord...
here is how should my program be. In first frame, there is a textfield1 where a user input text and when he press a button, a new frame will be display with a textfield2 that displays the inputted text from the textfield1. please help me with the syntax. i'm still a beginner in java. much thanks guys.
First Frame:
textfield= new JTex...
Hi,
I have been trying to change the icon in the frame. I have virtually tried everything:
The icon is 16x16 which is the right size ....doesn't work
I've trying PNG,GIF and JPG formats none of them work.
Tried different way of setting the icon....doesn't work.
I've tried relative (local paths) e.g. "icon.gif" and absolute paths e.g. "...
Here is the code:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JFrame;
import javax.swing.Timer;
public class TimerSample {
public static void main(String args[]) {
new JFrame().setVisible(true);
ActionListener actionListener = new ActionListener() {
public void actionPerf...
I am using the following code,
UIManager.put("JFrame.activeTitleBackground", Color.red);
for change the toolbar color in JFrame. But it didn't work.
Is it possible to change the color of titlebar in JFrame?
...
Hi! I am just wondering how can I make the title bar of a JFrame to be Marquee . Is it possible to do that? Thanks a lot!
...
Here is the code:
import javax.swing.SwingUtilities;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.event.*;
import java.awt.*;
public class GameWindow {
private String[] players;
private JFrame frame;
// Constructor.
public GameWindow(String[] players) {
this.players = players;...
Is it possible to lock the aspect ratio of a JFrame in Java Swing?
For example, if my window is 200px by 200px, and the user wants to resize it, I want the ratio between the width and the height at 1:1, so that if the new width is 400px, the new height is forced to 400px.
I'm aware of ComponentListener and componentResized, but I'm hav...
I want to do some drawing in a JPanel but the enclosing JFrame size doesn't seem to match where I've asked the coordinates to be drawn.
In my example code, the JFrame size is set to (700, 700) and the last point is drawn at (600, 600). I would expect this point to be drawn 100 pixels away from the right and bottom edges but it isn't (pl...
Is there any way in Java to enforce a minimum window size?
The last article I can find is from 1999, and has some complicated code to mimic the behaviour...
http://www.javaworld.com/javaworld/javaqa/1999-10/03-qa-window.html
Surely there is a simple method that can be used?
...
Hello everyone,
I have an applet. In this I have a JLabel component. When the user clicks this label, a new JFrame component gets displayed. I want to set the value of setDefaultCloseOperation() for this frame as JFrame.EXIT_ON_CLOSE. However, I get a SecurityException if I do that. I read the documentation of JFrame.EXIT_ON_CLOSE and i...
Hi all, I'm trying to make it so when I tab to some text fields on in my JFrame the data in the text field will be highlighted. I thought I had done this in the properties before but I am not seeing the option now. Does anyone know how to do this?
...
When I am running this, JLabel is not visible, but when I resize window (with mouse) JLabel is showed. Why?
import javax.swing.*;
import java.awt.*;
public class FrmTaoLogin extends JFrame {
private JPanel pnlLeft = new JPanel();
public FrmTaoLogin() {
super();
pnlLeft.setBorder(BorderFactory.createEtchedBorder());
...
Is it possible to make a JFrame that has a transparent background and draw an image on it, so only the image will be visible with no border or background?
...
Hello,
I would like to lock the mouse inside a JFrame. That is, the mouse can not leave the contents of the JFrame (unless the user hits escape, alt-tab, or the window otherwise looses focus). Ideas?
Thanks!
...
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 following way:
referenceToTheFrame.hide(); //hides the frame from view
refToTheFrame.dispose(); //disposes the frame from memory
But if I do this way, compiler complains:
Note: myProgram.java...
i am particularly using netbeans gui editor and i am new to gui
i have a jframe created and I added jtabbedpanel.
inside the jtabbedpanel i have 2 panels that i call standard and compact
i have set standardPanel = new ImagePanel(); which ImagePanel.java is located on different java file
how am I suppose to put a panel on different...
Hi,
This question has been asked a lot but everywhere the answers fall short. I can get a JFrame to display a background image just fine by extending JPanel and overriding paintComponent, like so:
class BackgroundPanel extends JPanel {
private ImageIcon imageIcon;
public BackgroundPanel() {
this.imageIcon = Icons.getIc...
Hello everyone,
I have this class called PollFrame that extends JFrame in a file called PollFrame.java . PollFrame contains a form. I have an applet, which has a button in it. When the button is clicked, I want the PollFrame to be displayed. I set the ActionPerformed as:
Pollframe poll = new PollFrame(); // This initializes the form
po...
On exiting my game, I would like to show an "exitscreen". The exitscreen.gif is in the folder, and works fine, but for some reason, only the blank frame shows with this:
JPanel finishPanel = new JPanel();
JLabel finishLabel = new JLabel(new ImageIcon("welcomescreen.gif"));
finishPanel.add(finishLabel);
finishLabel.setSize(11 * 35, 11 * ...