953 Posted Topics
Re: - don't to create a new [Top-Level Container](http://docs.oracle.com/javase/tutorial/uiswing/components/toplevel.html), nor on runtime, this is road to the troubles - see [CardLayout](http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html) - there are issues with variables (I can see that in **ActionPerformed**) - why to re_create a new **JComboBox typeCargo = (JComboBox)evt.getSource();**, this **JComboBox** isn't placed and layed in **Swing … | |
Re: @JamesCherrill is not used, but to avoiding of catching the image, I'm not good in Graphics, but I saw a few suggestion to use byte[] and ImageObserver, but for JPanels Background, there is paintComponent best of ways (with boolean for repaint()) | |
Re: not never to use **KeyListener** for **JTextComponents**, wrong way, have look at **DocumentFilter** for special **Chars** to use **Pattern** | |
Re: are you set ODBC for this MsAccess | |
Re: >Can I reduce the size of the JTable? Currently it takes the size as that of the panel. no idea about numbers of records. but 1) **myJTable.setPreferredScrollableViewportSize(myJTable.getPreferredSize())**, for a few row, this should to reduce the size of **JScrollPane** 2) have to get **height from row** (Assume that every rows … | |
Re: - for better help sooner post very short, compilable and runnable [SSCCE](http://sscce.org/), demonstraded your real issue, - otherwise everything are shots to the dark, - whats **laf_11112.jar** - read [Modifying the Look and Feel](http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/index.html) before | |
Re: 1.) File f = new File("C:\\Photos\\System\\Wooden Floor 4x4.png"); don't load anything, nor **FileIO** inside **paint** / **paintComponent** / **paintChildren**, prepare this Object as local variable, because a) paintComponent is called internally when JComponent required repaint() b) each of mouse and keyboard events to invoked paintComponent 2.) int height = image.getHeight(); … | |
Re: 1. don't use **KeyListener** for **JTextComponents**, use **DocumentListener**, 2. use **JFormattedTextField**, 3. I'd be to use **DocumentFilter** with **Pattern**, filtering for non_alphabets chars, then there no needed any prompt about non_number char is inputed, | |
Re: put points 1. and 2. by JamesCherrill together and to use JToggleButton, crossposted on another Java Forum | |
Re: java.Util.Date myDate = rs.getDate("DateOfTask"); for various column def on DbSide Datetime, date, time, TImestmpt | |
Re: Container panel = myTextField.getParent(); SwingUtilities.invokeLater(new Runnable() { public void run() { panel.scrollRectToVisible(myTextField.getBounds()); } }); - or another way by determine **Rectangle** from some **Point** of **JPanel** and by moving with the **JViewport** (not easiest of ways, but you can to e.i. centering **Point** rellative to the **JViewport**) | |
| |
Re: - why bothering with compilier, better could be to post to forum, isn't it ....... - there isnt created any of two JFrames, - there are two main methods remove one of them - don't extend JFrame, create that as local variable, otherwise part of important methods isn't accesible directly, … | |
Re: - there no reason to add **MouseListener** or **MouseMotionListener** to [JTable](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#selection) (but to use for ToolTip), add [ListSelectionListener](http://docs.oracle.com/javase/tutorial/uiswing/events/listselectionlistener.html), code examples in both of links from Oracle tutorial - notice [Filtering and Sorting](http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#sorting) can complicating those things | |
Re: setSize for JFrame must be calculated by Layout Manager, then each of JComponetns returns JComponetns.getPreferredSize(...), JFrame raised getScreenSize by call pack(), in another cases windows freeze, flickering during any action(s) with Container, action as resize, add/remove/replace/swich JCompoents.... | |
Re: dispose(), really nothing for JFrame (JDialog, JOptionPane or JWindow)'s lifecycle, that's same as setVisible(false) for JFrame is there System.exit(0); or JFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); these two methods always close all Object, kill the current JVM Instance, that valid only for JFrame, because has implemented method finalize(), another Top-Level Containers (JDialog, JOptionPane, JWindow) miss … | |
Re: @ Taywin, again JTable :-), <withOutFW> updateUI() == that's nothing to do with JTable, please don't updateUI, don't do that, never, forgot that that exist something as updateUI, right now, its road to the hell (on 1st.exceptions you ends with NPE or RepaintManager)<withOutFW> :-) near to repaint reality - SwingUtilities.updateComponentTreeUI(topLayOutContainer); … | |
Re: probably better would be start with Vector (in future is possible to directly sets as dataSource for JTable) each line is [CODE] Vector<Object> myVector = new Vector<Object>(); [/CODE] where wildCard Object speak about variable contents for every of Elements, if Elementscontains same Data Type and structure for example you'd store … | |
Re: > When i type a charactor in jtextfield popup list is show popup but when i press the down arrow its cant select index of popup lists use JComboBox | |
Re: KeyListener isn't designated for listening KeyEvents came from keyboard, for GUI based on Swing JComponents use KeyBinding instead | |
Re: why not, this is simple and possible, you can put there GlassPane, could be layed and possitioning by every Layoutmanagers, notice GlassPane can consume only MouseEvents, | |
| |
Re: don't use two or more JFrames, use CardLayout instead, if you need popup window for input of value use JOptionPane | |
Re: not full text of the message could be useless (maybe) pot here a SSCCE, because in most cases talking about to filling the the data to JTable without definitions about ouw model, no way heavens can you somone to expain me why this a new version of this forum is … | |
Re: no JTable there aren't any limitation, issue about limitiations must be hidden somewhere in your code http://docs.oracle.com/javase/tutorial/uiswing/components/table.html | |
Re: you can use JToolbar, this container is dockable and movable out/in from/to the Container (e.g. JFrame) | |
Re: use [http://stackoverflow.com/a/9430683/714968](DocumentFilter), | |
![]() | Re: you have to search and use hightlighter from [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/textarea.html"]Document[/URL], linked tutorial contains searching and Hightlighter too |
Re: @TIM_M_91 great suggestion +1, but remove code line (from your answer) pic1.setBounds(0,0,903,763); then you'll k*i*l*l used GridLayout | |
Re: please read how the [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html"]JTabl[/URL]e works, there is detailed describtions about how to populating data for JTable | |
Re: 1) learn for [URL="http://www.javapractices.com/topic/TopicAction.do?Id=58"]Naming Conventions[/URL] 2) don't use [URL="http://docs.oracle.com/javase/tutorial/uiswing/layout/none.html"]AbsoluteLayout[/URL] for dynaminc container, I saw a few simialir code, but you have to add [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/componentlistener.html"]ComponentListener[/URL] delayed by [URL="http://docs.oracle.com/javase/tutorial/uiswing/misc/timer.html"]Swing Timer[/URL] , that reduce caused flickering | |
Re: I hoping that you created folder with name Images there are lots of ways: [CODE] button.setIcon(new ImageIcon(this.getClass().getClassLoader().getResource("Images/iconName")));[/CODE] but I still prefered [CODE] Image ViewFxImage = ImageViewFxLoader.getImage(ViewFxDeals.class, "resources/passed.png"); final Icon ViewFxIcon = new ImageIcon(ViewFxImage); myButton.setIcon(null); //remove Icon myButton.setIcon(ViewFxIcon); //add Icon class ImageViewFxLoader { private ImageViewFxLoader() { } public static Image getImage(Class<?> … | |
Re: never, really never use more than one JFrame, for another windows use JDialog | |
Re: well my question where is file with name [B]lebanon ball.jpg[/B] placed, because I miss there - rellative path to the resources in the Java package, - absolute path to the HDD, - URL from to the Http | |
Re: [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/table.html#editrender"]JTable[/URL] knows Date instance, in the linked tutorial is list of types of data, for these types of data aren't required set whatever or modifying ... ![]() | |
Re: 1) basic stuff (valid for part of programing languages) is use nested layout - put 4 JButtons to the JPanel layed by GridLayout, - put this JPanel put to the JFrame myFrame.add(myFirstPanel, BorderLayout.CENTER) - put JLabel to the another JPanel (without declaring for LayourManager is there FlowLayout and JLabel will … | |
Re: I hope that Objects [B]connect[/B] and [B]disconnect[/B] are some of [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/index.html"]JComponents[/URL] with added [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/index.html"]ActionListener[/URL] | |
![]() | Re: maybe [CODE]import javax.swing.*; import java.net.URL; class ShowAnimatedGif { public static void main(String[] args) throws Exception { final URL url = new URL("http://pscode.org/media/starzoom-thumb.gif"); SwingUtilities.invokeLater(new Runnable() { public void run() { //JLabel l = new JLabel(new ImageIcon(url)); //JOptionPane.showMessageDialog(null, l); JButton btn = new JButton(new ImageIcon(url)); JOptionPane.showMessageDialog(null, btn); } }); } }[/CODE] |
Re: [URL="http://stackoverflow.com/questions/9590179/button-counter-java"]crossposted[/URL] | |
Re: I don't see there any lack, no reason for KeyBindings nor for out_dated KeyListener [CODE]import java.awt.*; import java.awt.event.*; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import javax.swing.*; //http://stackoverflow.com/questions/7769885/interrupted-exception-when-closing-file-open-dialogue public class GUI extends JPanel implements ActionListener { static private final String newline = System.getProperty("line.separator"); private static final long serialVersionUID = 1L; private … | |
Re: I think that nothing complicated (@zeroliken answered that by default), just follows turorial about [URL="http://docs.oracle.com/javase/tutorial/2d/images/index.html"]Graphics2D in Swing[/URL] and [URL="http://java.sun.com/products/java-media/2D/samples/suite/"]Java 2D API Sample Programs[/URL] | |
Re: use [URL="http://docs.oracle.com/javase/tutorial/uiswing/layout/card.html"]CardLayout[/URL] for switch betweens views | |
Re: [URL="http://stackoverflow.com/a/9548118/714968"]answered[/URL] | |
Re: [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/text.html"]official Swing tutorial[/URL] [URL="http://www.java2s.com/Code/Java/Swing-JFC/CatalogSwing-JFC.htm"]tons of Examples[/URL] | |
Re: [U]Could anyone post some working example??[/U] why not, tutorials lined by @StephNicolaou contains a few examples, | |
Re: 1) don't create JComboBox inside Databases Connection, create this JComponent before connection, 2) put this data to the Vector, inside ResultSet loops only add myVector.add(rs.getString(2)), 3) test if isn't rs.getString(2) null or empty, because emty JComboBoxes Item doesn't looks like nice.... | |
Re: use [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/formattedtextfield.html"]JFormattedTextField[/URL] with Number formatter, and add [URL="http://docs.oracle.com/javase/tutorial/uiswing/events/documentlistener.html"]DocumentListener[/URL] | |
Re: you are going correct directions, you can listening for ENTER key from JTextField, I think that you have look at [URL="http://docs.oracle.com/javase/tutorial/uiswing/components/filechooser.html"]JFileChooser[/URL] | |
Re: good conception required, followed steps [CODE] . . . content.setPreferredSize(new Dimmension(800,600)) . . content.add(someComponents) . . //last lines would be JFrame mainWin = new JFrame("Main Window"); mainWin.add(content, BorderLayout.CENTER); mainWin.pack(); mainWin.setVisible(true); [/CODE] | |
Re: you have to set NumberFormat for JFormattedTextField, maybe use JSpinner with SpinnerNumberModel [CODE]import java.awt.*; import java.awt.font.TextAttribute; import java.math.*; import java.text.*; import java.util.Map; import javax.swing.*; import javax.swing.JFormattedTextField.*; import javax.swing.event.*; import javax.swing.text.InternationalFormatter; public class DocumentListenerAdapter { public static void main(String args[]) { JFrame frame = new JFrame("AbstractTextField Test"); final JFormattedTextField textField1 = … |
The End.