953 Posted Topics
Re: @stultuske you are wrong @JohnSoftware read official Oracle tutorial for working code example about how to search in JTextComponent with highlighting matches | |
Re: - JPanel uses FlowLayout as default LayoutManager inplemented in API - set GridLayout to JPanel (you already set to JFrame, then there you put JPanel with JComponents) | |
Re: depend of how deep you want to go, you have to override RowFilter - basic red official Oracle tutorial [How to use Tables - Sorting and Filtering](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#sorting) for working code example ___________________________________________________________ - [simple](http://stackoverflow.com/a/8187799/714968) - [extended](http://stackoverflow.com/questions/17854854/jtable-rowfilter-and-rowfilter-entry) - there is used JToggleButton for filtering, add Action/ItemListener to JComboBox then result will … | |
Re: - [EventHandler can do that](http://stackoverflow.com/a/9007348/714968), there you can to wrap a few events together, required excelent knowledge about Java Essential Classes, Swing and AWT Listeners, there/this (never tried) maybe doesn't works for Beans with PropertyChangeListener, PropertySupport, this info can be probably out of scope for you - every Listener (excluding … | |
Re: [crossposted](http://stackoverflow.com/questions/20218165/how-to-update-jtable-based-on-the-items-i-click-in-my-jcombobox) | |
Re: - use ListSelectionListener, test if selectedRow > -1 (no row is selected), otherwise you will received a few nice exceptions from endless loop, and this code construction to freeze current JVM instance, can be closed from Taskbar only - change JTables SelectionMode to SINGLE_...., otherwise you have to loop inside … | |
Re: - never to perform long runnig task from ActionListener, nor wrapped into invokeLater, Swing GUi freeze untill long and hard JDBC ended - why did you recreated whole GUI on fixed period, Swing JComponents are designated to be reused, did you count those JFrames - no idea how to help … | |
Re: - question in this form isn't answerable - Or can you suggest something else? 1. L&F must be intialized as 1st code line in main class 2. Swing GUI must be created on Initial Thread | |
Re: and add - newIcon.flush() before is a new ImageIcon / Icon added to JLabel() - flush() can protect JLabels resouces to repaint correctly, especially in the cased that ImageIcon / Icon is loaded from local/network HDD or from URL (web etc...) | |
Re: - JFrame is Top-Level Container, its RootPane isn't by default focusable, then can't receive Key Events - you have to 1. put there JPanel 2. override paintComponent instead of paint 3. 1st. code line inside paintComponent(Graphics g){ shoudl be super.paintComponent, otherwise painting cumulated 4. use KeyBindings, in a state of … | |
Re: [crossposted](http://stackoverflow.com/questions/19839416/how-to-add-actions-on-the-image-in-jpanel) | |
Re: 1. create DefaultTableModel for JTable 2. in DefaultTableModel, there to override - public Class<?> getColumnClass(int column) { seems like as there are numbers only, then with Long or Double.Class - public boolean isCellEditable(int row, int col) { returns false (non-editable) for column contains sum, result - public void setValueAt(Object aValue, … | |
Re: - don't to create more that one JFrame, use JDialog with JFrame as parent, and/or with modality too - easiest of ways is usage of CardLayout with JPanels as Card, views - call JFrame.pack() after Card is switched (note works only in the case there is used LayoutManager, not NullLayout) | |
Re: - this question is about business rules, logics not about Java & JDBC, - by default most of profesional apps for trading has very similair structure and concept | |
Re: please 1. your question is 2. again change JComboBoxes to JSpinner (31/February) | |
Re: - use JSpinner, read Oracle tutorial for working code example instead of String[] Month and String[] Day, otherwise you will able to add funny Date, e.g. 31. february etc... - for output to use JTextArea, formatted output from all JTextFields, JSpinners, JComboBoxes (with combine in text from JLabels) | |
Re: - right there is with Renderer in some cases not starting higlighter and its painting for begining of node, but starting where close parent ended - for future readers post ans [SSCCE](http://sscce.org/), short, runnable, compilable demonstrated a.m. defect from renderer, and with hadcoded value for Nodes | |
Re: probalby 1) you want to use a) ActionListener for TextField only, then remove TextListener from TextField (standard logics for Chat) b) both, then content inside public void textValueChanged(TextEvent te) { must to know if is there event fired from ActionListener or KeyTyped, e.g. by using boolean for creating String or … | |
Re: note - this code is about old and refused practicies - never use Thread.sleep(int) in Java - never use Graphics g2 = panel2.getGraphics(); this method is proper for printing to printer or saving to BufferedImage - search here JPanel + paintComponent, delayed by Swing Timer | |
Re: btw job for Renderer | |
Re: [very similair suggestion to crosspost](http://www.coderanch.com/t/620697/GUI/java/Paint-painting) | |
Re: use [JFormattedTextField](http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html) | |
Re: [crossposted on SO](http://stackoverflow.com/q/18527158/714968) | |
Re: extends **JEditorPane** implements **TreeCellRenderer** - please whats goal, reason('s maybe), simple why - whats has linked JEditorPane with TreeCellRenderer to do together as JTable Renderer - who from them is (may question could be) parent, who is child and grand_parent - my answer is simple, short **not**, don't do that, … | |
Re: [crossposted](http://stackoverflow.com/questions/18293574/adding-multiple-enums-to-jcombobox) | |
Re: - override getPreferredSize not setXxxSize @Override public Dimension getPreferredSize() { return new Dimension(int, int); } - JPanel is ImageObserver, then null should be this **g.drawImage(image, getWidth(), getHeight(), this);** - its container (assume that JFrame) take it from JFrame.pack() - interesing is that you can to determine MinimumSize by JFrame.pack(); // … | |
Re: - Graphics graphics = cPanel.getGraphics(); 1. is proper methods for saving this snapshot to File, BufferedImage, paper Printer 2. this snapshot is very volatile, can expired on 1st mouse, key or from methods implemented in API 3. has nothing to do with ---> I need to draw an image Dynamically, … | |
Re: > Yes, this is experimental. Have not clean up yet. then before (and/or with suggestion by @JamesCherrill +++) - JFrame by default never to react to Key Event - add JPanel to JFrame - override paintComponent for JPanel instead of paint for JFrame - use KeyBindings instead of KeyListener or … | |
Re: - don't put JComponents to the XxxTableModel, there is stored only referrence, prepared value for Renderer/initial value for Editor - XxxCellRenderer isn't somehow restricted, but you have to accepting that everything here is only about static painting, virtual illusion based on methods implemented in APIs - there are three ways … | |
Re: - use JComboBox, a.m. logics doesn't require waiting for users decision - use JOptionPane in the case would need, stop to block code execution, - JOptionPane has internal event closed, canceled etc, more in the API - return Option_Seleted; probably returns number constant, e.g. button and closed, canceled | |
Re: use JFreeCharts, there is termomether as pre_defined graph (in version that I tried), if not then is so easy to create Shapes with rainbows colors, toggle with value | |
Re: > no its not. > its a personal project loop inside container where JComboBoxes are laid, by checking if(xxx instanceof JComboBox(Oracle APi)/ComboBox(your class)) desired and filtered Objects is accesible, pseudocode Component[] comp = container.getComponents(); for (int i = 0; i < comp.length; i++) { if (comp[i] instanceof Xxx) { comp[i].wheteverMethodImplementedInConcreteAPI; … | |
please overview for Java Forum, http://www.daniweb.com/software-development/java/9 isn't accessible for me, I can't see any exception, screen is blank, missing there Q&A's | |
Re: - JFreeCharts are based on AWT, - calculation of final size (on the screen for all Swings LayoutManagers) is based on PreferredSize - childs returns PreferredSize back to contianer, then JFrame.pack(BorderLayout implemented in API) will calculate proper Rectangle for JFrame('s ContentPane) - good practicies is to override getPreferredSize for ChartPanel … | |
Re: - question isn't clear, please whats *I cannot find a way to display variables' values in Java Applet.*, variables from and for why reason(s), code posted is about basic Java knowledges and haven't something with Applet/JApplet, you'll be the same issue in C++/.Net or Php - use Hybrid JApplet (Swing … ![]() | |
Re: ActionListener is desingnated to runce only one time, from Mouse or Key Events, issue must be in rest of your code | |
Re: - myPanel.scrollRectToVisible(JComponentFrom_myPanel.getBounds()); - search for next focusable, you can to play with get/setFocusedComponent() wrapped into invokeLater - most complex code is based on myComponent.getFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS), after Focus switched is required to switch notifiers betweens JComponents too | |
Re: I miss there 1. override getColumnClass, its very important for JTables view to know data types stored in DefaultTableModel 2. reset DefaultTableModel to null, use (there are a few another methods, you can to starting with) **model.setRowCount(0);** before a new rows are added to 3. create (I assumed that there … | |
Re: do you meaning something similair as is for ATM, where you type (pseudo numbers) [7542 and result is 75.42, then is possible, quite easilly](http://stackoverflow.com/questions/17074758/make-a-jformattedtextfield-behave-like-atm-input) | |
Re: - get all Top-Level Containers from current JVM instance (I'm assume that there are only Swing containers) Window[] wins = Window.getWindows(); for (int i = 0; i < wins.length; i++) { if (wins[i] instanceof JDialog) { wins[i].whateverMethodsInAPIForJDialog; } else if (wins[i] instanceof JWindow) { wins[i].whateverMethodsInAPIForJWindow; } else if (wins[i] instanceof … | |
Re: 1. is required to override [cancelCellEditing() and stopCellEditing()](http://docs.oracle.com/javase/7/docs/api/javax/swing/CellEditor.html#stopCellEditing%28%29) for TableCellEditor, you can to create startCellEditing() nested proper Boolean flag 2. otherwise, for better help sooner post an [SSCCE](http://sscce.org/), short, runnable, compilable, just about JFrame with JTable, invoked JOptionPane from TableCellEditor | |
Re: - put there JPanel, don't to paint to the Top-Level Container directly - override for JPanel 1. getPreferredSize, then all coordinates for painting are based on getWeight/Height 2. use paintComponent() instead of paint() - don't to use Keylistener, use KeyBindings added to JPanel - don't to provide FileIO (ImageIcon), load, … | |
Re: - please do you mean, can we starting with (then I can't use escape characters, e.g. slash "\") - just code simulation, out of corrrect answer on my side . import java.util.*; public class MyStringArray { private List<String> strings; public MyStringArray(String[] strArr) { strings = new ArrayList<>(); strings.addAll(Arrays.asList(strArr)); } @Override … | |
Re: - all Layout Managers(customs too), together with JFrame.pack() are calculated on PreferredSize (based on component tree, ZOrder), first is painted last, on top JComponent - with some LayoutManagers is possible to resize childs, with some isn't possible (FLowLayout), or settable (GridLayout, SpringLayout, MigLayout) - most of LayoutManagers accepts only PreferredSize, … | |
Re: 1. where you lost signpanel.add(signBtns[0]); 2. probably have to check all numbering for next JButtons 3. then array should be declared private JButton signBtns[] = new JButton[5]; 4. to dissable, comment code line //this.setContentPane(main_p); | |
Re: - required to override (last two code lines) myTable.doLayout() myTable.repaint() - as dirty hack, sure better could be to move those methods to the XxxTableModel as method - all/both JTables view (in your case) have got only one ColumnModel | |
Re: I think that proper way is described in previous post | |
Re: - add MouseListener to container (JPanel???) - override *public void mouseClicked(MouseEvent e) {* then there are two ways panel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (e.getModifiers() == MouseEvent.BUTTON3_MASK && e.getClickCount() == 1) { // whatever } } }); or panel.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) … | |
Re: [crossposted & answered](http://stackoverflow.com/questions/17137550/how-to-add-jradio-button-at-run-time) |
The End.