java,swing,user-interface,netbeans,jframe
You must pass the userLL as parameter to your userLogin class like this : public class userLogin { LinkedList<dataUser> userLL public userLogin(List userLL){ this.userLL = userLL; } //....... } And in your main class instantiate it like this : userLogin frame = new userLogin(userLL);...
java,swing,jframe,dimension,setbounds
There are 2 ways to fix this: Take into account the border of the frame when setting the bounds of the frame Override getPreferredSize() of the content pane of the JFrame and then call pack() on the frame. Here is a demo of the two techniques: import java.awt.Dimension; import java.awt.Insets;...
java,swing,arraylist,jtable,jframe
I don't know if I need to use TableModel or just JTable table = new JTable(data, columnNames) Depends on your needs, you can do either. I will demonstrate how to use the latter. If you want to use your own TableModel, see the link in @Andrew Thompson's comment. public...
java,swing,jframe,layout-manager,border-layout
The default layout of a JFrame (or more specifically in this case, the content pane of the frame) is a BorderLayout. When adding a component to a BordeLayout with no constraint, the Swing API will put the component in the CENTER. A BorderLayout can contain exactly one component in...
java,arraylist,jframe,jpanel,graphics2d
Lets start with the fact that DrawStuff hasn't actually been added to anything that is capable of painting it. DrawStuff#paintComponent should be making decisions about updating the state of the shapes List, instead, your ActionListener and MouseListener should be making these decisions (what to add, where and what do modify),...
canvas = new ThePanel(); setSize(700, 300); this.add(canvas, BorderLayout.CENTER); The setting size and adding to this is futile because later scrollpane ignores it. When your image is bigger than the JScrollPane just call canvas.setPreferredSize(imageWidth, imageHeight);...
I've just re implemented your problem in a better way. Here is how it looks like now: Problems are solved. import java.awt.BorderLayout; import java.awt.Color; import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; public class CirclePainter implements MouseMotionListener,...
new JFrame( "title" ) calls JFrame's constructor. It may call setTitle() (but it probably doesn't), or it may just set the internal variable used to hold the title. super.setTitle() is just a method call. If you have overridden setTitle(), it'll ignore your definition and call the same method on...
java,swing,jframe,layout-manager,grid-layout
change the mainPanel.add(component); sequence in setPanels() method to the following.. mainPanel.add(SelectData); mainPanel.add(START); mainPanel.add(startDay); mainPanel.add(sDay); mainPanel.add(startMonth); mainPanel.add(sMonth); mainPanel.add(startYear); mainPanel.add(sYear); mainPanel.add(END); mainPanel.add(new JLabel()); mainPanel.add(endDay); mainPanel.add(eDay); mainPanel.add(endMonth); mainPanel.add(eMonth); mainPanel.add(endYear); mainPanel.add(eYear); mainPanel.add(checkDate); and it will work..as you are using...
java,swing,netbeans,jframe,jcombobox
So I was really dumb and had two instances created, one of which I was not viewing and the other of which I was but was not changing. Basically what I did was in graphSelectionActionPerformed I did: this.graphSelectionGUI = (String)graphSelection.getSelectedItem(); Then in nextActionPerformed I did: new DefineEquation_1(graphSelectionGUI).setVisible(true); Following this, in...
Alright this code works for increasing +10 each time user clicks +10 button. To make it work with -10 or whatever number you want to decrease if they click on the frame, you should check JFrame mouse click using JComponent and MouseListener. As I said, next time make your code...
java,swing,user-interface,jframe,joptionpane
Use private void findActionPerformed(java.awt.event.ActionEvent evt) { try { String num = JOptionPane.showInputDialog("Number to Search:"); if(num != null) { int number = Integer.parseInt(num); s.search(number); } }catch (Exception e) { JOptionPane.showMessageDialog(this, "WRONG INPUT: you must insert integers", "Erorr", JOptionPane.ERROR_MESSAGE); } } JOptionPane returns null when one closes it or presses cancel. So...
You're trying to call a constructor as if it were a static method. Don't. Instead create your instance by calling the constructor as a constructor, assign the instance to your variable, and use it. Changes: // GuiDMenuBar mbr; GuiDMenuBar mbr = new GuiDMenuBar(); // create instance and assign public void...
java,swing,jframe,jinternalframe
The short answer is no. This is why we generally discourage extending from JFrame (or top level containers) directly. You need to try a move the content out of the JFrame to something like JPanel. This will allow you to make better decisions about how to present the content. The...
You need to update the text of totalSelection yourself. This is because when you initialise it, you provide a String object which has been generated from the value of totalPrice at that time. So to fix it, reset the text of totalSelection at the end of itemStateChanged...
java,swing,console,jframe,jpanel
If you're trying to get the system console onto the side of the screen you will need to Reset the Output Stream. Then you can use a JTextArea and place it into the border layout (east/west) whatever you would like. If you don't want system output, you'll just need to...
Possible problems: 1. Make sure the relative or absolute path used for pictures is correct. 2. Where you create an object of this class, you need to call t.setVisible(true). (i.e., have a look at my main method) public class Gui extends JFrame { private JComboBox<String> box; private JLabel picture; private...
java,swing,jframe,jbutton,actionlistener
When you run this: while (true) { if ((t.get())) break; } the thread will eat all cpu, making the UI unresponsive; to overcome, one easy way would be adding a sleep time inside the loop: while (true) { Thread.sleep(250); // sleep for 250 msecs if (t.get()) break; } Anyway it...
java,swing,user-interface,jframe,absolutelayout
I need to be able to display card images in groups that overlap You can use the Overlap Layout which supports this feature. So you can have different panels with different OverlapLayouts for the cards. You would then need another layout to manage the different piles of cards. Don't...
java,swing,types,jframe,undefined
With this: JFrame CBallMaze = new JFrame("Title");, you're creating a JFrame variable and assigning it a JFrame object, and then expecting it to have CBallMaze behaviors, something that isn't going to happen. Instead, you will want to create a CBallMaze object and assign it to a CBallMaze variable. So change...
As I understand the issue: When you click button JButton(morseIcon), Shell's main is called, which contains infinite loop while(true), so that's become impossible to repaint your window and even exit application. You can put call main into new thread: new Thread(() -> Morsecodes::main).start(); Or put your loop into thread... ...
java,swing,jframe,jpanel,paint
I suspect that the Graphics context, g, is invalid in your ActionListener, perhaps due to using getGraphics() inappropriately. Instead, let your ActionListener update fields in your view class and modify the Graphics context in paintComponent() using the updated values. In this complete example, the various implementations of actionPerformed() in the...
java,event-handling,jframe,jpanel,mouseevent
If I understood well what you need, this could help: ArrayList<Float> coordsX = new ArrayList<Float>(); ArrayList<Float> coordsY = new ArrayList<Float>(); addMouseMotionListener(this); this.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e){ coordsX.add(e.getX()); //Storing coordinate X coordsY.add(e.getY()); //Storing coordinate Y //Add this code to draw a circle each time you click. int r...
java,swing,ubuntu,jframe,location
I don't have Ubuntu to test with, but I've used something similar to this on both MacOS and Windows import java.awt.Container; import java.awt.Point; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionListener; import javax.swing.JFrame; import javax.swing.SwingUtilities; public class Test { private static JFrame mainFrame; public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() {...
java,swing,applet,jframe,jpanel
JFrame uses a BorderLayout by default, where as a JPanel uses a FlowLayout Instead of rebuilding the UI in the JFrame, simply add an instance of GUI to it, since you've already defined the functionality in a JPanel, this makes it easily reusable. public class SwingPaintDemo { public static void...
java,swing,timer,colors,jframe
(I really don't know what your "codes" are doing, as R-RB doesn't seem to make sense, how do you display R, G and B?) Okay, you need to start by generating some kind of sequence that you want displayed. This will allow the Timer to act as a pseudo loop...
java,swing,checkbox,jframe,enable-if
In your limit_checkBoxes() method, you want i < 30, not i > 30 in the loop. See my embedded comment. label.setText(Integer.toString(number_of_boxes_checked)); if (number_of_boxes_checked > 6) { for (int i = 0; i < 30; ++i) { //<- your bug was here, I fixed it checkBox[i].setEnabled(false); } } else { ++number_of_boxes_checked;...
java,swing,jframe,event-dispatch-thread
You didn't show how you call those methods of ClassA that make various calculations. I can only guess that you call all of them in an event dispatch thread (see The Event Dispatch Thread for details) and Java cannot render anything until ClassA completes its processing. If that is the...
java,jframe,jpanel,jlabel,game-engine
Solved. Thanks to MadProgrammer for his comments. Render the title map to a BufferedImage, either in it's entirety or based on the available viewable area, which ever is more efficient. Paint this to the screen, then paint your character on top it – MadProgrammer In 15+ years of professional Java/Swing...
java,swing,jframe,mouselistener
Tested it locally and it works as intended. What do you add with frame.add(this) ? public class Test { public static void main(String[] args) { JFrame t = new JFrame(); t.setSize(500, 500); t.addMouseListener(new IH()); t.show(); } public static class IH implements MouseListener{ @Override public void mouseClicked(MouseEvent e) { System.out.println(e.getX()); System.out.println(e.getY());...
It is just simple. //First of all put the options dialog code like this. int n = JOptionPane.showOptionDialog(this, "?", "Check", JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE,null,null,null); //Now grab the value of n into switch case like this. switch(n) { case 0: //Yes break; case 1: //No break; case 2: //Cancel break; case -1: //User...
I would use JDesktopPane with JInternalFrames. With that technique you can create as many windows as you need. A good place to start with this is here: https://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html.
java,jframe,mouselistener,pong
The Paddle class needs an instance of the JFrame class in order to add a mouse listener. If you pass a JFrame object into the constructor, you can then use the following code: public class Paddle { private JFrame frame; private int paddle_y; public Paddle(JFrame frame) { this.frame = frame;...
java,swing,jframe,paintcomponent,jcomponent
When doing custom painting: You need to override the getPreferredSize() method of your component to return the size of the component so a layout manager can display the component. Right now the size of your components are (0, 0) so there is nothing to paint. The painting of a component...
java,jframe,paintcomponent,jdialog
You should actually have 2 Points - drag start Point and current drag Point. The rectangle is calculated: x=min(dragStartPoint.x, dragCurrentPoint.x) y=min(dragStartPoint.y, dragCurrentPoint.y) width=abs(dragStartPoint.x - dragCurrentPoint.x) height=abs(dragStartPoint.y - dragCurrentPoint.y) ...
java,swing,jframe,actionlistener,visibility
It looks like you have a name clash: frame3 is used for a class and a variable: frame3 frame3 = new frame3(); If your class is named frame3 I would rename it to Frame3....
Use SwingUtilities.getWindowAncestor, if inside the JWindow class, refer it as this, if no, simply put object inside: JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(this); JFrame topFrame = (JFrame) SwingUtilities.getWindowAncestor(myJWindow); ...
you haven't add content yet to the frame.you have created contentPane but haven't add it to jframe .add it before call setVisible() this.setContentPane(contentPane); setVisible(true); ...
As you extend JFrame so you don't need to create another JFrame instance at constructor. Simply add panel to MyButtons which already inherited JFrame. public MyButtons(){ //JFrame frame = new JFrame("MyButtons"); Commentted this JPanel panel = new JPanel(); //frame.add(panel); And this JButton b1 = new JButton("Button 1"); JButton b2 =...
mainPanel.getRootPane().add(c4Panel,BorderLayout.CENTER); Should just be: mainPanel.add(c4Panel,BorderLayout.CENTER); The code: mainFrame.getContentPane() ..is simply returning a container which itself has an add() method, and the getContentPane() part has been unnecessary for some time....
You are calling your frame's setVisible(true) method before you add all of the desired components to it. Move the call to the end of your constructor. public swinginterface { // adding components to the JFrame frame.setVisible(true); } ...
java,swing,jframe,jpanel,action
The main idea is to check intersection of 2 objects (Shapes). The platform is not moved and has a fixed Shape - Rectangle (let's name it platformRect). Jump object is moved (down) and also has a Shape - let's say Ellipse (and call it movingEllipse). By Timer we change y...
java,swing,jframe,paint,keylistener
You're drawing directly in the JFrame, something that is dangerous to do (as you're finding out). You're not calling the super's paint(...) method from within your paint override preventing the JFrame doing the painting that it itself needs to be doing. You're calling repaint() from within a painting method...
java,swing,user-interface,jframe,window
Opening a new window is as simple as creating a new frame like you've already done in your display() function. For instance, this: JFrame newFrame = new JFrame("New Window"); newFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); newFrame.setVisible(true); Should be enough to open a new window with nothing in it (you'll probably want to add something to...
Don't call getGraphics on a JPanel. If you want to paint to a JPanel, override it's paintComponent method and use the Graphics object passed to that method as explained in the tutorials. JPanel panel = new JPanel(){ @Override protected void paintComponent(Graphics g){ super.paintComponent(g); g.setColor(...); g.fill(...); } }; frame.add(panel); ...
Try this one. import javax.swing.JFrame; import javax.swing.JButton; import javax.swing.JTextField; import javax.swing.JLabel; import java.awt.FlowLayout; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Demo{ private final JLabel showInput; private final JTextField inputField; public Demo(){ JFrame inputFrame = new JFrame("Input"); JFrame outputFrame = new JFrame("Output"); inputField = new JTextField(15); JButton button = new JButton("Click here");...
I believe when there is a focus-able component on your frame, java paints the focus rectangle over it. I added another button and once the refreshPortsButton button is disabled, the focus automatically jumped to the next focus-able one. I disabled the focusPaint on the refreshPortsButton and it worked fine. You...
java,swing,jframe,themes,synthetica
Swing GUI objects should be constructed and manipulated only on the event dispatch thread, after you've invoked UIManager.setLookAndFeel(). try { UIManager.setLookAndFeel(new SyntheticaAluOxideLookAndFeel()); } catch (UnsupportedLookAndFeelException e) { e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); } EventQueue.invokeLater(new Runnable() { public void run() { JFrame frame = new JFrame(); … frame.pack(true); frame.setVisible(true);...
You are adding Components to an already visible JFrame. Either add the Components before calling setVisible (preferred - you may also want to call pack to lay out the components as well) add(lbl); pack(); setVisible(true); or call revalidate on the JFrame after adding the Component(s) setVisible(true); add(lbl); revalidate(); ...
Call revalidate and repaint AFTER you have finished making the changes to the UI (remove AND add)
java,swing,jframe,layout-manager
import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.Icon; import javax.swing.ImageIcon; import javax.swing.JButton; import javax.swing.JFrame; public class BGUI extends JFrame { private JButton pine; private JButton rock; private int pineappleCount = 0, rockCount = 0; public BGUI(){ super("Bikini Bottom Builder Game"); setLayout(new FlowLayout()); setSize(800, 800); Icon p = new ImageIcon(getClass().getResource("b.png"));...
java,swing,jframe,default,windowlistener
The window listener is just a listener. It does not affect the default close operation, unless you actually change the default close operation in the windowClosing() code. I use: frame.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); as the default when the frame is created. Then in the windowClosing(...) method, if the user confirms the closing of...
Two ways are there: 1. Just "Maximize" the window using the code i.e. add the following: this.setExtendedState( this.getExtendedState()|JFrame.MAXIMIZED_BOTH ); Your code will look like this: public class Titlebar extends JFrame { private final Dimension _screenSize = Toolkit.getDefaultToolkit().getScreenSize(); public void run(){ this.setTitle("TitleBar"); this.setSize(_screenSize); this.setExtendedState( this.getExtendedState()|JFrame.MAXIMIZED_BOTH ); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } public...
eclipse,video,javafx,jframe,mp4
I am not sure to understand your problem but in order to create a new frame in JavaFX. You have to create a new class with a new stage. Let's say you create a new class "newFrame" with the code below. public void show(Stage stage){ //define your root double width...
java,osx,swing,jframe,fullscreen
Full screen support under Windows and MacOS have different user expectations... You could use Full screen exclusive mode on both, but Mac users have a different exceptions when it comes to full screen applications, as MacOS supports full screen applications at an OS level I tested the following code (which...
Try this try { spinner.commitEdit(); } catch (ParseException pe) {{ // Edited value is invalid, spinner.getValue() will return // the last valid value, you could revert the spinner to show that: JComponent editor = spinner.getEditor() if (editor instanceof DefaultEditor) { ((DefaultEditor)editor).getTextField().setValue(spinner.getValue()); } // reset the value to some known value:...
Put the calculation into your paintComponent method. In general you want to avoid having code in paintComponent that will slow it down, but these calls shouldn't give too much penalty. Also, if your program is re-sizable, you'll need to be able to re-calculate the sizes of things on the go...
A lot comes down to the requirements of the content and the layout manager. Rather then looking "how big" you'd like the frame to be, focus on the amount of space the content needs. The frame will then "pack" around this. This means that the frame will "content size +...
Try out this: public JPanelInformations() { //JPanel PanelInformation = new JPanel(); remove new instance of panel setLayout(new GridLayout(7,1,5,5)); JLabel labelInfo = new JLabel ("INFORMATION"); JLabel labelPrix = new JLabel ("Prix"); JLabel labelDesc = new JLabel ("Description"); JLabel labelQuant = new JLabel ("Quantite"); JTextField fieldPrix = new JTextField (20); JTextArea fieldDesc...
The easiest solution is to create the scroll pane in your initialize() method (like the code you have commented out). Then when you want to update the component in the scrollpane you just use: scrollPane.setViewportView( table ); //frame.getContentPane().add(table,BorderLayout.CENTER); //frame.revalidate(); //frame.repaint(); No need for revalidate(), repaint() or anything else....
You need to make the dialog visible before it will block... JDialog dialog = new JDialog(theDog,"theTitle", Dialog.ModalityType.APPLICATION_MODAL); dialog.setVisible(); Windows in Swing are not visible by default Have a look at How to Make Dialogs for more details...
I am required to determine which class inherited by the JFrame class declares the setVisible method, then import that class and modify the code in the main method so the frame variable is declared as that type rather than as a JFrame type. The Java API will tell you...
java,swing,graphics,jframe,imageicon
Comment out frame.setLayout(null); and you'll most likely see the game. The default layout of a JFrame is currently a BorderLayout An object added to a BorderLayout without a constraint defaults to the CENTER. An object in the CENTER of a BorderLayout is stretched to the available with and height. Since...
Understand that your BmrCalcv2 class uses TWO JFrames, not one. One is the instance of the BmrCalcv2 class with extends JFrame, and the other is a private field within the BmrCalcv2's constructor. You should get rid of one or the other to straighten this all out. If you decide to...
The problem is that your are bringing down the character only when the key is released ! Specifically with this logic: @Override public void keyReleased(KeyEvent e) { // TODO Auto-generated method stub if (e.getKeyCode()==KeyEvent.VK_SPACE){ jumper=false; } } And then with this logic when actionPerformed if (jumper==false){ DoodleHeight=DoodleHeight-10; } You need...
java,swing,netbeans,nullpointerexception,jframe
You're invoking the no-argument constructor instead of the one that takes the picture name as parameter. In main you should call: public void run() { new ShowPage(pictureName).setVisible(true); } where pictureName is the variable that stores the file name of the picture. The constructor also needs to call initComponents() just like...
Use ImageIO.read over Toolkit.getImage, it will throw a IOException of the image can't be load for some reason Check the location of the image. Your example is looking for a file in Koppenhagen\\Pictures, relative to the execution context of the program. You could use File#exists to check if the...
java,swing,jframe,user-input,greenfoot
Regardless of whether you are collecting user input upon the text field being used or the button being pressed, you can use the actionPerformed() method to do whatever you want upon detecting user input: b.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { System.out.println(jt.getText()); } }); OR jt.addActionListener(new ActionListener() {...
java,multithreading,swing,user-interface,jframe
Thread.sleep() is done on the Event Dispatch Thread which will lock the GUI. So If you need to wait for a specific amount of time, don't sleep in the event dispatch thread. Instead, use a timer. int delay = 1000; //milliseconds ActionListener taskPerformer = new ActionListener() { public void actionPerformed(ActionEvent...
what you have to do is when creating Frame 2 . you have to pass same reference of Frame 1 then inside frame 2 you can change the viability of Frame 1
The problem comes from BoxLayout: For a top-to-bottom box layout, the preferred width of the container is that of the maximum preferred width of the children. If the container is forced to be wider than that, BoxLayout attempts to size the width of each component to that of the container's...
java,swing,error-handling,jframe
In the code you shared, the button Douzaines (and the other related buttons) are used before they are declared: Douzaines.setVisible(false); // HERE I DO GET THE ERROR // [...] JButton Douzaines = new JButton("Douzaines"); // [...] Douzaines.setVisible(false); // HERE I DONT GET AN ERROR ...
You don't have to refresh the Frame or the JPanel. In the Actionlistener you will have to show the CardLayout 'upgrade cards' like you have done it in the levelauswahllistener. Then it should refresh it.
java,swing,jframe,joptionpane,modality
JOptionPanes are modal, so you can't do this directly. All dialogs are modal. Each showXxxDialog method blocks the caller until the user's interaction is complete. You'll have to use a JDialog or similar. JOptionPane p = new JOptionPane("I'm getting happy now."); JDialog k = p.createDialog(":-)"); k.setModal(false); // Makes the dialog...
java,arraylist,graphics,jframe,jcomponent
it may be not correct but have you called to the readinmapdata() before you called repaint()? it might cause this problem
Since I do not have your jar file there is no way for me to know the problem. You need to access the file as a resource and not as a new file because it is inside the jar. First you should use cmd to run the jar and see...
java,debugging,jframe,user,jtextfield
Here's an example where I created a JFrame and added a JTextField into it, and a input change listener, which gets triggered as and when the input is changed in the textField. I'm alerting a message if the input is "hello". import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.DocumentEvent; import...
java,swing,jframe,jtextarea,settext
setText does just that, it "sets the text" of field to the value your provide, removing all previous content. What you want is JTextArea#append If you're using Java 8, another option might be StringJoiner StringJoiner joiner = new StringJoiner(", "); for (int i = 0; i < 10; i++) {...
java,eclipse,swing,jframe,japplet
The Java Applet is executed client side - it runs on the computer of the person using the website. It does not run on the web server. If you have files in the server then the client will not be able to access them unless you serve them up from...
java,swing,animation,colors,jframe
I tried Wait, but it just froze the program and then it yielded the color, without transition It is unclear if you are calling this code on the EDT, but from the description sounds to be the case - sleeping (or performing a long running task) on the EDT...
In your case main() method should look like this: public static void main(String[] args) { Game game = new Game(); game.run(); } ...
Your code has several problems: You use array.length in both iterations (you should use array[0].length in one of those cases You use System.out.println in the "I tried it with this" part of your question. This will result in always printing in a new line. Did you try whether for(int i...
There are two problems in your code: You need to call main.getContentPane().add(c, BorderLayout.CENTER); to add JPanel c to your frame. Make sure to do this as one of the first things you do to main. In your JPanels, you are creating objects locally that are never returned from the classes....
java,string,jframe,jtextfield,indexoutofboundsexception
your index is overshooting use this instead for(int num=0;num<str.length()/3;num++) just < not <=...
Some notes to be made: That is a very small rectangle (this is important, because most OS's won't allow you to set the bounds of a JFrame to be so small, or else the minimize, exit, etc. buttons will collide. I understand that you are using a tutorial or demo...
java,swing,jframe,jbutton,paint
Problems: You're drawing directly in a JFrame -- don't do this as you can mess up the JFrame graphics. Your overriding the paint method and calling the super.paintComponents(...) method, again a dangerous thing to do, and something that should never be done. Instead you could do your drawing in the...
java,html,swing,jframe,jtextpane
I ended up using just basic 'text' and using components for click detection. To fix this issue i was having with HTML, i simply used editorKit.insertHTML(doc, doc.getLength(), "html code", 0, 0, null); Rather then inserting my code directly usings doc's 'insertString'...
java,multithreading,swing,user-interface,jframe
Swing is a single threaded framework, this means that any long running or blocking process which is executed within the context of the Event Dispatching Thread, will prevent the framework from responding to new events My question is how can I make the main GUI use wait()/notifyAll() so it will...
java,swing,jframe,jpanel,bufferedimage
One problem solved: You're not calling the super's paint method inside of your paint method override and by doing so are not allowing the GUI to draw its own components. In other words, you're not doing this: public void paint(Graphics g) { super.paint(g); // *************** missing ************ g.setColor(currentColor); if (myX...
ActionEvents are run on the EDT which is also responsible for painting. Once you change the labels state, Swing issues a request for repaiting the Label. The thing is that this request is posted on a queue and will be executed once the EDT is free and, as you can...
YourFrame frame=new YourFrame(); frame.setVisible(true); ...
java,swing,jframe,jbutton,actionlistener
I managed to get the second frame displayed (including its contents) by adding a call to the run() method: ClientMenu menu = new ClientMenu(); menu.setVisible(true); menu.run(); That being said, there are quite some problems with your code: You have a main method in each of your classes. You should have...
If you're trying to make all components disappear and be replaced by a different "view", then the easiest way to do this is to use a CardLayout, and then call this object's show(...) method to show the view of choice when a button has been pushed, as demonstrated below. Note...
-DisplaySet is not used, and gives me errors when I try to change it DisplaySet is static and from what you've described, you DON'T want to call it from within the class's constructor, instead, you could call it from the main method public static void main(String[] args) { DisplayWindow.DisplaySet();...
You've got your if (action command equals q3) if block buried within the previous if block and so it will never be reached when it is in a true state. e.g. you have something like: if (e.getActionCommand().equals("q2")) { { // this block is unnecessary // bunch of stuff in here...