Hi, I have a JFrame that has a BottomPanel (a class I made that extends JPanel) inside it.
And inside that JPanel is another JPanel called DicePanel(that again extends JPanel).
In DicePanel there is a button called 'End Turn' that when clicked should end the players current turn for the board game the program is based on. I want to some...
Let's say I want to make the opacity of a JPanel %20 viewable? I don't mean setOpaque (draw or not draw) or setVisible (show or hide)... I mean make it see-through JPanel.. you know?
Is this possible?
...
I am failing to display a JComponent inside a JPanel on a JFrame.
The following does not work.
JComponent component = ...
panel.add(component, BorderLayout.CENTER);
frame.add(panel, BorderLayout.CENTER);
But if I add the JComponent to the JFrame[like frame.add(component, BorderLayout.CENTER);], it displays the contents.
Any ideas
...
Hello everyone,
I want to be able to have a JPanel in a cell with a JButton that does some work when clicked.
I looked for howtos about Cell Editors, but all examples talk about replacing the cell with another component (e.g. replace an int with a JTextField etc.) My situation is a little different:
I have the following ADT
class My...
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Random;
public class dots extends JPanel implements KeyListener, ComponentListener{ //JPanel extended so that we can overwrite paintComponent and draw the dots, KeyListener so that we can capture keypresses
Random rand = new Random();
JFrame frame;
bo...
I have class extended from JPanel. This class contains several other JComponents and a lot of painting. What I did and I know it isn't correct is, I overrided the paintComponent for the paintings, so far so good.
But I also set the location and the size for all subcomponents in this method, because they depend on the getWidth and getHe...
Hi I have a JFrame and there are two JPanels on top of it. My intention is to draw on the JPanels. Can anyone please share any Java code?
...
I'm trying to get the Layout of a JDialog of mine to fit a particular look that a program in which I'm porting to Java has, I've used several LayoutManagers before with great success yet for some reason I cannot seem to get this working at all. My goal is to have the Right (East) side of the JDialog contain a "Find Next" and "Cancel" but...
Hi,
I’m new in Java.
I use alternately various JPanel in a JFrame. And I would like to know how can I use a variable declared in a JPanel, in another JPanel?
Thank you for your collaboration.
Best regards.
Daniel
...
I have multiple JPanels on my application, however I cannot figure out how to detect which exactly which one was clicked.
In my MouseListener, I have the argument e but my method isn't working
Early in my code I declare multiple JPanels and a listener object.
PuzzleListener plist = new PuzzleListener();
JPanel puzzle_board = ...
I have a JFrame which contains a JPanel. The frame can be resized by the user using the mouse. When the width of the frame is > 400, the jpanel inside's width is set to 10; otherwise 1080.
In between the frame and the panel, there is also a JScrollBar.
Here is my code:
import java.awt.BorderLayout;
import java.awt.Color;
import java.a...
i want to have a scrollpane inside a panel which the scrollpane cover the whole panel. how can i do that?
...
My issues is that I have created a JPanel that draws a gradient as a background. But when I go to add components to it (like a JButton) it does nothing...
Please help!
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java....
I have a JTextArea in a JPanel. How can I have the JTextArea fill the whole JPanel and resize when the JPanel resizes and scroll when too much text is typed in?
...
I'm newbie to Game programming. I'm trying to develp a simple shooting game. The game ground which I'm trying is a circular one. The game has one shooter and 5 driods. The shooter and the driods have to move with-in the circular area only. Following is the code snippet i tried.
I tried implementing the game using the State design patter...
I'm reading an introduction to Java book. I'm about three/fourths of the way through the GUI section, and learning about add different JComponents to a JFrame to create a UI.
I'm confused about one thing, though. The book (in the examples) created a Frame, and then added 4 panels by subclassing one after the other. (In other words: It e...
I have three questions/problems. (NOTE - I don't have enough reputation to post pics, so I linked them. And I needed to obfuscate them...)
1) I created a panel that holds my game graphics (the player area). The panel is supposed to be 800x800 and clip everything that lies below and to the right. But when I add the graphics panel to a JF...
I have a JFrame with 3 panels. I extend an App class, and then add three panels to it, like so:
JPanel controlButtonsPanel = new GameControlButtons();
controlButtonsPanel.setPreferredSize(new Dimension(801,60));
controlButtonsPanel.setBorder(new LineBorder(Color.white, 1));
constraints.anchor = GridBagConstraints...
I'm making a game with three main panels and a few subpanels, and I'm confused about how you "connect" the panels and their data.
I have my main class, which extends JFrame and adds three JPanels. Each of those panels is a subclass of JPanel. (Ex: JPanel gameControlPanel = new GameControlPanel(), where GameControlPanel is a class I crea...
I made a simple java game last week. At that time, one class extended Jframe and held the data (which comprised three other class, through composition)
Now, I'm trying to make the same game, but with several JPanels. One panel will be the game graphics (basically the old JFrame shrunk into one panel). And there will be buttons and text ...