953 Posted Topics
Re: 1) line frame.setVisible(true); must be last line for JFrame constuctor 2) never use Graphics g = frame.getGraphics(); 3) use [URL="http://stackoverflow.com/a/7940227/714968"]KeyBindings[/URL] rather than KeyListener | |
Re: Robot must waiting for (half)second before first usage, this downvote isn't correct screen capture is same as SendKey by default [CODE]import javax.imageio.*; import javax.swing.*; import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.io.*; public class CaptureScreen implements ActionListener { private JFrame f = new JFrame("Screen Capture"); private JPanel pane = new … | |
Re: use [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html"]JFormattedTextField[/URL] with Number Formatter - doesn't care about parsing - set [URL="http://stackoverflow.com/a/8582656/714968"]Formatter to decision number format[/URL] - use [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/documentlistener.html"]DocumentListener[/URL] | |
Re: I think that nothing complicated in this case [URL="http://docs.oracle.com/javase/6/docs/api/javax/swing/table/DefaultTableModel.html"]public class DefaultTableModel extends AbstractTableModel implements Serializable[/URL] you have to add and override this method for removeRow in your AbstractTableModel [CODE]public void removeRowAt(int row) { data.removeElementAt(row); //fireTableDataChanged(); fireTableRowsDeleted(row - 1, data.size() - 1); }[/CODE] | |
Re: 1) place this code line [B]panel.setLayout(null); [/B] before placing JComponent 2) variables [B]JScrollPane scrollpane;[/B] and [B] JScrollPane scrollpane1;[/B] aren't initialized and rest of JComponents | |
Re: you can't put Image as background to [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html"]JFrame[/URL], but 1) ContentPane 2) paintComponent for JPanel / JComponent 3) [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/label.html"]JLabel[/URL] & [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/icon.html"]Icon[/URL] (notice JLabel haven't implemented any LayoutManager, you have to defin for that) | |
Re: You have to set for [URL="http://docs.oracle.com/javase/6/docs/api/javax/swing/JTable.html#setAutoResizeMode%28int%29"]JTable#setAutoResizeMode[/URL], more is described in JTable's tutorial [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#width"]Setting and Changing Column Widths[/URL] | |
Re: not easy job with Nimbus, you have to define own Painter for [URL="http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/_nimbusDefaults.html"]Nimbus Defaults[/URL], much luck | |
Re: 1) wrong that you used code generated by NetBeans 2) fireTableRowsInserted is job for AbstractTableModel, don't call tshi method directly 3) eeerrrgggggggggggt, use DefaultTableModel [CODE]import java.awt.*; import java.awt.event.*; import java.util.Random; import javax.swing.*; import javax.swing.border.LineBorder; import javax.swing.table.DefaultTableModel; import javax.swing.table.TableCellRenderer; public class DefaultTableModelDemo { public static final String[] COLUMN_NAMES = { "Monday", … | |
Re: @cOrRuPtG3n3t!x what's an aswers is [CODE]maybe you coud try setting the bounds of components by setBounds() and setMaximumSize(Dimension) and even setPreferredSize(Dimension) methods? [/CODE] no never setBounds, this is job for LayoutManager, occasionally you can place that by take Insets, but why not use MigLayout most of LayoutManagers pretty ignored setXxxSize | |
Re: if you set [B]JTextArea(m, 10, 15);[/B] , then [B]scroll.setSize(500, 500);[/B] is too contraproductive, call for [B]scroll.pack();[/B] before [B]scroll.setVisible(true);[/B] rather than manually set for size on the screen | |
Re: @117 please and a new quesion, your own question, before that please to read 1. [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/mouselistener.html"]Mouse Listener[/URL] 2. [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/mousemotionlistener.html"]Mouse-Motion Listener[/URL] 3. [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/mousewheellistener.html"]Mouse-Wheel Listener[/URL] 4. let's this too old thread | |
Re: you have to add [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/documentlistener.html"]DocumentListener[/URL] for listening any of changes in [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/text.html"]JTextComponents[/URL] this code for ??? AutoComplete ??? JTextField have got two big issues 1) most important rs (ResultSet) and stmt (Statement) must be closed into finally block, otherwise these Object stay in RAM until current application ended 2) your … | |
![]() | Re: [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html"]JMenu[/URL] isn't designated to invoke any action, JMenu is container nested [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html#event"]JMenuItem(s)[/URL], sure there are two/three choices how to determine if JMenu is visible / hidden my question Why do you want/need to listening for that, for why reason |
![]() | Re: 1) for new window use [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/dialog.html"]JDialog / JWindow[/URL] rather than a [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/frame.html"]JFram[/URL]e 2) for key shortcut use [URL="http://docs.oracle.com/javase/tutorial/uiswing/misc/keybinding.html"]KeyBindinds[/URL] rether than [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html"]KeyListener[/URL] |
Re: Swing (from Java5) for [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html"]Top-Level Containers[/URL] implemented BorderLayout as default [URL="http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html"]LayoutManager[/URL] | |
Re: better once time to see that as 100 times .... [CODE]import java.awt.*; import java.awt.event.ActionEvent; import javax.swing.*; // based on @trashgod code /** @see http://stackoverflow.com/questions/5759131 */ // http://stackoverflow.com/questions/8667719/jdialog-repaint-after-jlist-modification public class ListDialog { private static final int N = 12; private JDialog dlg = new JDialog(); private DefaultListModel model = new DefaultListModel(); … | |
Re: @JamesCherrill invalidate(), please not, never can you please describe reason for sending flag Invalidate for JComponent, I thin that you'll never call this method by hand, because by default is implemented correctly in APIs, and if yes then you have to confirm that by notify()/notifyAll() for already visible Container is … | |
Re: 1) I have a JScrollPane that contains a JPanel with a CardLayout, good GUI design for various screens ratio in pixels and ready for crossplatfom +1 for question 2) I want the contents of the ScrollPane/ViewPort to never exceed the width of the viewport. basically that's contraproductive in contex that … | |
Re: it too hard to implementing JList & Render with some of dirty hack, use JTable with one Column, 1) JTable with JCheckBox is represented with Boolean value only 2) no required any code for Renderer/Editor, because JTable knows Boolean value 3) JTable must be editable for Editor 4) everything [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html"]here[/URL] | |
Re: even oracle tutorial talking about ActionListener, better would be look for [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/itemlistener.html"]ItemListener[/URL] | |
Re: what's Filter for why reason is Filter what's KeyWord where do you want to put Filter that can filtering some (of) KeyWord(s) too hard to start to wrote anything else without yours ... | |
Re: @JamesCherrill @Ezzaral until yesterday I ignored [URL="http://docs.oracle.com/javase/6/docs/api/java/beans/EventHandler.html"]EventHandler[/URL], but now ... somehow as I tried from 'left _to_right_and_back'... I can't found something wrong, nor buggy, here is an [URL="http://stackoverflow.com/a/8942519/714968"]answer[/URL], link inside the code example is about JButton | |
Re: [URL="http://stackoverflow.com/questions/8955663/paintcomponent-output-error"]crossposted[/URL] | |
Re: @cOrRuPtG3n3t!x please use links to the current Java6/Java7 API's, because in most of them were important changes in nested on inherits methods however +1 for simple and clear suggestion | |
Re: there are lots of good workaround for JTable and Database, I'd suggest to search for ResultsetTableModel or TableFromDatabase | |
Re: @Philippe.Lahaie because upvoting is about - valuable info - excelent suggestion - agreement with corret answer - nice answer - etc possitive otherwise on another side is down_vote, but I can't answering this instigation of down_voting, simple I can't found any answer for down_voting or all were deleted before I … | |
Re: [URL="http://stackoverflow.com/a/7553827/714968"]Double haven't any numbers, nor decimal [/URL] (authors lots of Books about Networking, basic Java and Algebra), for real number is Double best way how to represent Number value with correct precisions | |
Re: [CODE]Nope, Doesn't work, thanks anyway [/CODE] be sure that works | |
Re: 1) JWindow is un_decorated Container, there aren't any button (JFrame has three, JDialog only one), 2) this window isn't possible close, hide or terminate current JVM without additional Action e.g from JButton, JMenu or another code that call System.exit(i int), best way is use this container as popup window for … | |
Re: @stultuske I think that no, never ..., Swing GUI isn't designated for listening of KeyListener, especially JTextComponents, because required some Woodoo for correct Focus / FocusSubsystem and required override method setFocusable() [URL="http://stackoverflow.com/questions/7940173/how-do-i-use-keyeventdispatcher/7940227#7940227"]use KeyBindings[/URL], 1) no required override Focus behavior 2) can possible replace/overrive built-in key_shortcuts from BasicXxxUI 3) with same/similair … | |
Re: most of yours KeyEvent are implemented as internal commands for various JComponents, you can check that in BasicXxxUI, how many times I suggest you implements another API | |
Re: not this is by forcing frame.setSize(900,700);, that real reason why ... use pack instead however you can setSize() but 1) don9t use reserved words as ClassName, rename Frame ---> MyFrame panel ---> MyPanel 2) class name start with UpperCase 3) void or method with lowerCase 4) if you want ot … | |
Re: you have look for method paintComponent, check tutorial [URL="http://docs.oracle.com/javase/tutorial/2d/index.html"]Graphics[/URL] | |
Re: 1) JMenu.addSeparator this JSeparator has Color, you can change this Color for translucent effect 2) JMenuItem.setBorder(new EmptyBorder(10,10,10,10)); | |
Re: not going to test or run bunch of your code posted here 1) your AbstractTableModel not correct, there is useless TableModel or whole class Kund, because both are Models, and you can fill data for JTable from class Kund correctly, and returns changes from JTable to the class Kund correctly … | |
Re: you have look for [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#sorting"]JTable Sorting / Filtering[/URL], tutorial contains similair example | |
Re: why bothering with that not simple job use JDialog instead, don't have a minimize maximize button. | |
Re: SwingX have got implemented excelent Java Calendar, there is simple workaround for Weekend and same way you can implements Special Days, agreed with @NormR1 must be manually hardcoded/added to the File or Database | |
Re: there any Bug with TableCellEditor, some your mistake, post a runnable code that demonstrated your issue, because your code works in my hands as I expected | |
![]() | Re: not runs your code 1) textArea1.append(String.valueOf(df.format(monthlyPayment)) + "\n"); 2) use [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html"]JFormattedTextField[/URL] similair example in the tutorial 3) Add scroll bars to textArea read tutorial about [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/textarea.html"]JTextArea[/URL] ![]() |
Re: 1) one most confortable way is put formatted output from the File to the JTable with removed H & V grid 2) by using Html is possible tabular output to the JTextPane, JTextArea not designated use Htlm correctly 3) create three JTextArea (added to JPanel) EDIT 4) [URL="http://stackoverflow.com/questions/8533612/align-strings-in-columns-in-jtextarea"]here[/URL] is your … | |
Re: 1) you have to accept that [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/scrollpane.html"]JScrollpane[/URL] is designed to nest only one [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html"]JComponent[/URL], 2) there simply workaround put three [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html"]JTables[/URL] to the [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html"]JPanel[/URL], 3) JScrollpane.add() function is not right check [URL="http://docs.oracle.com/javase/6/docs/api/javax/swing/JScrollPane.html#JScrollPane%28java.awt.Component%29"]contructor in API[/URL] | |
Re: all changes for Swing JComponents must be done in EventDispashTread, and you have issue with Concurency in Swing, because your method IncomingReader doesn't inkoke EDT, short description ---> wrap incoming.append(message + "\n"); to the invokeLater() long [URL="http://docs.oracle.com/javase/tutorial/uiswing/concurrency/initial.html"]Concurency in Swing[/URL] | |
Re: 1) look how [URL="http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html"]LayoutManager[/URL] works 2) use [URL="http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html"]CardLayout[/URL] instead of AbsoluteLayout 3) read tutorial about [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/actionlistener.html"]ActionListener[/URL], [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/button.html#abstractbutton"]JButton[/URL] and [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/menu.html"]JMenu[/URL], 4) if you don't want to bothering with CardLayout, then for swaping (remove then add) betweens JComponents you have to call revalidate(); repaint();//most cases required 5) follows examples from linked tutorials | |
Re: better would be look at [URL="http://docs.oracle.com/javase/6/docs/api/javax/swing/text/JTextComponent.html#write%28java.io.Writer%29"]JTextArea#write(Writer out) throws IOException[/URL] then put JTextArea to JOptionPane | |
Re: 1) that not possible, you have to add one JLabel on the TOP and 2nd on BOTTOM, 2) not possible change [URL="http://stackoverflow.com/questions/6144775/messageformat-header-footerformat-how-to-change-font-for-jtable-printing"]Font and another methods[/URL], [CODE]MessageFormat header = new MessageFormat(" Whatever"); MessageFormat footer = new MessageFormat(" Page {0,number,integer} Whatever"); try { PrintRequestAttributeSet set = new HashPrintRequestAttributeSet(); set.add(OrientationRequested.LANDSCAPE); myTable.print(JTable.PrintMode.FIT_WIDTH, header, footer, … | |
Re: [URL="http://docs.oracle.com/javase/6/docs/api/javax/swing/SwingUtilities.html#isLeftMouseButton%28java.awt.event.MouseEvent%29"]SwingUtilities[/URL] implements (only for mouse with three Buttons, for example there are Mouse with 5Buttons, then rest of Buttons are ignored by default) isLeftMouseButton isMiddleMouseButton isRightMouseButton |
The End.