Search Results

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

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

  • How to represent double values as circles in a 2d matrix in java

    - by marco
    Hello, so I want to write a matrix explorer which enables me to reorder rows and columns of a matrix. For this porpouse I used the Jtable class. Now the problem that I have is that it is very difficult to reorder a matrix by looking at double values, so I would like to print the matrix not with the double values but with circles in which the radius of the circle represents the value. So that I can tell the difference between big values and small values quicker. Anybody has any idea how I can turn this double values into filled circles with JTable or any table class for that matter?

    Read the article

  • How to get a handle to all JCheckBox objects in order to loop?

    - by EmmyS
    I'm very new to Java and am having some issues looping through JCheckBoxes on a UI. The idea is that I have a bunch of checkboxes (not in a group because more than one can be selected.) When I click a JButton, I want to build a string containing the text from each selected checkbox. The issue I'm having is that our instructor told us that the checkboxes need to be created via a method, which means (see code below) that there isn't a discrete instance name for each checkbox. If there were, I could say something like if(checkBox1.isSelected()) { myString.append(checkBox.getText()); } That would repeat for checkBox2, checkBox3, and so on. But the method provided to us for adding checkboxes to a panel looks like this: public class CheckBoxPanel extends JPanel { private static final long serialVersionUID = 1L; public CheckBoxPanel(String title, String... options) { setBorder(BorderFactory.createTitledBorder(BorderFactory .createEtchedBorder(), title)); setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); // make one checkbox for each option for (String option : options) { JCheckBox b = new JCheckBox(option); b.setActionCommand(option); add(b); } } } This is called like this: toppingPanel = new CheckBoxPanel("Each Topping $1.50", "Tomato", "Green Pepper", "Black Olives", "Mushrooms", "Extra Cheese", "Pepperoni", "Sausage"); So I now have a panel that contains a border with the title "Each Topping $1.50", and 7 visible checkboxes. What I need to do is get a list of all the selected toppings. We are not supposed to use an ActionListener for each checkbox, but rather get the list when a button is clicked. I'm feeling really clueless here, but I just can't figure out how to get the isSelected property of the checkboxes when the individual checkboxes don't have instance names. Ideally I'd like to somehow add all the checkboxes to an array and loop through the array in the button's action listener to determine which ones are checked, but if I have to check each one individually I will. I just can't figure out how to refer to an individual checkbox when they've been created dynamically.

    Read the article

  • How can i underline a text in JDK5, NOT JDK6

    - by Serkan Kasapbasi
    when i search internet i have found a way to underline font like this, Font f=jLabel1.getFont(); Map<TextAttribute,Object> map = new Hashtable<TextAttribute,Object>(); map.put(TextAttribute.UNDERLINE,TextAttribute.UNDERLINE_ON); f=f.deriveFont(map); jLabel1.setFont(f); it works well on jdk6, however it doesnt work on jdk5, and it doesnt warn about anything. first, how can i get same effect on jdk5? second, why is there a TextAttribute.UNDERLINE constant, if it doesnt work?

    Read the article

  • How to LIMIT the text box length?

    - by sam
    I am working on eclipse java using swt jface with rcp. How can i limit the characters in my text box. Like if i want only 4 characters in my text box then what should i do? and what if i want alphanumeric combination . again in certain limit?

    Read the article

  • how to disable minimize button in frame?

    - by vybhav
    can i disable minimize button in frame?how?(i hav already tried setUndecorated() and setResizable().both didnt work). i m trying to add imags to a panel at a random location which i m able to do) bt wen frame is minimized by clicking at the minimize button (not wen frame minimizes by clicking at the background window) images assemble at the top in a row. help guys..... thanks

    Read the article

  • Simple popup java form with at least two fields

    - by nunos
    This is, I suppose, a very simple question for any Java programmer. My question is as simple as this: When the user clicks a button, I want to show a popup form that should have at least two JTextFields and two JLabels, so using JOptionPane.showInputDialog is not a possibility. Thanks.

    Read the article

  • Unable to change background colour for JOptionPane

    - by Sunil Kumar Sahoo
    Hi I have created sample progeam which will give same look and feel of a confirm dialog and set the background colour as red. But I donot know what is the problem that my background colour of option is displayed as the default colour but not red. also i need same look and feel of confirm dialog across all platforms. Here is the code that I have written. please help me to solve the issue public class JOptionPaneBackground { public static void main(String[] args) throws Exception { // UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName()); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIDefaults uiDefaults = UIManager.getLookAndFeelDefaults(); List<Object> keys = new ArrayList<Object>(uiDefaults.keySet()); Collections.sort(keys, new Comparator<Object>() { public int compare(Object o1, Object o2) { return (o1.toString()).compareTo(o2.toString()); } }); for (Object key : keys) { System.out.println(String.format("%-40s = %s", key, uiDefaults.get(key))); } UIManager.put("OptionPane.background", Color.red); UIManager.put("Panel.background", Color.red); JOptionPane.showConfirmDialog(null, "Hello World!"); } }

    Read the article

  • Mix of Arabic and English causes problems in JTextArea (Java)

    - by Dan
    I have a JTextArea which displays HTML of an Arabic web page. So it's essentially a mix of English and Arabic. In the JTextArea, with columns set to 30, certain text just disappears instead of wrapping properly. The weird thing is that if I copy the invisible text and paste it into Notepad, then I can see it in Notepad. If I change the number of columns to 40, everything displays fine. Any ideas?

    Read the article

  • JToolbar is hidden by JMenu

    - by pierre
    I'm using Netbeans to add a JToolbar to my window which also has a JMenuBar. Here is the design-time look: .. but during run-time I get this: With the toolbar seemingly partially hidden under the menu names. This is on the Mac, btw. Is there something stupid I've forgotten to do or some layout trick I should be using? EDIT: I'll add that the area below the toolbar is a SplitContainer.

    Read the article

  • How to click through JGlassPane With MouseListener to UI behind it

    - by Epicmaster
    I have a JFrame and a bunch of JComponents on top of the JFrame. I need to make use of the JGlassPane and I used this implementation to set it up. JPanel glass = new JPanel(); frame.setGlassPane(glass); glass.setVisible(true); glass.setOpaque(false); After doing so I can't select any JButtons or other JComponents under the JGlassPane. Is there a way to have only the components on the GlassPane selectable while still having the ability to select components under the GlassPane? Edit I forgot to mention (not knowing this would be relevant) that I did attach both a MouseListener and a MouseMotionListener to the glass pane. Is there a way to pass the Mouse Events to other components and only use them when needed?

    Read the article

  • Add 'expand' button to JTree node that has no children?

    - by thedude19
    I'd like to add the 'expand' button to my JTree's nodes to indicate that they are expandable. The catch is that they have no children until the user clicks on them (due to processing that happens in the background). Is there any way I can set a node as a parent or having children without it actually having children? Thanks

    Read the article

  • How to Stich multiple java.awt.Image objects

    - by Imran
    Refereing to my previous question, http://stackoverflow.com/questions/2682364/how-to-stich-to-image-objects-in-java I successfully stiched two java.awt.Image objects, now I need to stich multiple objects of the same type. Is there any API or library available for that

    Read the article

  • How to put a background image on GridBagLayout

    - by Loligans
    I am trying to work with layout managers for the first time, and they are just kicking me in the teeth. I am trying to make a background image and then put buttons on top, using GridBagLayout, if there is a a better layoutmanager please do tell. As for trying to learn how to use layout managers, its very difficult and any learning references would also be much appreciated. This is what it looks like currently, I can get the frame to show the full image, but when i use gridlayout manager, it does that public void addComponentsToPane(Container pane){ BackgroundImage image = new BackgroundImage(); JButton button1, button2, button3, button4, button5; pane.setLayout(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); if(shouldFill){ c.fill = GridBagConstraints.NONE; } button1 = new JButton("Button 1"); if (shouldWeightX) { c.weightx = 0.5; } c.fill = GridBagConstraints.HORIZONTAL; c.gridx = 1; c.gridy = 0; button1.setOpaque(false); pane.add(button1, c); button2 = new JButton("Button 2"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 0; c.gridy = 0; button2.setOpaque(false); pane.add(button2, c); button3 = new JButton("Button 3"); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 0.5; c.gridx = 2; c.gridy = 0; button3.setOpaque(false); pane.add(button3, c); button4 = new JButton("Long-Named Button 4"); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 40; //make this component tall c.weightx = 0.0; c.gridwidth = 3; c.gridx = 0; c.gridy = 1; pane.add(button4, c); button5 = new JButton("button 1"); c.fill = GridBagConstraints.HORIZONTAL; c.ipady = 0; //reset to default c.weighty = 1.0; //request any extra vertical space c.anchor = GridBagConstraints.PAGE_END; //bottom of space c.insets = new Insets(10,0,0,0); //top padding c.gridx = 1; //aligned with button 2 c.gridwidth = 2; //2 columns wide c.gridy = 2; //third row pane.add(button5, c); c.ipadx = 800; c.ipady = 400; pane.add(image, c); } This is what i'm trying to make it look like

    Read the article

  • how to draw a line between two labels in a panel where labels are added during runtime

    - by vybhav
    A panel contains two labels which are generated by mouse clicks on the panel. I want to connect these two labels by drawing a line between them probably by dragging the mouse pointer from one label to another. There are two events here - one is clicking on the panel to generate the labels and the second is connecting these two labels (mouse pressed, mouse dragged and mouse released events). Both these event need to call the repaint() method but for different purposes. But there can be only one paint() method. The problem is when I connect these two labels, the line comes up but the rest of the components on the panel disappear.

    Read the article

  • Workaround for JFormattedTextField delete bug in Java for Mac OS X 10.6 Update 2 (1.6.0_20)

    - by Johan Kaving
    There is apparently a bug introduced in the latest Java update for Mac OS X, which causes deletes in JFormattedTextFields to be performed twice. See http://lists.apple.com/archives/java-dev/2010/May/msg00092.html The DefaultEditorKit.deletePrevCharAction is invoked twice when the delete key is pressed. Are there any suggestions for a workaround? I'm thinking of replacing the delete action for my text fields with a patched version that somehow filters out these duplicate invocations.

    Read the article

  • Java: getInputMap(WHEN_IN_FOCUSED_WINDOW) from within JInternalFrame

    - by gerardlouw
    I have a component inside a JInternalFrame which needs to perform actions when keys are pressed within the JInternalFrame's parenting window. Using InputMap/ActionMap would be ideal, but the getInputMap(WHEN_IN_FOCUSED_WINDOW) of the component returns an InputMap that treats the JInternalFrame as the "focused window", rather than its parenting window. Any solutions or ideas?

    Read the article

  • The Elegant way to handle Cyclic Event in Java ??

    - by dex
    Hi fellows, i think this not a specific problem to me; everybody might have encountered this issue before. To properly illustrate it, here's a simple UI: As you can see, those two spinners are controlling a single variable -- "A". The only difference is that they control it using different views. If i change the top spinner, "A" will be changed and the bottom spinner's value will also be updated accordingly. However, updating the bottom spinner's call (such as setValue) will also trigger another event instructing the top spinner to update based on the bottom spinner's value. Thus creates a bad cycle which can eventually cause a StackOverFlow exception. My previously solution is kinda cumbersome: i placed a guarding boolean to indicate whether the 2nd updating call should be performed. Now i'd like to ask "how can i handle such situation elegantly?" thx

    Read the article

  • JPanel in JFrame in NetBeans

    - by Gaurav
    I have created a Java application (project) in NetBeans, in which I have designed a JFrame with menu bar, and different JPanels. I want these JPanels to appear inside the JFrame on action of different menu items, so that whenever the menu items are clicked different JPanels should appear inside the JFrame. I have designed both JFrame & JPanel separately, but I couldn't link them together. Please help me out friends.

    Read the article

  • How to remove the title bar from a JFrame screenshot?

    - by Greg Harman
    I'm capturing a screenshot image of a JFrame via a "double buffering" approach, per below: public BufferedImage getScreenshot() { java.awt.Dimension dim = this.getPreferredSize(); BufferedImage image = new BufferedImage(dim.width, dim.height, BufferedImage.TYPE_INT_RGB); this.paint(image.getGraphics()); return image; } where this extends JFrame. The image that I get has a blank strip along the top where the title bar was. What's the most straightforward way to capture an image of the contents of the JFrame without the extra space allocated for the title bar?

    Read the article

  • Creating a table with an initial element selected

    - by Tony
    I want to create a table which displays in each row a set of data, in addition to a radio button for possible selection. This can be achieved easily by using a simple table model class which extends the DefaultTableModel and a cell renderer and editor class which implements the TableCellRenderer and TableCellEditor interfaces respectively. What I really couldn't manage to do is to make the table to display initially one of the elements (rows) initially selected. It seems straightforward but it isn't...does anybody have a clue about it?

    Read the article

  • Element to string in HTMLDocument

    - by kalpesh
    i have a Element object its a HTMLDocument object and i want to string value of this element. i want this result Christina Toth, Pharm. D. ======================= plz see below code. public static void main(String args[]) throws Exception { InputStream is = Nullsoft.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); HTMLEditorKit htmlKit = new HTMLEditorKit(); HTMLDocument htmlDoc = (HTMLDocument) htmlKit.createDefaultDocument(); HTMLEditorKit.Parser parser = new ParserDelegator(); HTMLEditorKit.ParserCallback callback = htmlDoc.getReader(0); parser.parse(br, callback, true); // Parse ElementIterator iterator = new ElementIterator(htmlDoc); Element element; while ((element = iterator.next()) != null) { AttributeSet attributes = element.getAttributes(); Object name = attributes.getAttribute(StyleConstants.NameAttribute); if ((name instanceof HTML.Tag) && ((name == HTML.Tag.DIV) || (name == HTML.Tag.H2) || (name == HTML.Tag.H3))) { StringBuffer text = new StringBuffer(); int count = element.getElementCount(); for (int i = 0; i < count; i++) { Element child = element.getElement(i); AttributeSet childAttributes = child.getAttributes(); // if (childAttributes.getAttribute(StyleConstants.NameAttribute) == HTML.Tag.CONTENT) { int startOffset = child.getStartOffset(); int endOffset = child.getEndOffset(); int length = endOffset - startOffset; text.append(htmlDoc.getText(startOffset, length)); } } System.out.println(name + ": " + text.toString()); } } System.exit(0); } public static InputStream getInputStream() { String text = "<html>\n" + "<head>\n" + "<title>pg_0001</title>\n" + "\n" + "<style type=\"text/css\">\n" + ".ft3{font-style:normal;font-weight:bold;font-size:11px;font-family:Helvetica;color:#000000;}\n" + "</style>\n" + "</head>\n" + "<body vlink=\"#FFFFFF\" link=\"#FFFFFF\" bgcolor=\"#ffffff\">\n" + "\n" + "\n" + "<div style=\"position:absolute;top:597;left:252\"><nobr><span class=\"ft3\">Christina Toth, Pharm. D.</span></nobr></div>\n" + "\n" + "\n" + "</body>\n" + "</html>"; InputStream is = null; try { is = new ByteArrayInputStream(text.getBytes("UTF-8")); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } return is; }

    Read the article

  • JFrame the same shape as an Image / Program running in background

    - by Jan Weber
    My question is simple, the solution surely not. I am looking for a way to shape a JFrame the same as an Image it will be displaying. By shape I mean the shape of the pixels that have an alpha != 0. I've already found a working example using a GeneralPath object, but it created ~110000 "nodes" for an Image of about 500*400, so starting the JFrame took more than 2 minutes, which is definitely not the desired effect, the startup should be in under 2 seconds. Thanks for your time.

    Read the article

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