jpanel

Changing Panels using the Card layout [closed]

折月煮酒 提交于 2019-12-29 04:15:10
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 6 years ago . Hi Im sorry if this has already been posted but I looked hard and found other codes that I could not understand very well. I am new to java programming

How can I update JPanel continuously?

六月ゝ 毕业季﹏ 提交于 2019-12-29 02:01:06
问题 I've got a slight problem, I'm writing a gps tracking app to track several objects at once. The data comes in over a serial interface, this is coming in fine from what I can tell. The issue is that I need to continually update the JPanel where the map is created and displayed. public JPanel mapDisplay(){ JPanel mapPanel = new JPanel(); mapPanel.setSize(560, 540); Coordinate start = new Coordinate (-34.9286, 138.6); trackMap.addMapMarker(new MapMarkerDot(1Lat, 1Lon)); trackMap

JPanel background image

血红的双手。 提交于 2019-12-29 01:46:50
问题 This is my code, it indeed finds the image so that is not my concern, my concern is how to make that image be the background of the panel. I'm trying to work with Graphics but i doesnt work, any ideas?? please?? try { java.net.URL imgURL = MAINWINDOW.class.getResource(imagen); Image imgFondo = javax.imageio.ImageIO.read(imgURL); if (imgFondo != null) { Graphics grafica=null; grafica.drawImage(imgFondo, 0, 0, this); panel.paintComponents(grafica); } else { System.err.println("Couldn't find

Automatically size JPanel inside JFrame

拥有回忆 提交于 2019-12-28 15:12:58
问题 I have a JPanel subclass on which I add buttons, labels, tables, etc. To show on screen it I use JFrame : MainPanel mainPanel = new MainPanel(); //JPanel subclass JFrame mainFrame = new JFrame(); mainFrame.setTitle("main window title"); mainFrame.getContentPane().add(mainPanel); mainFrame.setLocation(100, 100); mainFrame.pack(); mainFrame.setVisible(true); mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); But when I size the window, size of panel don't change. How to make size of

How to disable all components in a JPanel

别说谁变了你拦得住时间么 提交于 2019-12-28 07:01:44
问题 In my JPanel I have many components, including other JPanels, JLabels, JTextAreas, and JButtons. Becuase I want to implement a tutorial mode where another window appears and everything in my main JPanel is disabled as the new window explains each 'feature' one by one... I want a to know how to disable all the components that are inside my origiinal JPanel. I know you can use: component.setEnabled(false); But I don't want to write it for each component in my JPanel. I would like to know if it

How to disable all components in a JPanel

扶醉桌前 提交于 2019-12-28 07:01:07
问题 In my JPanel I have many components, including other JPanels, JLabels, JTextAreas, and JButtons. Becuase I want to implement a tutorial mode where another window appears and everything in my main JPanel is disabled as the new window explains each 'feature' one by one... I want a to know how to disable all the components that are inside my origiinal JPanel. I know you can use: component.setEnabled(false); But I don't want to write it for each component in my JPanel. I would like to know if it

CardLayout showing two panels, flashing

冷暖自知 提交于 2019-12-28 04:28:11
问题 I'm trying to use CardLayout to show two JPanels , a main menu, and a controls screen. When I add two JPanels to my cards JPanel , it just shows two with flashing images. Here is my code: package main; public class MazeGame { // Layout public static JPanel cards = new JPanel(); // Window public static JFrame window; public static String windowLabel = "2D Maze Game - Before Alpha"; // Window Dimensions and Location public static int WIDTH = 600; public static int HEIGHT = 600; public static

Replacing JPanel with JPanel in a JFrame

旧巷老猫 提交于 2019-12-28 01:34:52
问题 I have a class that extends JFrame, and it has a BorderLayout. It has two private instance variables of type JPanel. They represent panels of buttons and are called flipButton and confidenceButtons. When you click on the button, the panel of buttons is replaced by the other panel of buttons. That is, if you click on a button in flipButton, flipButton is replaced by confidenceButtons. I tried to do it like this: private class FlipListener implements ActionListener{ public void actionPerformed

printing JPanel without displaying it to screen

时间秒杀一切 提交于 2019-12-26 04:01:31
问题 I have 2 classes. The first class contains a JPanel to be printed out. The second class prints the JPanel of the first class. How can I printout the JPanel of the first class without displaying it in to screen? 回答1: Try the Sreen Image class. 回答2: atlernative for your questions, because Swing APIs can do that for JComponents which are layed by using Absolute Positioning didn't required to be visible for obtains final size, 1/ disadvantages Absolute Layout setLaout(null) is last property how

JTabbedPane won't change panel on mouseclick

不羁的心 提交于 2019-12-26 02:43:44
问题 I have a Main class that stores a TabbedComponent(extending JTabbedPane) as a variable. Another class (ToolbarComponent(extending JMenuBar) is also stored as a variable within my main class. Upon a user event on the Toolbar, it calls the parent class (main), to get the TabbedComponent object and call a method to create a new tab. Which all works fine. My issue is that when I attempt to click on a ta with my mouse, nothing changes. I'm pretty sure that I don't need a listener on MouseAdapter