java drawing rect in panel
ı draw rect on to jpanel but it is only seeing when changing the active operation system window. ...
ı draw rect on to jpanel but it is only seeing when changing the active operation system window. ...
Sorry I don't know if this is very clear, but I'm pretty new to Java. So I have a JFrame with a BorderLayout containing a JPanel and a JButton. What I want to do is when something happens in my JPanel, I want for example change the text of the JButton, or enable/disable it. How would I do that? How can I access the JButton from the JP...
I'm trying to print a JPanel with some painted graphics on it (overriding paintComponent). The graphics is so big that they wont fit on a single page and therefor I'm letting it span across multiple pages. My problem lies within the fact that if I let the user choose the pageFormat/Paper type by calling: PrintRequestAttributeSet aset =...
I only want a method to activate if the pixel that is clicked is white. How would I implement this? Trying to look for a method that returns the colour at a coord, but I can't find one. ...
hi, all in title thanks for your answers ...
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...
After I use my textfield I can't get a jpanel that click on back into focus for my keylistener. It works for the mouselistener but all other keystrokes keep being detected by the textfield not the jpanel. The panel has been setFocusable(true) and works fine until i give the textfield the keyboard focus. It's like the textfield won't rel...
I've been trying to load up an image dynamically in runtime for the longest time and have taken a look at other posts on this site and have yet to find exactly the thing that will work. I am trying to load an image while my GUI is running (making it in runtime) and have tried various things. Right now, I have found the easiest way to c...
I'm having A JLayeredPane where I add 3 JPanels. I make the JPanels transparent (no background is set and setOpaque(false)). I draw lines on the JPanels and only the line on the last JPanel which has been added is visible. The lines of the other JPanels are not visible through that top JPanel (even if I have added different zIndexes whe...
Hi guys, basically I want my JFrame to become a completely new JFrame object when an event is triggered. I have some code that basically calls [CODE]GUI gui = new GUI(x, y)[/CODE] the only problem I'm having is that as well as creating the new GUI object, it is not deleting the old window. Can anyone tell me how to get rid of the old win...
I have a JPanel sitting inside the center position of a BorderLayout of a JFrame. How can I swap out the current JPanel for a new one? ...
I have several JComponents on a JPanel and I want to disable all of those components when I press a Start button. At present, I am disabling all of the components explicitly by component1.setEnabled(false); : : But Is there anyway by which I can disable all of the components at once? I tried to disable the JPanel to which these compo...
I would like to have all elements in my JPanel to be aligned to the left. I try to do it in the following way: JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setAlignmentX(Component.LEFT_ALIGNMENT); As a result Java use left side of all elements as a position of the element and then put all...
Hi, I am making an image loading component which consists of a JPanel containing a JScrollPane, which in turn contains another JPanel. What this component does is allows images to be dropped on top of it, after which point the image is loaded and the inner most JPanel is set to the size of the image dropped. This in turn causes the sc...
I'm extending a JPanel to display a game board, and adding a JEditorPane at the bottom to hold some status text. Unfortunately, the game board renders just fine, but the JEditorPane is just a blank gray area until I highlight the text in it, when it will render whatever text is highlighted (but not the rest). If I'm understanding Swing...
Hello all This code inside a JFrame form created in netbeans works fine as i'm trying to put a JCalendar in a panel that i create manually. JCalendar myCalendar =new JCalendar(); JPanel customPanel = new JPanel(); customPanel.setSize(400, 250); customPanel.setBorder(new LineBorder(Color.BLACK)); customPanel.add(myCalendar); this.add(cus...
I'm working on a map editor for my college project. And I had a problem that the map panel is not listening key event while it should. This happens when I add a ToolBarPane (which extends JPanel) with JComponent such as JButton, JComboBox that implements ActionListener on it AND the map panel (which extends the JPanel) together on to the...
I am having some pretty strange symptoms with JPanels and CardLayout. Essentially, I have cards which act as "pages" since I can only hold 12 cells on the grid, and I display each page as a card, and clicking -> and <- buttons change pages accordingly (or that's the idea). Because this data is representing a changing model, every five se...
I want my panel to fit the frame when I show/hide fields. How could I notify to the parent frame to revalidate? I thought about pass the frame to my panel's constructor, but I think may have a way this is already done. I remember that there was a protected attribute in JPanel, but there isn't.. maybe i remembering the wrong component. ...
I'm working through a JPanel exercise in a Java book. I'm tasked with creating a 5x4 grid using GridLayout. When I loop through the container to add panels and buttons, the first add() throws the OOB exception. What am I doing wrong? package mineField; import java.awt.*; import javax.swing.*; @SuppressWarnings("serial") public class...