953 Posted Topics
Re: 1. there isn't reason to use prehistoric AWT Applet, nor JApplet to use JFrame instead 2. background = ImageIO.read(new File("gameBackground.png")); etc aren't valid path for File in Java, there are two ways put images as files to Java packages or to type full path (I'd not be suggest) 3. don't … | |
Re: @JamesCherrill (OT, can be taken as flamewar) with KeyBindings is our life again quite easier import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.border.*; public class Calculator { private JTextField display = new JTextField(25); private JPanel panel = new JPanel(); private JFrame frame = new JFrame("Calculator Panel"); private Action numberAction = … | |
Re: wrong design, wrong notifiers, most important is repaint(); inside paint/PaintComponent (repaint from itself) caused endless loop with high CPU and GPU usage, missing there stop repainting for contianer or super.paint() as 1st code line in paint, otherwise nothing will be repainted correctly, only nice flickering | |
Re: agree with Java8 docs for Swing APIs, there weren't significant changes (excluding bridges/APIs between JavaFX8 and Swing) | |
Re: - reason why DocumentListener is implemented in JTextComponents APIs, - do not to use KeyListener for JTextComponents, you can'r be able to manage all KeyEvents, nor text is inserted from ClipBoard - there you can to append to another Document or share the same Document for two, bunch of JTextComponents, … | |
Re: - enless loop by default causes flickering, - use Swing Timer with repaint instead of Runnable#Thread | |
Re: - use JToggleButtons in loop, add ActionListener (already used) - you created a new Scanner in every..., how did you want to put that together, remove every code lines in ActionListener, only append String value from e.getSource, there no need to test for every Objects, don't to complicate simple things, … | |
Re: [crossposted and answered](http://stackoverflow.com/q/23857245/714968) | |
Re: nothing clear from posted question - your question is about AWT, GWT, JavaFX, Swing etc... | |
Re: - use JFormattedTextField with input mask or add DocumentFilter with Regex to JTextField instead of plain vanilla JTextField - you have an issue with Concurency in Swing, your code block a Swing GUI untill all events ended (there is possible to lost part of events for Swing GUI), use Runnable#Thread … | |
Re: cr.setVisible(true); should be last code line | |
Re: - Swing/AWT doesn't know a new JComponent is added to already visible GUI, there isn't any notifier automatically relayout container, you have to call revalidate() and repaint() for animation/movement from keyboard - your consume() is quite contraproductive, to change this logics, add required numbers of JLabels to container, use proper … | |
Re: to write a JAVA program that <> to write a Java program that | |
Re: [Inheritance versus composition: Which one should you choose?](http://www.javaworld.com/article/2076814/core-java/inheritance-versus-composition--which-one-should-you-choose-.html), including possible scenarios, rest about performance in dedicated Object is excelently described on Wikipedia too | |
Re: your question is too broad, not clear anything, where is JComboBox, or where will be, etc..., must agree with @stultuske and don't to use static variables, move everything from main class to standard constructor public class Lesson37 extends JFrame { public Lesson37 () { //here to create a GUI } … | |
Re: - setProcess, publish, process aren designated to be right place for creating another thread, they are connectors to EDT - SwingWorker is single threaded, isn't reusable, can't returns any states about itself, designated as bridge betweens EDT and Workers Threads, everything should be executed/initalized/e.i. inside doInBackground(), rest of methods are … | |
Re: depends on.... - if current parent JFrame/JDialog/JWindow for JButton quit = new JButton(); or not (not possible to suggest something based on your code and description), - if yes, then don't extend JFrame/JDialog/JWindow, create this Object as local variable, use this variable e.g. myWindow.setVisible(false) btw equals for JVM resources setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE/HIDE_ON_CLOSE) … | |
Re: @JamesCherrill - please why AWT, disagree - TextListener to each text field (for AWT TextField), note DocumentListener isn't shareable, there isn't possible to add more that one JTextComponent to DocumentListener, solution is create an util.List with pairs for every JTextComponent(s) and DocumentListener/Filter(s) - and ChangeListeners to radio buttons (I think … | |
Re: everything depends of if, which one and how will be resizable | |
Re: - you can to display only one value in JComboBox from Employee emp = new Employee(f, l); - whats ComboEmployee.addItem(emp.full()); - there are two ways add 1. a new Items to JComboBox directly (have to decide if String f or String l) 2. use XxxListCellRenderer by using 2D array Employee … | |
Re: - just guessing ---> not possible to suggest something fomr this desription - use JWindow (undecorated modal JDialog if is neccessary to protect users input or focus) instead of endless funny story about dock(ing) something somewhere - examples about focus recycle for JWindow/JDialog is in all good JCalendars (suggest to … | |
Re: - +++ 10k - (1) and mKorbel whose knowledge of Swing is even more amazing that his interesting use of the English language. ---> not true this knowleges is (only) based on reading Q&As on many Forums - (2) and mKorbel whose knowledge of Swing is even more amazing that … | |
Re: please re_read 1st. answer here by @JamesCherrill. especially 1st. sentence there | |
Re: GlassPane/JViewport(with custom RepaintManager) or JLayer (just the painting illusion, not real Component) | |
Re: - use parameter for override isSelected/hasFocus (not clear from your description) in XxxTableCellRenderer/prepareRenderer - renderer has (bug or feature) memory issue, in most cases have to reset useless painting in another cells - JTable has setting for row, column and cell selection in API | |
Re: there are four ways - OverLayout or JLayeredPane - GlassPane - JLayer (required Java7 based on JXLayer - Java6) - Java Accordion _____________________________________________ - note don't to use JViewport for this job without own custom RepaintManager | |
Re: crossposted on SO (give me codezz - deleted by comunity) | |
Re: - GridBagLayout for JPanel into JFrame.CENTER, there JLabel (Printer: ...) must fills 5 columns in 1st row, - GridLayout(int rows, int cols, int hgap, int vgap) for JPanel.WEST/EAST | |
Re: @milil +1 for courage to answer, but be sure is totally wrong, because all those notifiers can firing an Event after TableCellEditor is terminated, - job for simple TableCellEditor withr JFormattedTextField linstened by DocumentListener (every key released) | |
| |
Re: @Phaelax JTable (standard way) doesn't contains any JComboBox, this is painting illusion made by XxxTableCellRenderer/Editor, in the XxxTableModel is stored initial value for Renderer/Editor @CoilFyzx - use MutableComboBoxModel (is designated for any changes at runtime), could be possible with DefaultComboBox, - there no issue to set separate XxxComboBoxModel for each … | |
Re: @JamesCherrill [please see OPs last post](http://www.daniweb.com/software-development/java/threads/471765/jcombobox-table-cell-editor-removing-items), seems to forgot to tell us that there is JDBC (can't found any words to wrote something cleaver there), then everything is ....??? or maybe isn't ??? | |
Re: - agree read Oracle tutorial for working code example - note (probably typos or fast hands by @JamesCherrill) JCheckBox haven't something with JComboBox, logics is quite/little bit different, for JCheckBox just Boolean value stored in XxxTableModel to represents JCheckBox as Renderer/Editor in JTables view | |
Re: @JamesCherrill you are right, but default returns is toString, (can't found this thread, doesn't works for all standard data types stored in standard arrays) [very good explanations, code example by Rob Camickr](http://tips4java.wordpress.com/2013/02/18/combo-box-with-hidden-data/) | |
Re: - your code missing notifiers required for all of events by using AbstractTableModel, - read Oracle tutorial [How to use JTables](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html), parts 1. [Creating a Table Model](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#data) 2. [Firing Data Change Events](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#fire) 3. [Concepts: Editors and Renderers](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#editrender) 4. [Using a Combo Box as an Editor](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#combobox) - by default we aren't … | |
Re: - override setPrototypeDisplayValue("long String value") for JComboBox, put this JComboBox to the JFrame.NORTH - use JPanel (default LayoutManager is FlowLayout.CENTER) put rest of JComponents to this JPanel (JFrame.CENTER) - print screen talking about JFrame (GridLayout with three rows, because there is crazy gap), JComboBox and two separates JPanels contains JComponents … | |
Re: @JamesCherrill - happy new year, all the best for you and your family - can't resist, flamewar again - [You can also set minimum sizes for your JPanels, which may help with some spacing issues.](http://stackoverflow.com/questions/7229226/should-i-avoid-the-use-of-setpreferredmaximumminimumsize-methods-in-java-swi) - all JComponents can returns own PreferredSize acceptable by LayoutManager - excluding JTable (setPreferredScrollableViewportSize) and … | |
Re: - you are added JComponents to the already (potentially can be) visible Swing GUI, meaning code line setVisible(true); - you hae to move this code line to the end of constructor, after all JComonents are added to container (JFrame) | |
Re: - isn't logics for Input/OutputStream better for FileIO from database, maybe doesn't matted, but - you have to start to loading Image/BufferedImage, then to covert to ImageIcon/Icon (by test if is instanceof ImageIcon/Icon before) | |
Re: - read Oracle tutorial How to use Trees, there is (incl. you issue) quite everything described and correctly - TreeModel only to store value for JTree's view | |
Re: [crossposted](http://stackoverflow.com/q/20612531/714968) | |
Re: :-) convert to String, hmmm then how to do, something - with decimal and thoushand (I'm hope that there isn't added or inputed Indian Number Format, inputed by mistake, then all logics go away, to milky way) separator(s) - @<M/> this lesson has important issue because you determine nextLong(), then … | |
Re: - how easilly could be to trace code from an [SSCCE](http://sscce.org/), short, runnable, compilable not from description - nobody knows if is there used MouseListener and MouseMotionListener or restricted in MouseAdapter _____________________________________________________________ - (repeating) every Listeners (excluding DocumentListener) can returns an Object, you can to compare (==) this Object with … | |
Re: my view is that all Object exists untill main class is fully executed, Total memory is :63438848 Initial free memory is :62778040 free memory after garbage collection :63155624 free memory after integer allocation :62494816 memory used by allocation :660808 free memory after collecting discarded integers :63165616 so different situations can … | |
Re: 1. never to set column coordinates inside XxxTableCellRenderer - TableColumn tacol = table.getColumnModel().getColumn(column); // this was missing nor columns target, - tacol.setCellRenderer(this); // this was missing - both above code lines is way directly to the troubles 2. this renderer can works for whole JTables view visible on the screen, … | |
Re: @Tu Dinh - virtual -100 in compare with nice crying in last post 1. read Oracle tutorial How to use Tables for working code examples, there are mentioned in all parts how the XxxTableModel works 2. logics could be add Vector<Object> to Vector<Vector<Object>>, 3. have to test if EMSSubjectDAO returns … | |
Re: +1 without Function Object.toString() is used to display text in JTree GUI, so you have to @Override toString() to get your expected string | |
Re: +1 for Java Naming Conventions - and very important details don't to call, never super.paintComponents(gr); but super.paintComponent(gr); - paintComponents required little bit more effort and knowledge than simple paintComponent, then is easier to override paintChildren __________________________ - override getPreferredSize for public class GraphicUse extends JPanel, don't forget to add @Overrride … | |
Re: (EDIT) blablablba, - lightweight job for SQL interpreter, instead of hard process on the client side | |
Re: - desk=new JDesktopPane(); should be created on [Initial Thread](http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html), - quite sure that in Java7 nothing happened on the screen, in Java6 are chances very volatille |
The End.