swing

How to fix “(java:22494): Gdk-WARNING…”

。_饼干妹妹 提交于 2021-01-28 11:10:02
问题 I am writing a javafx program and I need the panel to update at a constant rate. Right now it is set to update every second. But I got this error, which is usually (but not always) followed by a glitch in the panel when the whole scene becomes distorted (it like mirrors in on itself in a weird choppy x pattern. hard to explain). Full error: (java:22494): Gdk-WARNING **: 18:38:59.118: XSetErrorHandler() called with a GDK error trap pushed. Don't do that. This is the code I have for the timer:

<No main classes found>

房东的猫 提交于 2021-01-28 10:33:40
问题 Followed an oracle tutorial on creating a GUI, the tutorial promised that upon running the application I will have to select the main class, however, Netbeans doesn't find any Main classes? Here is my code: public class GUI extends javax.swing.JFrame { /** * Creates new form GUI */ public GUI() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form

<No main classes found>

亡梦爱人 提交于 2021-01-28 10:33:35
问题 Followed an oracle tutorial on creating a GUI, the tutorial promised that upon running the application I will have to select the main class, however, Netbeans doesn't find any Main classes? Here is my code: public class GUI extends javax.swing.JFrame { /** * Creates new form GUI */ public GUI() { initComponents(); } /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form

Updating GUI from another class

流过昼夜 提交于 2021-01-28 09:01:57
问题 I am building a Snake and Ladders game in Java with Swing using NetBeans as the IDE. The problem is when i write a function which handles some aspects of the GUI (e.g setting icon of a label) OUTSIDE of the main class in another class, the application runs but the changes that have to happen using that code in that function doesn't apply. import javax.swing.JLabel; import javax.swing.JOptionPane; public class Game extends javax.swing.JFrame { protected javax.swing.JLabel diceLabel; private

Changing the color of a JTable cell DYNAMICALLY

独自空忆成欢 提交于 2021-01-28 08:58:20
问题 I would like to know how do i change the background color of a cell in a Table without any response from users. For example, if there is a change in one of my variables due to some unrelated method calls, which I would like for to be reflected in my table. Example, a method changes a value of my array that I used to initialize my table, however the user had no hand in it, like say a elapsed time change in value. So how do I reflect it on my table, or is there any way I could manually call the

Changing the color of a JTable cell DYNAMICALLY

天大地大妈咪最大 提交于 2021-01-28 08:41:38
问题 I would like to know how do i change the background color of a cell in a Table without any response from users. For example, if there is a change in one of my variables due to some unrelated method calls, which I would like for to be reflected in my table. Example, a method changes a value of my array that I used to initialize my table, however the user had no hand in it, like say a elapsed time change in value. So how do I reflect it on my table, or is there any way I could manually call the

DocumentFilter for negative and positive integer

守給你的承諾、 提交于 2021-01-28 08:21:07
问题 I know this is a common question, but I'm trying to create a TextField that only accept int numbers, and it's almost done, here's the code: Create textfield: nome = new JFormattedTextField(); nome.setHorizontalAlignment(SwingConstants.CENTER); nome.setColumns(2); DocumentFilter filtro = new FiltroNumero(); ((AbstractDocument) nome.getDocument()).setDocumentFilter(filtro); panel.add(nome); DocummentFilter: public class FiltroNumero extends DocumentFilter{ public void insertString

how to set jbutton icon for specific time to show when it is clicked and how to disappear the icon when time finished

故事扮演 提交于 2021-01-28 07:16:57
问题 how to code java for set timer to my button for set button icon when i clicked and some time delay for process while my button icon has to show then the icon have to set null for time end. i have tried following way but it is work when i am not to clicked the button private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) { timer = new Timer(5000, new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if(chromeShown) { jButton3.setIcon(new javax.swing

Creating bold cell border lines JTable

有些话、适合烂在心里 提交于 2021-01-28 06:40:56
问题 I'm trying to create a Sudoku game and I am having trouble creating the bold lines to break it into 3 x 3 blocks. My recent attempt was to impose an image on top of the table using JLabel . The problem is the label completely covers the JTable . I goofed around with setting the opacity of the label and the table with no luck. Here are some images to show what I'm aiming for: The current look: The goal: If you could advise me as to a method I can use to create these lines, it would be greatly

JFreeChart AutoRange Doesn't Work on Multiple Series On The Same Plot

人盡茶涼 提交于 2021-01-28 06:34:23
问题 In this code I created 2 TimeSeries and added them to the same plot but the axis.setAutoRange(true) works only for the second series. Is there a way to make the AutoRange work on both of the TimeSeries? import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.ValueAxis; import org.jfree.chart.plot.XYPlot; import org.jfree.data.time.Millisecond; import org.jfree.data.time.TimeSeries; import org.jfree.data.time