jpanel

Embed vlcj player in JPanel

回眸只為那壹抹淺笑 提交于 2020-01-16 14:31:05
问题 Hi I am trying to add a vlcj player in a jpanel. I am using this post and this post to realise this. I am also using a tutorial on how to use embeddedMediaPlayerComponent for this. I already got this working where the video is played in a JFrame. I want to place the vlcj-player in a JPanel now, but I am still getting erroneous behavior. Here is my code of the main class with the jframe in import java.awt.BorderLayout; import java.awt.Color; import java.awt.Font; import java.awt.Graphics;

JPanel with a specific JRadioButton does not update after getting result from SwingWorker thread

喜夏-厌秋 提交于 2020-01-16 06:31:27
问题 I am making a Java GUI application. For reading two types of files required as an input, I am using the SwingWorker class which performs the operation in two different background threads. Once, the two types of files are read, there are a lot of components which get updated in the GUI with data and a HeatMap in one of the JPanel . This JPanel contains two JRadioButton , which on switching should display the two different heat maps obtained from the two files read by the application. I can see

Components in GridLayout wit JPanel fills the grid incorrectly

♀尐吖头ヾ 提交于 2020-01-15 23:05:47
问题 I am trying to prevent the GridLayout in a JPanel from filling the cells entirely and ignoring any setSize of the components i am using this code: import javax.swing.*; import java.awt.*; public class GrideComponents{ public static void main(String[] args) { JFrame frame = new JFrame("Laying Out Components in a Grid"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridLayout(5,2,0,0)); panel.add(new JLabel("Enter name")); JTextField a = new JTextField(5);

Components in GridLayout wit JPanel fills the grid incorrectly

自古美人都是妖i 提交于 2020-01-15 23:05:09
问题 I am trying to prevent the GridLayout in a JPanel from filling the cells entirely and ignoring any setSize of the components i am using this code: import javax.swing.*; import java.awt.*; public class GrideComponents{ public static void main(String[] args) { JFrame frame = new JFrame("Laying Out Components in a Grid"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel panel = new JPanel(new GridLayout(5,2,0,0)); panel.add(new JLabel("Enter name")); JTextField a = new JTextField(5);

Using multiple classes with the same JFrame

泪湿孤枕 提交于 2020-01-15 11:37:11
问题 I've been in a bit of a pickle here. I've been ripping my hair out over how to accomplish such a task. For my International Bacc I have to fill out certain criteria for my Program dossier and one of them is using inheritance and passing parameters etc. I'm in the stage of making my prototype and wanted to achieve the effect of using multiple JPanels within the same JFrame. I've achieved this rather crudely with setVisivble() and adding both panels to the JFrame. I understand that I can use

Repainting a JPanel in a loop with a delay

荒凉一梦 提交于 2020-01-15 08:35:10
问题 I'm trying to create a program which will visualize different sorting algorithms by drawing a set of bars representing an array along for each time the sort loops. However, when I set the array from within the sorter class which in turn repaints the panel, it seems that it only calls paintComponent() for the first and last iteration, not showing the steps in between. Here is the sort code which calls the setNumberArray() method: public void bubbleSort() { int[] x = getNumberArray(); boolean

How use a 9-patch image as background on a JPanel?

寵の児 提交于 2020-01-15 06:42:49
问题 I'm searching a way for use a 9-patch file as background for javax.swing.JPanel. So that the background image automatically resizes itself when the dimensions of the JPanel change. Is it possible? Or I have to create all the pieces of the image and manually resize some of them when the listener triggers (like in the piece of code that follows)? public class JPanelWithNinePatchBackground extends JPanel { { /* Define all parts of the background like BufferedImage */ addComponentListener(new

Type mismatch error when adding Label to Scala Swing Panel

ぃ、小莉子 提交于 2020-01-15 05:50:06
问题 I have this Class extending FlowPanel and I'm trying to add Labels into it: import java.awt.{Label, Color} import scala.swing._ import scala.util.Random class MyPanel extends FlowPanel{ val dimension = new Dimension(600,400) maximumSize = dimension minimumSize = dimension preferredSize = dimension foreground = Color.white background = Color.LIGHT_GRAY def drowLabels(size: Int) = { for(i <- 0 until size){ contents += new Label() revalidate(); repaint(); } } But I get an error message: type

JPanel not refreshing upon selection with JComboBox

允我心安 提交于 2020-01-14 14:45:31
问题 I am attempting to write a pretty short class that "ties" a JPanel to a JComboBox. I think I have the logic down, but nothing happens when I select something new using the JComboBox... Here is (more or less) my code: private DisplayPanel currentDisplay; //a displaypanel is simply an extended JPanel with an id field, and an overriden .equals() method private JComboBox selector; private List<DisplayPanel> displays; public SelectionPanel(DisplayPanel panel){ displays = new ArrayList<DisplayPanel

JPanel not refreshing upon selection with JComboBox

蓝咒 提交于 2020-01-14 14:45:09
问题 I am attempting to write a pretty short class that "ties" a JPanel to a JComboBox. I think I have the logic down, but nothing happens when I select something new using the JComboBox... Here is (more or less) my code: private DisplayPanel currentDisplay; //a displaypanel is simply an extended JPanel with an id field, and an overriden .equals() method private JComboBox selector; private List<DisplayPanel> displays; public SelectionPanel(DisplayPanel panel){ displays = new ArrayList<DisplayPanel