awt

vertical scroll bar in JTable

此生再无相见时 提交于 2019-12-25 03:27:32
问题 I have one JTable with vertical scroll bar on it,when i added new row the scroll bar will move to the new row. The problem is scrollbar is visible in the frame but i can't scroll it. this is way i created jtable table = new javax.swing.JTable(){ public boolean isCellEditable(int rowIndex, int colIndex) { return false; //Disallow the editing of any cell } }; model = (DefaultTableModel) table.getModel(); table.setRowHeight(20); selectionModel = table.getSelectionModel(); selectionModel

Error when creating JFrame from JFrame

*爱你&永不变心* 提交于 2019-12-25 02:49:42
问题 I have an application that is works fine and the JFrame for it is launched in the constructor of a GameInitializer class which takes in some config parameters. I have tried to create a GUI in which allows the user to specify these config parameters and then click submit. When the user clicks submit a new GameInitializer object is created. The error I am getting is: Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread at java.awt

Repaint doesn't work and the value of my private fields won't change?

不想你离开。 提交于 2019-12-25 02:31:08
问题 I am making a graphical interface in Netbeans where you can put a series of numbers (example: 7 8 5 4 10 13) in the textfield "punten" and when you press the button "ververs" a graphical linechart of all the numbers should appear (in my panel). I made a class "Gui" that extends JFrame with the Textfield, the button and a panel in it. I also made a class "Grafiek" that extends JPanel and that is linked with the panel in my "Gui". The problems that I experience are: the repaint(); command won't

hasAlpha vs getAlphaRaster

喜你入骨 提交于 2019-12-25 02:18:14
问题 In Java, is it expected to be able to have a BufferedImage such that getColorModel().hasAlpha() will return true, but getAlphaRaster() will return null? I ask because there's a library I'm using (PDFBox specifically, in the PDJpeg class) that breaks on such an image. In this particular case I'm creating the image very simply using: BufferedImage bi = ImageIO.read(new FileInputStream("/Users/dan/Downloads/test.png")); I've attached the particular image that's failing for me below this question

JButtons re-enable themselves after being disabled

人盡茶涼 提交于 2019-12-25 01:18:52
问题 I have an array of JButtons which form a keypad interface. After six numbers are entered I want to disable the keypad so that no further numbers can be entered by the user. I have written the code and the buttons do disable until the mouse hovers above any of them, then the buttons seem to re-enable themselves and run actionEvents added to them. The full code is available here. Possible things that I think are wrong. There is some sort of MouseListener which is ignoring when I set button

setBackground doesn't work on applet background

青春壹個敷衍的年華 提交于 2019-12-24 23:23:23
问题 I don't believe this is a duplicate because the other questions were in regards to JButtons and JPanels. I was wondering why the following in java isn't working like one would assume: import javax.swing.JApplet; import java.awt.*; public class Example extends JApplet { public void paint(Graphics page) { setBackground (Color.cyan); } } Basically when I run the applet the background won't change, regardless of color. I realize there are other options to get the same effect, but I am using

Java AWT-EventQueue-0 Error

别等时光非礼了梦想. 提交于 2019-12-24 21:44:48
问题 can someone help me to debug this, Edit 1: the error is not in the code below * Error occurs within the code below: * if (e.getSource().equals(btnRefresh)) { PeerList.removeAllElements(); FileList.removeAllElements(); try { AllPeers=(List <String>)Services.getPeers(); } catch (RemoteException e1) { // TODO Auto-generated catch block } for (String CurrentPeer:AllPeers) { System.out.println(CurrentPeer); PeerList.addElement(CurrentPeer); } } Edit 1: Error is here lstPeerList

Transparent AWT component, possible?

折月煮酒 提交于 2019-12-24 21:13:39
问题 I'm in the need of a translucent AWT component/container to be placed on top of other components to receive the mouse events. The problem here is to create a translucent component. My investigation so far showed that Swing has the possiblity to do setOpaque(false) on e.g. a JPanel. Is there something similiar for AWT? The idea is to make a ScrollPane scrollable by simply clicking somewhere and moving the mouse around. Thats why I need a transparent component to place it above all other

Why is my simple JFrame displaying weird?

为君一笑 提交于 2019-12-24 17:11:19
问题 I am a newbie at Java Swing/AWT and I have this code following working for a simple PopUp dialog which closes on any of the JButtons beind clicked, but displays real wonky. Does anybody have suggestions on what and how to fix? import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax

Gap between JPanels in GridLayout

▼魔方 西西 提交于 2019-12-24 16:06:18
问题 The code below produces nine individual JPanels in which are 9 buttons. The nine JPanels are arranged onto a base JPanel using GridLayout. This base JPanel is then placed onto the ContentPane using Border Layout. I'm using borders for the JButtons and each individual JPanel to clearly define their separation. The JButtons inside each JPanel look fine but there is a gap between the JPanels which is causing the appearance of a double line which is bugging the hell out of me. I've tried adding