Why is my Java application blurry?
This is what I want to do
This is what appears when the Java application is launched. (see the text on my button and the text in the textbox is java)
I am using Eclipse Luna on Windows 7.
PS: My shortcuts are blurry in Java didn't help
public class DownloadManager {
private JFrame frame;
private JTable table;
private JTextField txtUrl;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
DownloadManager window = new DownloadManager();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public DownloadManager() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 752, 514);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
table = new JTable();
table.setBounds(47, 190, 629, 250);
frame.getContentPane().add(table);
txtUrl = new JTextField();
txtUrl.setBounds(47, 84, 391, 34);
frame.getContentPane().add(txtUrl);
txtUrl.setColumns(10);
JButton btnDownload = new JButton("Download");
btnDownload.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
btnDownload.setBounds(534, 78, 99, 47);
frame.getContentPane().add(btnDownload);
}
}
EDIT:
The solution suggested In JDK 1.8, similar to JDK 1.8, displays wobble distortion i.e. Changing the NVIDIA GeForce 630M power management settings for maximum performance did not help.
+3
source to share
1 answer
Use a layout manager to reduce the artifacts shown above. Below is an example of nests one JPanel
inside the other.
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
public class DownloadManager {
private JFrame frame;
private JTable table;
private JTextField txtUrl;
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
DownloadManager window = new DownloadManager();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public DownloadManager() {
initialize();
}
private void initialize() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
table = new JTable() {
@Override
public Dimension getPreferredScrollableViewportSize() {
return new Dimension(320, 240);
}
};
frame.add(new JScrollPane(table), BorderLayout.CENTER);
txtUrl = new JTextField(12);
txtUrl.setColumns(10);
JButton btnDownload = new JButton("Download");
btnDownload.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
}
});
JPanel panel = new JPanel();
panel.add(txtUrl);
panel.add(btnDownload);
frame.add(panel, BorderLayout.NORTH);
frame.pack();
}
}
+4
source to share