jpanel

How can I integrate 2 different JFrames?

橙三吉。 提交于 2021-01-05 08:59:41
问题 I have a code ready that generates a CPU/Time chart (I changed another code according to my need). So far so good, but now I can't integrate it in a JFrame that is really mine and already stylized! Here is the code of the chart: /** @see https://stackoverflow.com/a/5048863/230513 */ public class Atol extends ApplicationFrame { private static final String TITLE = "Dynamic Series"; private static final String START = "Start"; private static final String STOP = "Stop"; private static final float

Added panel not showing up in frame (Java)

寵の児 提交于 2021-01-05 07:22:18
问题 I'm working on making a battleship game board using swing in java. I've added the panel (i.e. the grid or the game board) to the window but it still won't show up. I've pasted the code below. Any help is appreciated. Thanks. public class board { private static JFrame window; private static JPanel[][] grid; public static void main(String[] args) { window = new JFrame(); window.setTitle("GAME BOARD"); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); grid = new JPanel[10][10]; for (int i

How to switch JPanel cards when a JMenu is clicked

邮差的信 提交于 2020-07-20 06:32:33
问题 I'm building an application using Netbeans where I have to switch from one JPanel to another when a specific JMenu is clicked. I have tried to use the following code but it won't work. MainPane is the main panel, NewpatientPane is the panel to switch to while card2 is the card name for the NewpatientPane. Any help will be appreciated. public void pharmacyMenuActionPerformed(java.awt.event.ActionEvent evt){ CardLayout card = (CardLayout)MainPane.getLayout(); card.show(Mainpane, "card2");

Why are my JPanels not showing color or shapes

空扰寡人 提交于 2020-07-16 07:41:45
问题 So whenever I run the application the frame is there however all the colors and rectangles are not. I'm making 3 different menus each intractable so I need 3 panels within my frame import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Application extends JPanel{ public static void main(String[] args) { JFrame frame = new JFrame("FrogVibes"); JPanel container = new JPanel(); JPanel mainPanel = new JPanel(); JPanel upgradePanel = new JPanel(); JPanel frogPanel = new