953 Posted Topics

Member Avatar for wolwayne

[crossposted](http://stackoverflow.com/questions/17130260/java-swing-getting-values-from-dynamically-generated-jtabbedpane)

Member Avatar for mKorbel
0
425
Member Avatar for manpreetchaney

> i have a problem in logic of swapping in java. That is how to swap no. of buttons with mouse click i am not getting the proper code for that..,please, can anybody there 2 help me out..! thnks - whats **swapping in java** - whats hidden in **how to …

Member Avatar for manpreetchaney
0
178
Member Avatar for ktsangop

- change **null** from **int response = JOptionPane.showConfirmDialog(null ...** to real parent, any (J)Component that returns true from isDisplayable(), means that is already visible on the screen, then **JOptionPane** will be centered to this Point - JOptionPane is only the JDialog, then there is possible to moving with locationOnScreen, - …

Member Avatar for ktsangop
0
3K
Member Avatar for jemz

- all discusion about **KeyListner** is wrong, caused a few another side effects from usage of wrong **Listener** - there no reason call for **repaint()**, why repeating, supply methods implemented in API, all those notifiers are implemented and correctly - not, never to use **KeyListener** for **Swing JComponents**, this **Listener** …

Member Avatar for jemz
0
1K
Member Avatar for DrEinstein

- remove *panelOne.setSize(300,300);* - remove *super.setSize(300,300);* use *pack()* instead - remove all *super.Xxx*, create an *local variable for JFrame* - *JPanels* dimension (inside *JScrollPane*) must be greater than rectangle from *JScrollPane* (basic property, reason why *JScrollPane* is there), otherwise *JScrollBar* isn't visible

Member Avatar for DrEinstein
1
149
Member Avatar for maroun.maroun

[crossposted & answered](http://www.coderanch.com/t/613486/GUI/java/Showing-JTree-scroll-panes)

Member Avatar for mKorbel
0
147
Member Avatar for CoilFyzx

**So far I have managed to use a TableModelListener to respond to the changing cell values** - don't to use Model Listeners to change Model, - this is Model_To_View notifier, carrefully with that, result can be endless loop, - override setValueAt for computations inside XxxTableModel **What I wish to do …

Member Avatar for CoilFyzx
0
452
Member Avatar for timi_ca
Member Avatar for Start4me

1. use JApplet not Applet (I'd suggest to use JFrame instead) 2. put there JPanel ant to override paintComponent instad of paint() 3. 1st. code line should be super.paintComponent(), otherwise all painting will be cumulating 4. rest is described in Oracle tutorial [Performing Custom Painting](http://docs.oracle.com/javase/tutorial/uiswing/painting/index.html)

Member Avatar for JamesCherrill
0
381
Member Avatar for mintcrops

[crossposted](http://stackoverflow.com/questions/16777758/how-to-load-jpanel-in-a-jframe-using-button-click-netbeans)

Member Avatar for mKorbel
0
345
Member Avatar for mKorbel

- Please how is possible (probably dirty hack) to create [How to Create Translucent and Shaped Windows](http://docs.oracle.com/javase/tutorial/uiswing/misc/trans_shaped_windows.html) - undecorated container (returns *java.awt.IllegalComponentStateException: The frame is displayable.*) - change Look and Feel for (returns *AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated*) - by using code from linked official tutorial . import java.awt.*; …

Member Avatar for mKorbel
1
1K
Member Avatar for Dane2259

1. there are two ways - by moving with derived JScrollBar from JScrollpane - by moving with JViewport to desired Rectangle 2. both are based on Rectangle from JComponent.getBounds(), where JComponent.getBounds() is required JComponent to be visible in JViewport 3. easiest of ways is moving with JViewport e.g. **JScrollPane#scrollRectToVisible(JComponent.getBounds())**

Member Avatar for mKorbel
0
132
Member Avatar for CoilFyzx

@bguild answers here going wrong directions, please to review that, from end to the start, @CoilFyzx please whats your goal, there are simpler ways, by using JTable and/or with another, both JTables can has the same TableModel, depends of your final idea, used notifiers and Listeners

Member Avatar for JamesCherrill
0
947
Member Avatar for wolwayne
Member Avatar for riahc3

*Sometimes I update my web service JAR by deleting the old one*, are you tried to use JWS(tJWS not clear from your description)

Member Avatar for jwenting
0
256
Member Avatar for G_S

[looks like as we are](http://en.wikipedia.org/wiki/Composition_over_inheritance) mixing [composition with inheritance](http://www.javaworld.com/jw-11-1998/jw-11-techniques.html)

Member Avatar for G_S
0
197
Member Avatar for justin.dienger

1. add JPanel to JFrame, override paintComponent for JPanel, custom painting is done for container only 2. JPanel must be focusable, setFocusable(true), otherwise isn't possible to catch events from KeyListener 3. override getPreferredSize, then all coordinates for Oval could be calculated from getHeight/getWeight only, works after JFrame is resized too …

Member Avatar for stultuske
0
2K
Member Avatar for Red_Rain

JTable has the similair structure as - Database (column names and row) - original xml structure is about (similair to) databases or Tree structure - plain csv file (acceptable by MsExcell as well), there are a few codes how to export JTable to MsExcel (JTableHeader and rows too), its only …

Member Avatar for mKorbel
0
256
Member Avatar for milkman93

agreed with @stultuske, another points, depends of - JButtons arrays is created once time or dynamically on runtime - not sure if GBC (this ways) works correctly (from posted codesnipped), maybe use GridLsyout - no idea whats **courseBtnArray.add(new JButton("Course 1"));** and **courseBtnArray.add(new JButton("Course " + (i + 2)));**, why JButtons …

Member Avatar for mKorbel
0
487
Member Avatar for riahc3

there are see two issues 1. decimal separator is dot programming languages 2. use Numbers instance with Currency formatter, then output to the Java GUI will be 10,00, but stored with dot internally

Member Avatar for mKorbel
0
554
Member Avatar for trishtren

1. **model = new DefaultListModel()**; should be declared as local variable or separate class 2. **List = new JList( this.observerlink.getlist() )**; a) **List** is reserved Java word for **util.List** and **awt.List** ....change that to **myList** (Java is CaseSensitive, for more infor to search for Java naming convention) b) **myList** should …

Member Avatar for trishtren
0
208
Member Avatar for vishalonne

@jalpesh_007 - wrong, not true at all - [Top-Level Containers](http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html) are bases on properties came from Native OS, - simple [**Top-Level Containers** never ever are** GC'ed**](http://stackoverflow.com/questions/6309407/remove-top-level-container-on-runtime) - then **setVisible(false)** == **dispose()** - there are two proper ways a) [CardLayout](http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html) b) (if is there real reason) then to use **JDialog** and …

Member Avatar for rush_parekh
1
10K
Member Avatar for game06

- [crossposted](http://www.coderanch.com/t/607931/GUI/java/removing-image-background-color-java) - again don't paint to the container directly, use JComponent, JPanel, JLabel - prepare an Image in SW that can do that, is designated for, save as png, put ImageIcon to the JLabel

Member Avatar for mKorbel
0
2K
Member Avatar for rancosster

- [crossposted](http://stackoverflow.com/q/15565757/714968) - create an [SSCCE](http://sscce.org/), short, runnable, compilable, otherwise anyone can ended with **"Whats ModelEquivalent"**

Member Avatar for rancosster
0
461
Member Avatar for hwoarang69

- never to paint to the Top-Level Containers, use JPanel instead - prepare all Objects to the Array (if there are more than one element) - use paintComponent inastead of paint

Member Avatar for hwoarang69
0
558
Member Avatar for timetraveller1992

- in Swing are implemented methods for displaying Icon / ImageIcon in JComponents APIs - put ImageIcon / Icon (create an loval variable) to the JLabel.setIcon(logo) directly, - for this job isn't required to play BufferedImage - another issue is about layout contens properly

Member Avatar for JamesCherrill
0
156
Member Avatar for DavidKroukamp

@David, probably not an answer - why reinvent the wheel (as you know very well I'm always against...), use standard code made by Sun or SwingX (has issue with Carret & Highlighter) - maybe not to use KeyBindings or KeyListener, job for AWTEventListener (key & mouse events) - I miss …

Member Avatar for bguild
1
1K
Member Avatar for harinath_2007

- agreed with @JamesCherrill about util.Timer, Executor (black hole, dirty and empty API), notice about EDT - [for endless loop I'd be to use util.Timer invoked Executor, and executor to invoke SwingWorker (same as Executor, the same black hole, dirty API)](http://stackoverflow.com/a/7049095/714968) - every IDE has implemented one_click to JProfiler

Member Avatar for mKorbel
0
169
Member Avatar for aabbccbryanmark

- use JFormattedTextField for number instance (similair code example in Oracles tutorial about how to use JFormattedTextField), or JSpinner - there are two ways (JTextComponents returns Document, model for JTextComponents, use getDocument rather than getText) 1. use DocumentListener (in the case that all changes from JTextComponents will going outside) 2. …

Member Avatar for aabbccbryanmark
0
2K
Member Avatar for isacc

**can i change toggle button's state to another (play state to pause),by clicking another button(stop)** - **JToggleButton.setSelected(true / false)** (inherits from **JCheckBox** / **JRadioButton**, has two states) - use **ItemListener** (returns **SELECTED** / **DESELECTED**, then easy to test), otherwise you have to test for **isSelected()**

Member Avatar for mKorbel
0
175
Member Avatar for milkman93

use NumberFormat or DecimalFormat for number instance, set proper RoundingMode and decimal places if needed for example import java.math.RoundingMode; import java.text.NumberFormat; import java.util.Formatter; public class round { public static double roundTo2Places(double value) { assert value >= Long.MIN_VALUE / 100 && value <= Long.MAX_VALUE / 100; long digits = (long) (value …

Member Avatar for milkman93
0
5K
Member Avatar for StefanRafa0

[crossposted](http://stackoverflow.com/questions/15211134/blocking-thread-when-progressbar-is-running)

Member Avatar for mKorbel
0
286
Member Avatar for Violet_82

- **JPanel** has implemented **FlowLayout** in API - **FlowLayout** accepting only **PreferredSize** that came from **JComponents** back to the container (**JPanel** in this case) - **Painting in Swing**, **Graphics(2D)** by default never returns any **PreferredSize**, [have to override this **Dimension**](http://stackoverflow.com/a/11071471/714968) - don't forget to set coordinates to the **getHeight/Weight**, instead …

Member Avatar for Violet_82
0
3K
Member Avatar for unholy.vlad

have to testing with **if (jSlider1.getValueIsAdjusting()) {** inside **ChangeListener**

Member Avatar for mKorbel
0
88
Member Avatar for harinath_2007

harinath_2007 wrote **Whenever the text in the textarea fills up completely , i want the scrollbar to scroll down.** there are two ways: 1st. way JTextArea textArea = new JTextArea(); DefaultCaret caret = (DefaultCaret)textArea.getCaret(); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); 2nd. way - get the **JScrollBar** from **JScrollPane** as local variable, - add **DocumentListener** to …

Member Avatar for harinath_2007
0
113
Member Avatar for SoulofchaOs

there are two ways - use [ButtonModel](http://docs.oracle.com/javase/7/docs/api/javax/swing/ButtonModel.html), there are **isArmed()**, **isRollover()**, **isSelected()**, returns **action**, **memonic** and **name** too - but and or with [JButton#get/putClientProperty(Object key, Object value)](http://docs.oracle.com/javase/7/docs/api/javax/swing/JComponent.html#putClientProperty%28java.lang.Object,%20java.lang.Object%29), ther you can multiple description in String, number of keys isn't limited somehow

Member Avatar for mKorbel
0
252
Member Avatar for dreamslct

AFAIK not possible, without JNI/JNA, otherwise Font, Color, MessageType is based on resources came from Native OS, in the case that you'll to change theme in OS, then will be changed these properties too, accesible frome Win32, Net, C++, e.i.

Member Avatar for JamesCherrill
0
363
Member Avatar for cor.vandijk.779

- everything depends of [JTable.setSelectionMode](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#selection) - **To retrieve the current selection, use JTable.getSelectedRows which returns an array of row indexes, and JTable.getSelectedColumns which returns an array of column indexes. To retrieve the coordinates of the lead selection, refer to the selection models for the table itself and for the table's …

Member Avatar for mKorbel
0
611
Member Avatar for mKorbel

**short version** --> not able to upvote answers **long(er) version** --> I tried this action to the Java forum, in several threads and from two separate PC's logged under my user

Member Avatar for happygeek
0
200
Member Avatar for NidhishKrishnan

[crossposted](http://stackoverflow.com/questions/13931081/why-focus-on-jtextfield-is-not-getting-on-the-first-click-of-tab-button), Focus, FocusSubsystem is pretty asynchronous, have to wrap into invokeLater

Member Avatar for radhakrishna.p
0
824
Member Avatar for Red_Rain

there are two ways to use - JTable instead of plain JTextField - JFormattedTextField with number formatter, instead of set / parsing number valur from plain JTextField ________________________________________________________________________________________________________________________________________________________ you can to use JTextField with DocumentFilter (filtering of uinwanted char(s)) for number value

Member Avatar for mKorbel
0
666
Member Avatar for arcticman452

- don't to recreate a new **JComboBoxes** instance inside **ItemListener**, then you lost referrence to the original **JComboBox** (fired event), create **JComboBox** only once time, - add **ItemListener** to both separatelly only to test **SELECTED** inside **public void itemStateChanged(ItemEvent ie)** - create **ItemListaner** class, there you determine which one firing …

Member Avatar for arcticman452
0
133
Member Avatar for arcticman452

- use Swing instead of AWT (JFrame - Frame, JButton - Button, JComboBox - Choice...) - read [Oracle tutorial how to use JFormattedTextField](http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html), instead of parsing value from AWT TextField

Member Avatar for arcticman452
0
211
Member Avatar for Neversleepin

- for better help sooner post an [SSCCE](http://sscce.org/) - short, runnable, compilable, just to avoids any code came from Layer, MatrixLayer, jPanelVizualisationOptions1.update();, currentPanel.refresh(); - jList1.repaint(); is useless methods, sure required in the case that 1. JList isn't inside JScrollPanel, then to call revalidate & repaint to the JLists parent 2. …

Member Avatar for Neversleepin
0
287
Member Avatar for arcticman452

- for why reason you using AWT to use Swing instead - then Choice should be JComboBox, (Frame/JFrame, Button/JButton) - add ItemListener to JComboBox - ItemListener always fired twice events, SELECTED and DESELECTED, - can to determine, test if ITEM_STATE_CHANGED only

Member Avatar for mKorbel
0
132
Member Avatar for georget1011

- arrays in Programming languages starting with **zero**, - your **JTable** has **4 * 4 elements**, then **setValueAt(whatever, 3, 3)** could be last botton cell on left side - debug before if **items.A[5]** returns some value

Member Avatar for mKorbel
0
1K
Member Avatar for london-G

have to add **PrintRequestAttributeSet** before printing to **Printer** **PrintRequestAttributeSet set = new HashPrintRequestAttributeSet(); set.add(OrientationRequested.LANDSCAPE); Table_Stud.print(JTable.PrintMode.FIT_WIDTH, header, footer, false, set, false);**

Member Avatar for mKorbel
0
780
Member Avatar for easyscript

1. this issue talking about remove then add a new **JComponents** to the (already) visible GUI, have to call **revalidate();** and **repaint();** for container where is placed ..., don't reacreate that on fly 2. load all **ImageIcons** on the Apps startup, store that as local variable 3. then you'll call …

Member Avatar for mKorbel
0
831
Member Avatar for lo0lo0999
Member Avatar for subrat_p

1. see [AutoComplete JComboBox](http://stackoverflow.com/a/7255918/714968) 2. see [how to interact betweens two JComboBoxes](http://www.daniweb.com/software-development/java/threads/363152/problem-w-multiple-jcombobox)

Member Avatar for mKorbel
0
427

The End.