I am attempting to load classes dynamically into a component. I am using a file chooser to select the .JAR file that will be loaded and then a option pane to get the name of the class.
I have trawled the internet looking for how to convert a java file to a URL in order to load it in URLClassLoader and I have come up with:
File myFile =...
How to get the line number or cell number by double-clicking the mouse in the table.
...
Hi,
I am working on an app which when used for loading a file and drawing the contained components, may result into painting of overlapping components. For example, consider a big rectangle box containing text line inside it.
Now because these components are overlapping, it is difficult for the user to select the inner text box in this ...
Is it possible to start JProgressBar from inbetween.I know this is wierd but I need to show the update between 20-80% and the progress bar should be invisible between 0-20% and 80-100% and the number 20 and 80 are run time variables.
...
do you know the best way to erase whole JT ?
...
Hello,
The situation is like this:
Upon clicking on a menu item, some components are added to a JScrollPane, the components are resized, then setVisible method of JScrollPane is called. Resizing of components are out of my control. (TextAreas getting resized according to their contents. Caret updates are disabled.)
I want to scroll th...
Hi.
It seems that when I instantiate 12 Swing Worker threads, the first six starts to complete its task, it finishes AND then the last six starts and finishes. The behavior I'm looking for is all 12 threads start working at the same time & finish at the same time.
I have the following:
for (int i = 0; i < 12; i++ )
{
myTask m...
I'm trying to translate between view and viewport coordinates.
But the JViewport/JScrollpane doesn't seem to work as documented. JViewport.toViewCoordinates()
thinks the view is always at the top left of the component, even though that's clearly not the case.
String text = "blahblahblah\nblahblah\nblah";
JFrame frame = new JFrame("titl...
given the following code:
public class MainFrame extends JFrame{
public MainFrame() throws HeadlessException {
super();
this.setSize(500, 400);
this.setVisible(true);
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
JButton myButton = new JButton("Test");
this.add(myButton);
this.pack();
}
public ...
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class File
{
private JFrame frame1;
private JPanel panel1;
private JPanel panel2;
private JLabel labelWeight;
private JLabel labelHeight;
File()
{
frame1 = new JFrame();
panel1 = new JPanel();
panel2 = new JPanel();
labelWeight ...
Hi everyone,
I'm trying to learn swing and I was thinking you guys may know a really good swing based open source application that I could study and inspire from. I'm looking for something that has a real world use, not just some concepts explained (like examples in most books and tutorials).
Thank you!
...
Hi,
I am trying to implement a GUI in java but I am beginner in swing. I want to make something clear. I read that in order to keep the GUI responsive I should use the SwingWorker class to do the task in a separate thread. Ok so far.
No I have a model with around 15 methods that are remote methods. Each method returns different object ty...
For some reason, I cannot this working. It should be simple really.
I've having a JFrame with a BorderLayout, which contains a JPanel (SOUTH) and a (CENTER) JPanel (itemPanel).
itemPanel should be wrapped in a scrollpane. Its width = x, and all of its children shares its length, so it basically works like a table with only 1 column.
...
Hi Coders,
I am a complete newbie when it comes to the use of factory classes and methods, patterns, etc - in fact I first learned of them here on Stackoverflow when browsing Java related questions :-)
In response to a previous question of mine it was suggested that I look into the use of the Builder Pattern in the development of my GU...
I am trying to create a panel with changing pictures.
This is my panel:
public class AdvertisementPanel extends JPanel {
private BufferedImage image;
private ArrayList<String> pictures;
private int index = 0;
public AdvertisementPanel(String... pics) {
pictures = new ArrayList<String>(Arrays.asList(pics));
Executors.newSingleThreadSch...
The Context
At the moment, I have a JTextArea that has been created like so:
JTextArea descArea = new JTextArea();
descArea.setFont(style.getFont());
descArea.setLineWrap(true);
descArea.setName("descArea");
descArea.setToolTipText(resourceMap.getString("descArea.toolTipText"));
descArea.setText(model.getName());
JScrollPane descPane =...
I am trying to display numbers in the steps of 5,10,15,20 in a Jtable.
In case of 5 the column names will be 0,5,10,15...
In case of 10 the column names will be 0,10,20,30...
In case of 15 the column names will be 0,15,30,45...
In case of 20 the column names will be 0,20,40,60...
Right now I am able to display 5 and what I need is ...
i have used
enter code here
textArea1=new TextArea();
String s=textArea1.getSelectedText();
g.drawRect(s.length(),s.length(),s.length(),s.length());
but it is not getting.please help me.
...
how can i add components dynamically in a jpanel?
I am having add button when i click the button the components should be added to the JPanel.
my question is that adding a textfield and button to jpanel when i click on the add button the user can click on the add button any number of times according to that i have to add them to the jpa...
Hi folks,
I was wondering if there is some sort of magic I can use to get around an IllegalStateException and allow a JTextField to "attempt to mutate in notification", or in other words to set its own text if its listener is triggered.
For your information, I am trying to program an auto-complete function which returns the most likel...