[Solved] What to do when no base class exists to a certain common interface in Java Swing

You can use the interface and create wrappers for each component type you need. JTextFieldSupportWrapper and JComboboxSupportWrapper both taking an instance of the wrapped object type and and delegating to the addActionListener methods. abstract class ActionListenerSupportWrapper<T extends JComponent> implements ActionListenerSupport { protected final T comp; protected ActionListenerSupportWrapper(T comp) { this.comp = comp; } } // … Read more

[Solved] Action Listeners [closed]

And how would i make it work form a different class file? Import it, if you need to, and then create an instance of it. how to use the action listeners that are attached to the buttons Place the logic that you’d like to be executed within the actionPerformed(ActionEvent e) method of the ActionListener class … Read more

[Solved] displaying image in java, no main class found [closed]

Want to display Image, try something like this: import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; import java.util.logging.Level; import java.util.logging.Logger; import javax.imageio.ImageIO; import javax.swing.*; public class ImagePanel extends JPanel{ private BufferedImage bi; public ImagePanel() { try { bi = ImageIO.read(new File(“Your Image Path”)); } catch (IOException ex) { Logger.getLogger(ImagePanel.class.getName()).log(Level.SEVERE, null, ex); … Read more

[Solved] @Override command is not compatible with ‘Ready to Program Java?’ [closed]

Looking it up, the thing you’re using (“Ready to program Java”) comes with Java 1.4. It’s ancient. So … no, @Override isn’t allowed, and also you can not set the layout directly on the JFrame. See: http://docs.oracle.com/javase/1.4.2/docs/api/javax/swing/JFrame.html#setLayout(java.awt.LayoutManager) By default the layout of this component may not be set, the layout of its contentPane should be … Read more

[Solved] I have 4 days, should I learn QT or Java swing? [closed]

Qt is my vote, too. The examples and info in the links below should get you well on your way to your solution. http://www.youtube.com/watch?v=92biLZST6Vg http://qt-project.org/doc/qt-4.8/phonon-qmusicplayer.html http://qt-project.org/doc/qt-4.8/qfilesystemmodel.html PS, After installing Qt and Qt Creator, it has fantastic documentation and great examples and tutorials easily accessed from the IDE, on the Welcome tab. solved I have 4 … Read more

[Solved] Java graphs not appearing

I have learned that extending JFrame and JPanel is bad But if you need to draw in the GUI, you often need to extend JPanel, and that’s exactly what you should do here. For example the code where you draw with a Graphics object should be inside of the JPanel’s protected void paintComponent(Graphics g) method. … Read more

[Solved] Activating JButton when radio button is enabled? [closed]

Use itemStateChanged event to detect the radio button enabled & do your stuff, @Override public void itemStateChanged(ItemEvent e) { if (e.getStateChange() == ItemEvent.SELECTED) { yourButton.enabled=true; } else if (e.getStateChange() == ItemEvent.DESELECTED) { yourButton.enabled=false; } } 1 solved Activating JButton when radio button is enabled? [closed]

[Solved] Java Timer : I want to fade in and out for my picture but there are some error [closed]

Screen size you cat get without using JFrame’s instance: screen = Toolkit.getDefaultToolkit().getScreenSize(); Also after creating JFrame, add a component listener to update width, height on any resize: JFrame frame = new JFrame(“fade frame”); frame.addComponentListener(new ComponentAdapter() { @Override public void componentResized(ComponentEvent e) { width = image.getWidth(frame); height = image.getHeight(frame); } }); solved Java Timer : I … Read more

[Solved] Displaying a grid as 2 parts in java

Use a JFrame with a BorderLayout. In the BorderLayout.PAGE_START you add a panel with one grid In the BorderLayout.CENTER you add the label In the BorderLayout.PAGE_END you add the second panel. Read the section from the Swing tutorial on How to Use a BorderLayout for more information and working examples. 3 solved Displaying a grid … Read more