I try to limit the number of allowable characters to 5 by using
try {
jFormattedTextField2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("*****")));
} catch (java.text.ParseException ex) {
ex.printStackTrace();
}
However, when I only enter 1 character, t...
Hello guys, i have a timer that counts the spent time and other calculations, but i need when i click on pause button the timer to pause, and then resume. How do i pause it?
...
I want to add Scrollpane to JPanel which is in turn called by another jpanel?
public class test {
JFrame jframe;
JPanel jpanel;
JScrollPane js= null;
public void createFrame()
{
jframe=new JFrame("Thick client Wallboard");
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
jframe.s...
I am having some issues with my code, I cant see whats wrong with the logic, but here it is. I want them to have the radio button to choose either or, and when one is selected(radio button) the text area isn't available and vise versa. Here is the segment of the code. When I go back and forth on the radio buttons, both become not selecta...
Hello:
This is the first time for me to post here, so sorry if I made some mistake.
I am working on a JTable which column data have to verify some parameters, for example:
Column 3 values > 30
Column 4 values > 10
Column 5 values > 4
Also the first 2 columns are filled "automatically", putting 0s in the rest of the columns.
If tha...
Hi,
I been trying to do "the question title". Here is my current code:
Main.java
import java.awt.*;
import javax.swing.*;
public class Main {
public static void main(String[] args) {
JFrame f= new JFrame ("My Frame");
f.setDefaultCloseOperation (JFrame .EXIT_ON_CLOSE);
JTabbedPane tp = new JTabbedPane();
User user = new User();
tp...
I know that by using this method, the runnable parameter is submitted to the system EventQueue.
But should all GUI updates be done this using this method? I mean, if i want to say, change a text of JButton, should i use something like this:
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
jButton1.setT...
HI
I am trying to play an audio file in my Java application:
here is the code:
public static void music()
{
AudioPlayer MGP = AudioPlayer.player;
AudioStream BGM;
AudioData MD;
ContinuousAudioDataStream loop = null;
try
{
BGM = new AudioStream(new FileInputStream("\\BattleShip\\battle.w...
I was having problems getting a null layout manager working, and I found this great page with things to remember when using a null layout manager. One of them was my issue, and I quickly moved on.
I'm now having similar problems with another panel using a null layout manager. However, I cannot find this page anywhere! So what are the...
I'm developing the Java Swing application. I'm quite new to Java, so got some questions. I have a modal window with some set of controls (text fields, buttons etc).
I want to handle click on the button in the parent window. I think the most efficient and accurate way is first to handle it in modal window, then raise some another event ...
Hi,
I have question about Drag And Drop in Java.
I was able to to implement drag and drop files from Windows Explorer to Swing application.
Now I need to oposite direction.
I have JTable which contains Column with object type File. I just need to detect which file (files) are dragged and where in Windows Explorer.
Thanks in advance.
...
I would like to use factory classes and methods to generate GUI components, but I don't know how and in which class the various listeners should be declared and added to the components.
If I have a simple factory class such as that listed below should I add an ActionListener to the button before it is returned to the calling class. If t...
Hello,
I am working on a form that provides "real-time" validation to the user and I have one problem.
The goal is to put a label near the field (in this case a JSpinner), to show the user if the data is accepted or denied, in the same way that javascript-based validators do.
The problem is that for archieving this, I need to set the ...
I'm looking for the following behaviour in a JPanel Layout (Swing): basically it would arrange the components in a Vertical way, one bellow each other. When the components can't fit vertically in the container, it should add the next one in a new row. This would continue dinamically, adding new rows as needed.
It would look likes this, ...
I want to know whether we can find a tag in JEditorPane in java swing where my cursor is pointing..
For ex.
following is the text content in my editor pane..
<html>
<head>
<body>
<div><!--Cursor inside the div tag--></div>
</body>
</html>
for instance suppose this is the text inside my editor pane. and my cursor is inside the tag. no...
I want to make "Open"(pic 1) and "Save" (pic 2) anyone know how to do that in java? Thx b4
Pic 1
Pic 2
...
I have 2 JTabbedPane. I am unable to refresh the data. PLease help, here is my code:
pane1:
//.. some codes...
// This is the ButtonListener
private class ButtonListener implements ActionListener
{
public void actionPerformed (ActionEvent event)
{
userInput = tf.getText(); // tf is JTextField
//System.out.println("t...
How do I set the JTable column and row color?
...
I am creating a battleship game with 4 classes using sockets. A computer, player message and a menu class. To start the game I run the computer class which is the server then I run the menu class which bring up the menu. Through the menu I click start to create a new player object which looks like this
public static void runPlayer()
{
...
Why is it needed to put GUI update code in SwingUtilities.invokeLater()?
Why it cant be internally taken care by Swing itself? Why do caller has to care about how swing handles UI updates?
...