Search Results

Search found 1571 results on 63 pages for 'swing'.

Page 28/63 | < Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >

  • Creating JTable Row Header

    - by Chandu
    Hi all, I'm new to JTable.I'm working in Swings using JTable & Toplink(JPA). I have two buttons "add Row", "Del Row" and I have some records displayed from db. when ever "add row" is clicked a new record, row header should be added to JTable with an auto increment number displayed in sequential order to the JTable Row Header. During deletion using "Del row " button the record has to be deleted & not its corresponding header so that next rows got updated to the previous headers & the auto increment number remain unchanged and always be in sequence. please help me on this regard. Thanks in advance, Chandu

    Read the article

  • Netbeans jar file icon problems

    - by Erma
    I finally found how to make an exe project in Netbeans, so a jar file and execute it from the DESKTOP. The only problem I have ocurred is that after I open the jar file and login with my username and password the button icons are not shown, if I put a string it appears but if I put the image it doesn't appear. So,I had to restore this code: JButton btnNew = new JButton(new ImageIcon("new.gif")); JButton btnUpdate = new JButton(new ImageIcon("NotePad.gif")); JButton btnDelete = new JButton(new ImageIcon("delete.gif")); JButton btnSearch = new JButton(new ImageIcon("find.gif")); and put this one: JButton btnNew = new JButton("ADD"); JButton btnUpdate = new JButton("Update"); JButton btnDelete = new JButton("Delete"); JButton btnSearch = new JButton("Search"); It now works but I would like to have the icons please. Any idea?

    Read the article

  • Java - Custom PropertyEditorSupport to display units

    - by I82Much
    All, I'm trying to make the properties of my node have Units associated with the measure. ( I am using the JScience.org implementation of JSR 275) So for instance, public class Robot extends AbstractNode { // in kg float vehicleMass; @Override public Sheet createSheet() { Sheet s = Sheet.createDefault(); Sheet.Set set = s.createPropertiesSet(); try { PropertySupport.Reflection vehicleMassField = new PropertySupport.Reflection(this, float.class, "vehicleMass"); vehicleMassField.setValue("units", SI.KILOGRAMS); vehicleMassField.setName("vehicleMass"); set.put(vehicleMassField); PropertyEditorManager.registerEditor(float.class, UnitInPlaceEditor.class); } catch (NoSuchMethodException ex) { Exceptions.printStackTrace(ex); } s.put(set); return s; } } I want my UnitInPlaceEditor to append the units to the end of the string representation of the number, and when the field is clicked (enters edit mode) for the units to disappear and just the number becomes selected for editing. I can make the units appear, but I cannot get the units to disappear when the field enters editing mode. public class UnitsInplaceEditor extends PropertyEditorSupport implements ExPropertyEditor { private PropertyEnv pe; @Override public String getAsText() { // Append the unit by retrieving the stored value } @Override public void setAsText(String s) { // strip off the unit, parse out the number } public void attachEnv(PropertyEnv pe) { this.pe = pe; } } Here's a screenshot of the display - I like it like this.. but here's the value being edited; note the unit stays there. Basically I want one value (string) to be displayed in the field when the field is NOT being edited, and a different to be displayed when user starts editing the field. Barring that, I'd like to put a constant jlabel for the units (uneditable) to the right of the text field. Anyone know how to do this?

    Read the article

  • Draw a JButton to look like a JLabel (or at least without the button edge?)

    - by Electrons_Ahoy
    I've got a JButton that for various reasons I want to act like a button, but look like a JLabel. It doesn't actually have to be a JLabel under the hood, I just don't want the raised button edge to show up. Is there an easy way to turn off the "button look" for JButtons but keep all the button functionality? I could build some kind of composed subclass hyperbutton that delegated to a jlabel for display purposes, but I'm really hoping there's something along the lines of button.lookLikeAButton(false).

    Read the article

  • Java Backgroundworker: Scope of Widget to be updated unclear

    - by erlord
    Hi all, I am trying to understand the mechanism of org.jdesktop.swingx.BackgroundWorker. Their javadoc presents following example: final JLabel label; class MeaningOfLifeFinder implements BackgroundListener { public void doInBackground(BackgroundEvent evt) { String meaningOfLife = findTheMeaningOfLife(); evt.getWorker().publish(meaningOfLife); } public void process(BackgroundEvent evt) { label.setText("" + evt.getData()); } public void done(BackgroundEvent evt) {} public void started(BackgroundEvent evt) {} } (new MeaningOfLifeFinder()).execute(); Apart from the fact that I doubt the result will ever get published, I wonder how label is passed to the process method, where it is being updated. I thought it's scope is limited to the outside of the BackgroudListener implementation. Quite confused I am ... any answers for me? Thanks in advance

    Read the article

  • JTable.setRowHeight prevents me from adding more rows

    - by Brent Parker
    I'm working on a pretty simple Java app in order to learn more about JTables, TableModels, and custom cell renderers. The table is a simple table with 8 columns only with text in them. When you click on an "add" button, a dialog pops up and lets you enter the data for the columns. Now to my problem. One of the columns (the last one) should allow for multiple lines of text. I'm already putting HTML into the field, but it is not wrapping. I did some research and looked into JTable#setRowHeight(). However, once I use setRowHeight, I can no longer add rows to the table. The data is put into the table model, but it does not show in the table. If I remove the setRowHeight line, then it adds data just fine. Is there another step to adding data to my data model that I'm missing? Thanks a lot!

    Read the article

  • Why is JFormattedTextField evil?

    - by kwutchak
    Hi, In this question Is there any way to accept only numeric values in a JTextField? one of the answers suggested that JFormattedTextField had issues. I've not yet used it, but could somebody please expand (or disagree) on the issues with this class? Thanks...

    Read the article

  • Managing string resources in a Java application - singleton?

    - by Joe Attardi
    I seek a solution to the age-old problem of managing string resources. My current implementation seems to work well, but it depends on using singletons, and I know how often singletons can be maligned. The resource manager class has a singleton instance that handles lookups in the ResourceBundle, and you use it like so: MessageResources mr = MessageResources.getMessageResources(); // returns singleton instance ... JLabel helloLabel = new JLabel(mr.getString("label.hello")); Is this an appropriate use of a singleton? Is there some better, more universally used approach that I'm not aware of? I understand that this is probably a bit subjective, but any feedback I can get would be appreciated. I'd rather find out early on that I'm doing it wrong than later on in the process. Thanks!

    Read the article

  • Java: Altering UI fonts (Nimbus) doesn't work!

    - by ivan_ivanovich_ivanoff
    Hello! I'm referring to this Nimbus reference. I tried to set global Font to be slightly larger: UIManager.put("defaultFont", new Font(Font.SANS_SERIF, 0, 16)); ...works only for the menu but nothing else (buttons, labels). I tried to change labels and buttons fonts with UIManager.put("Button.font", new Font(Font.SANS_SERIF, 0, 16)); UIManager.put("Label.font", new Font(Font.SANS_SERIF, 0, 16)); but the font remains. The only thing that worked for me was deriving a font: someButton.setFont(someButton.getFont().deriveFont(16f)); But this is not an option, since this must be done for each element manually. Note, that deriving a font for UIManager doesn't work either: UIManager.put("Label.font", UIManager.getFont("Label.font").deriveFont(16f)); I tested everything under Linux and Windows: same behavior. I just can't understand how an API can be so messy. If a method is called setFont(..) then I expect it to set the font. If this method fails to set the font in any thinkable circumstances, then it should be deprecated. EDIT: The problem not only applies to Nimbus, but also to the default LAF.

    Read the article

  • How do I properly display all content in a JTabbedPane?

    - by maleki
    I am nesting a JPanel inside a JTabbedPane. I am having trouble displaying all the content inside of the JTabbedPane. The outside borders of the internal content get chopped off. I am currently not using a Layout Manager for my JTabbedPane or dummy Panel because it stretches my content automatically. How do I add a JPanel inside the JTabbedPane so that I can have an even border around all the content.My attempts to create a dummy panel and setting a border for the inner panel using BorderFactory haven't worked. Is there a convention that I need to know to do this correctly? JTabbedPane tabPane = new JTabbedPane(); GridPane tab1 = new GridPane(); GridPane tab2 = new GridPane(); tabPane.add("My Pieces",tab1); tabPane.add("Opponent Pieces",tab2); public class GridPane extends JPanel { public GridPane() { this.setPreferredSize(new Dimension(400,160)); this.setLayout(new GridLayout(4,10)); this.setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT); for (int i = 0; i < 4; i++) { for (int j = 0; j < 10; j++) { boardSquares[i][j] = new JPanel(); boardSquaresArr.add(boardSquares[i][j]); this.add(boardSquares[i][j]); } } } }

    Read the article

  • Can Box Layout accept size of included elements?

    - by Roman
    I used myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS)); to order panels vertically (one under another one). But myPanel defined in the shown way change the included panel. In more details, it tries to set the same hight and width for the included panels. Can it be changed? Can BoxLayout adopt size of the included elements?

    Read the article

  • Drawing star shapes with variable parameters

    - by owca
    Hi. I have task to write program allowing users to draw stars, which can differ in size and amount of arms. When I was dealing with basic stars I was doing it with GeneralPath and tables of points : int xPoints[] = { 55, 67, 109, 73, 83, 55, 27, 37, 1, 43 }; int yPoints[] = { 0, 36, 36, 54, 96, 72, 96, 54, 36, 36 }; Graphics2D g2d = ( Graphics2D ) g; GeneralPath star = new GeneralPath(); star.moveTo( xPoints[ 0 ], yPoints[ 0 ] ); for ( int k = 1; k < xPoints.length; k++ ) star.lineTo( xPoints[ k ], yPoints[ k ] ); star.closePath(); g2d.fill( star ); What method should I choose for drawing stars with variable inner and outer radius, as well as different amount of arms ? This is what I should obtain :

    Read the article

  • Adding a JLabel to JLayeredPane from event listener not dragging.

    - by Cody
    Ok, So for some reason When I add components to a JLayeredPane in its constructor: JLabel label = new JLabel(); label.setSize(100,100); label.setText("This works"); add(label); It works perfectly fine, but If a add it later in the JLayeredPane's parent EDT it doesnt let me move the objects around but they let me see the objects. Adding from EDT: JLabel label = new JLabel(); label.setToolTipText(url.getHost()); label.setIcon(icon); label.setBorder(new LineBorder(null)); label.setSize(icon.getIconWidth(), icon.getIconHeight()); dressFrame.layeredPane.add(label, JLayeredPane.DRAG_LAYER); Dragging method: Component c = findComponentAt(e.getX(), e.getY()); if (c instanceof JLayeredPane) { pieceSelected = false; return; } Point parentLocation = c.getLocation(); xAdjustment = parentLocation.x - e.getX(); yAdjustment = parentLocation.y - e.getY(); movingPiece = c; movingPiece.setLocation(e.getX() + xAdjustment, e.getY() + yAdjustment); pieceSelected = true;

    Read the article

  • JOptionPane to appear on selected JCheckBox

    - by Venno
    Hi all I am having some difficulties with adding a joptionpane in JcheckBox listener public void itemStateChanged(ItemEvent evt) { if(evt.getStateChange() == ItemEvent.SELECTED){ ///some code JOptionPane.showMessageDialog(null, "Message", "Alert", JOptionPane.INFORMATION_MESSAGE); } } so it works fine,but the problem is that the JCheckBox gets selected and immediately deselected how can I manage to fix this ? Cheers

    Read the article

  • Resizing JPopupMenu and avoiding a "flicker" issue

    - by Avrom
    Hi, I am trying to implement a search results popup list similar to the style found here: http://www.inquisitorx.com/ (I'm not trying to implement a Google search, I'm just using this as a rough example of the style I'm working on.) In any event, I am implementing this by using a JList contained within a JPopupMenu which is popped up underneath a JTextField. When a user enters search terms, the list changes to reflect different matching results. I then call pack on the JPopupMenu to resize it. This works, however, it creates a slight flicker effect since it is actually hiding the popup and showing a popup. (See the private method getPopup in JPopupMenu where it explicitly does this.) Is there any way to just get it to just resize itself (aside from using a JWindow)?

    Read the article

  • Changing content of HTMLDocument displayed in a JTextPane

    - by kayahr
    I'm displaying some tables as HTML code (rendered by a Freemarker template) with a JTextPane. I also have some HTML links in this HTML output which can be used to interact with the values of the table (For example "Delete a row" and stuff like this). Currently I always recreate the whole HTML output on each change and replace the whole document in the JTextPane with the new one. This is getting really slow and the JTextPane always changes the scroll position when I do this. Is it possible to change only parts of the HTML code during runtime without replacing the whole document? In a real browser I would use the DOM and do something like document.getElementById("price").innerHTML = "$123.44". Is something like that possible with the HTMLDocument in a JTextPane?

    Read the article

  • Java2d: Set gradient for a lines

    - by Algorist
    Hi, I am having multiple points in a plane and some hundreds of lines pass through those points. Some points can have more lines passing through them than other points. I want to show some kind of more gradient or brightness associated with lines crowded together. Is this possible to do in java2d. Please refer to this : http://ft.ornl.gov/doku/_media/ft/projects/paraxis.jpg Thank you.

    Read the article

  • Button in a JMenuBar

    - by Kurru
    Hi I was trying to make a JMenu behave like a JButton but I'm having some problems and hopefully someone here can help! I've added a MenuListener to the JMenu item with this but I cant get the popup menu/focus to leave to enable me to properly click the JMenu repeated times to trigger this function and i was hoping someone could tell me what i'm doing wrong. Thanks. public void menuSelected(MenuEvent e) { ... // do stuff here code JMenu source = (JMenu)e.getSource(); source.setSelected(false); source.setPopupMenuVisible(false); }

    Read the article

  • Java MouseEvents not working

    - by billynomates
    This may be a stupid question, but I have to ask! I have the following code snippets that are supposed to run their corresponding methods when the user interacts with objects. For some reason, "foo" is never printed, but "bar" is. myJSpinner1.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseEntered(java.awt.event.MouseEvent evt() { System.out.println("foo"); //"foo" is not printed } }); myJSpinner2.addChangeListener(new java.awt.event.ChangeListener() { public void stateChanged(java.awt.event.ChangeEvent evt() { System.out.println("bar"); //"bar" is printed } }); I get no exceptions or stack trace. What am I missing in the MouseListener one? Thanks in advance.

    Read the article

  • How to retrieve data from textarea or text field and store in a text file with the same data format,

    - by Sunil Kumar Sahoo
    Hi I have created a text field in java and i am able to get the data from text field and store in a .txt file. But My problem is that let the my data in textfield is in bold and italic format and the font colour is red. Now I want to store the data exactly in the same format in .txt file. I donot know how to write code for that. Anyone please help me to solve this type of problem Thanks Sunil Kumar Sahoo

    Read the article

  • Disabling JComboBox and retaining original item list

    - by n002213f
    My action listener on a JComboBox invokes a thread. I would like the component to be disabled until the thread completes. I have tried calling seEnabled(false) when the thread start and setEnabled(true) when it completes. Unfortunately setEnabled(false) clears the combo box list as well. Is there a way of disabling the component but retain the original list?

    Read the article

  • Can I fix the width of JRadioButton?

    - by Roman
    I have sever JPanels which have to be ordered vertically. For that I want to fix the width of the JPanels. Because if they are too short in comparison with the windows width, they will go horizontally (one after another) and I do not want it. At the moment the width of the JPanel is not constant because the width of the JRadioButton (included into JPabel) is not constant. How can I make the width of the JRadioButton constant? At the moment it is not constant because of the label (which can be different).

    Read the article

  • How do I move a Java JFrame partially off my Linux desktop?

    - by Erick Robertson
    I'm writing a Java application with movable frames, and I've come across a quirk in Linux. I'm running GNOME 2.16.0 under CentOS. When I use JFrame.setBounds to set the bounds to any location that's half off the screen, it actually sets the location of the frame to be as close as possible to the bounds specified while still staying completely on the screen. This is confusing because other non-Java windows can move half off the screen. How do I tell Java to tell GNOME to actually put the frame where I specify, even if that's half off the screen?

    Read the article

< Previous Page | 24 25 26 27 28 29 30 31 32 33 34 35  | Next Page >