Here is my code:
import javax.swing.*;
import java.awt.*;
public class PanelModel {
public static void main(String[] args) {
JFrame frame = new JFrame("Colored Trails");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(new BoxLayout(mainPanel...
Hi,
I need to know if a JPanel`s bacground can be set to Transparent?
My frame is has two Jpanels
Image Panel and Feature Panel, Feature Panel is overlapping Image Panel, the Image Panel is working as a background and it is loading image from a remote Url, now I want to draw shaps on Feature Panel , but now Image Panel cannot be seen d...
Here is the code:
import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
public class TestGrid {
public static void main(String[] args) {
JFrame frame = new JFrame("Colored Trails");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel mainPanel = new JPanel();
mainPanel.setLayou...
At the moment I have the following code which works fine.
label = new JLabel(panelLabel,SwingConstants.CENTER);
outputPanel.add(label,BorderLayout.CENTER);
I get the text in the center of the panel (in terms of the left-right position as well as in terms of the top-bottom).
Now I want to set the position to the bottom (and center in...
I'm working on a pretty simple Java app in order to learn more about JTables, TableModels, and custom cell renderers. The table is a simple table with 8 columns only with text in them. When you click on an "add" button, a dialog pops up and lets you enter the data for the columns.
Now to my problem. One of the columns (the last one) ...
I have an ImageIcon which is an image of a router. I added this ImageIcon to a label. But labels are either rectangles or squares. I want such a component that takes the shape of the ImageIcon when added to it. Does such a component exist? Is there any other way of doing it?
...
I am making a text editor using Java swing. I am using JTextArea for the same. I want to know how I can use Undo and Redo functionality in JTextArea as I am not able to use it.
...
I need a way to bind UI indicators to rapidly-changing values.
I have a class NumberCruncher which does a bunch of heavy processing in a critical non-UI thread, thousands of iterations of a loop per second, and some number of those result in changes to a set of parameters I care about. (think of them as a key-value store)
I want to dis...
What's the best way to set up a table in a JScrollPane such that the first column is always on the screen in the same position regardless of horizontal scrolling and overlaps columns that pass underneath?
When the scrollbar is at the farthest left, the columns look normal, but as the user scrolls to the right, the secondary columns (2...
Hi,
I have a question about the 'Event Descriptor Thread'. I have a Main class that is also a JFrame. It initialises the rest of the components in the code, some of them do not involve Swing and some of them do. Is it enough to simply initialise the Main class using the EDT like this?...
public static void main(String[] args) {
jav...
I seek a solution to the age-old problem of managing string resources. My current implementation seems to work well, but it depends on using singletons, and I know how often singletons can be maligned.
The resource manager class has a singleton instance that handles lookups in the ResourceBundle, and you use it like so:
MessageResource...
Hi all,
I'm new to JTable.I'm working in Swings using JTable & Toplink(JPA). I have two buttons "add Row", "Del Row" and I have some records displayed from db. when ever "add row" is clicked a new record, row header should be added to JTable with an auto increment number displayed in sequential order to the JTable Row Header.
During de...
How do I set a background image to a JTextPane - some sort of a watermark.
I tried this option - creating a child class of JTextPane and use the paint method to draw the image.
But then the text is displayed "below" the image than above.
Is there any "standard" or "well known" way to do this?
(BTW, I tried (something silly?) making t...
This may be a stupid question, but I have to ask!
I have the following code snippets that are supposed to run their corresponding methods when the user interacts with objects.
For some reason, "foo" is never printed, but "bar" is.
myJSpinner1.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseEntered(java.awt.eve...
How can I make the comboBox available when the checkBox was uncheck (vice versa)
Why the comboBox is still disable after I unChecked the checkBox?
choice [] = {"A","B","C"};
JComboBox a = new JComboBox(choice);
JCheckBox chk = new JCheckBox("choice");
...
a.addActionListener(this);
chk.addActionListener(this);
...
public void actio...
How do I change the icon of a frame when loading the applet from JNLP?
I'm also using substance to change the appearance of the applet, and in a stand alone application the title changes with the skin I choose, but if I run the applet from webstart it always puts the default title bar (windows look). How can I change that?
Thanks.
...
Is there way to use more than 1 layout manager in Java. Right now I'm using a gridLayout to implement a chess board but beneath it I would like to put some other stuff but not in a gridLayout. Maybe a FlowLayout or some other layout. How would I go about doing this?
Thanks!
...
I want to give XP Look and Feel to my Java Desktop Appliction, regardless of the platform it will run.
I came to know that since JDK 1.4, Sun Microsystems has officially released a look and feel for XP - com.sun.java.swing.plaf.windows.WindowsLookAndFeel
I am using Java 1.6 but when I didn't find any package named windows in javax.swin...
I want to remove a line connecting two labels. Actually, I want to remove a label after which the line connecting the label is also removed. How can I do it?
...
I am working on a school assignment that requires me to be able to pick up a tile, drag it to a location, then drop it there. I was able to get this working using TransferHandler and a bunch of stuff from the dnd package, but this is not an acceptable way to perform this action for this assignment according to the professor. So, I am t...