Search Results

Search found 37239 results on 1490 pages for 'javax swing text'.

Page 62/1490 | < Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >

  • Having difficulty add a custom icon to a JFrame

    - by Oliver
    Hi, I have been trying to change the icon in the frame. I have virtually tried everything: The icon is 16x16 which is the right size ....doesn't work I've trying PNG,GIF and JPG formats none of them work. Tried different way of setting the icon....doesn't work. I've tried relative (local paths) e.g. "icon.gif" and absolute paths e.g. "c:\work\java\icon.gif" ...doesn't work Here is my code and see if you can figure it out Thanks Oli import javax.swing.*; public class androidDriver { public static void main(String[] args) throws IOException { JFrame f = new JFrame("Android Data Viewer"); f.setResizable(false); f.setSize(300,300); f.setLocationRelativeTo(null); f.setVisible(true); f.setIconImage(new ImageIcon("androidIcon2.gif").getImage()); } }

    Read the article

  • Read / write program in Java using JFileChooser

    - by Casper Marcussen
    Didn't want to bother people in here, but since I am under a time pressure, I am desperate to get help. My questions is how to link the file choosen from a JFileChooser to a file, and how to convert it to string being able to display and edit it in a TextArea. I have the GUI set up using swing, but the link between actionListener and the JFileChooser is not complete. Any help would be much appreciated. Code: http://pastebin.com/p3fb17Wi EDIT: I found this program, that does pretty much what i wanted to, but it does not allow me to save the actual file : http://www.java-forums.org/new-java/8856-how-get-content-text-file-write-jtextarea.html

    Read the article

  • DJ JWebBrowser: how to show but disable Address and Button bars?

    - by Nikolay Kuznetsov
    I am using chrriis.dj.nativeswing.swtimpl.components.JWebBrowser in my swing application to open web page. The page is going to show "Facebook Authentication" page and I want to prevent user from inputting some other URL other than I specify and also Forward and Back buttons should be visible but not has no affect. So following functions are applicable for my goal setButtonBarVisible(true); setLocationBarVisible(true); Once user completes the authentication I will handle the locationChanged event. @Override public void locationChanged(WebBrowserNavigationEvent arg0) { System.out.println("locationChanged!"); .... } }

    Read the article

  • "Unsupported Image Type" exception in only few images...

    - by Nitz
    In my java-swing project. I have one frame in which user can drop the images and save that images in database. Now this work perfectly but their are some images which is not showing. This are images Image 1 , Images 2 which is not supporting .. this are some images which are not reading... and its showing me exception, like javax.imageio.IIOException: Unsupported Image Type Can i check that, is the image which user had dropped is supported or not? And can i convert that file which is not supported into supported file in java?

    Read the article

  • Adding JTextField to a JPanel and showing them

    - by Davide Gualano
    I'm building a little app using Java and Swing in NetBeans. Using NetBeans design window, I created a JFrame with a JPanel inside. Now I want to dynamically add some jTextFields to the JPanel. I wrote something like that: Vector textFieldsVector = new Vector(); JTextField tf; int i = 0; while (i < 3) { tf = new JTextField(); textFieldVector.add(tf); myPanel.add(tf); //myPanel is the JPanel where I want to put the JTextFields i++; } myPanel.validate(); myPanel.repaint(); But nothing happens: when I run the app, the JFrame shows with the JPanel inside, but the JTextFields don't. I'm a total newbie in writing graphical Java apps, so I'm surely missing something very simple, but I can't see what.

    Read the article

  • How do I detect if a display is in High Contrast mode?

    - by banjollity
    I'm testing my company's established Swing application for accessibility issues. With high contrast mode enabled on my PC certain parts of this application are rendered properly (white-on-black) and some incorrectly (black-on-white). The bits that are correct are the native components (JButton, JLabel and whatnot) and third party components from the likes of JIDE. The incorrect bits are custom components and renderers developed in-house without consideration for high-contrast mode. Clearly it's possible to detect when high-contrast mode is enabled. How do I do this?

    Read the article

  • Visual Editor vs Manual code

    - by Albinoswordfish
    I'm not sure how it is using other frameworks but this questions is strictly regarding Java swing. Is it better to use a Visual Editor to place objects or to manually code the placement of the objects onto the frame (Layout managers or null layouts)? From my experience I've had a lot of trouble using Visual editors when it comes to different screen resolutions or changing the window size. Using manual code to place objects I've found that my GUIs behave a lot better with regard to the screen size issue. However when I want to change a small part of my GUI it takes a lot more work compared to using a visual editor Just wondering what people's thoughts were on this?

    Read the article

  • Java appliction design question

    - by ring bearer
    Hi I have a hobby project, which is basically to maintain 'todo' tasks in the way I like. One task can be described as: public class TodoItem { private String subject; private Date dueBy; private Date startBy; private Priority priority; private String category; private Status status; private String notes; } as you can imagine I would have 1000 todo items at a given time. What is the best strategy to store a todo item? (currently on an XML file) such that all the items are loaded quickly up on app start up(the application shows kind of a dashboard of all the items at start up) What is the best way to design its back-end so that it can be ported to android/or a J2ME based phone Currently this is done using java swing. What should be the concerns so that it works efficiently on a device where memory is limited? Thanks!

    Read the article

  • login form whith java/sqlite

    - by tuxou
    hi I would like to create a login form for my application with the possibility to add or remove users for an sqlite database, i have created the table users(nam, pass) but i can't unclud it in my login form, it someone could help me this is my login code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public class login extends JFrame { // Variables declaration private JLabel jLabel1; private JLabel jLabel2; private JTextField jTextField1; private JPasswordField jPasswordField1; private JButton jButton1; private JPanel contentPane; // End of variables declaration public login() { super(); create(); this.setVisible(true); } private void create() { jLabel1 = new JLabel(); jLabel2 = new JLabel(); jTextField1 = new JTextField(); jPasswordField1 = new JPasswordField(); jButton1 = new JButton(); contentPane = (JPanel)this.getContentPane(); // // jLabel1 // jLabel1.setHorizontalAlignment(SwingConstants.LEFT); jLabel1.setForeground(new Color(0, 0, 255)); jLabel1.setText("username:"); // // jLabel2 // jLabel2.setHorizontalAlignment(SwingConstants.LEFT); jLabel2.setForeground(new Color(0, 0, 255)); jLabel2.setText("password:"); // // jTextField1 // jTextField1.setForeground(new Color(0, 0, 255)); jTextField1.setSelectedTextColor(new Color(0, 0, 255)); jTextField1.setToolTipText("Enter your username"); jTextField1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jTextField1_actionPerformed(e); } }); // // jPasswordField1 // jPasswordField1.setForeground(new Color(0, 0, 255)); jPasswordField1.setToolTipText("Enter your password"); jPasswordField1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jPasswordField1_actionPerformed(e); } }); // // jButton1 // jButton1.setBackground(new Color(204, 204, 204)); jButton1.setForeground(new Color(0, 0, 255)); jButton1.setText("Login"); jButton1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); // // contentPane // contentPane.setLayout(null); contentPane.setBorder(BorderFactory.createEtchedBorder()); contentPane.setBackground(new Color(204, 204, 204)); addComponent(contentPane, jLabel1, 5,10,106,18); addComponent(contentPane, jLabel2, 5,47,97,18); addComponent(contentPane, jTextField1, 110,10,183,22); addComponent(contentPane, jPasswordField1, 110,45,183,22); addComponent(contentPane, jButton1, 150,75,83,28); // // login // this.setTitle("Login To Members Area"); this.setLocation(new Point(76, 182)); this.setSize(new Dimension(335, 141)); this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); this.setResizable(false); } /** Add Component Without a Layout Manager (Absolute Positioning) */ private void addComponent(Container container,Component c,int x,int y,int width,int height) { c.setBounds(x,y,width,height); container.add(c); } private void jTextField1_actionPerformed(ActionEvent e) { } private void jPasswordField1_actionPerformed(ActionEvent e) { } private void jButton1_actionPerformed(ActionEvent e) { System.out.println("\njButton1_actionPerformed(ActionEvent e) called."); String username = new String(jTextField1.getText()); String password = new String(jPasswordField1.getText()); if(username.equals("") || password.equals("")) // If password and username is empty Do this { jButton1.setEnabled(false); JLabel errorFields = new JLabel("You must enter a username and password to login."); JOptionPane.showMessageDialog(null,errorFields); jTextField1.setText(""); jPasswordField1.setText(""); jButton1.setEnabled(true); this.setVisible(true); } else { JLabel optionLabel = new JLabel("You entered "+username+" as your username. Is this correct?"); int confirm =JOptionPane.showConfirmDialog(null,optionLabel); switch(confirm){ // Switch Case case JOptionPane.YES_OPTION: // Attempt to Login user jButton1.setEnabled(false); // Set button enable to false to prevent 2 login attempts break; case JOptionPane.NO_OPTION: // No Case.(Go back. Set text to 0) jButton1.setEnabled(false); jTextField1.setText(""); jPasswordField1.setText(""); jButton1.setEnabled(true); break; case JOptionPane.CANCEL_OPTION: // Cancel Case.(Go back. Set text to 0) jButton1.setEnabled(false); jTextField1.setText(""); jPasswordField1.setText(""); jButton1.setEnabled(true); break; } // End Switch Case } } public static void main(String[] args) { JFrame.setDefaultLookAndFeelDecorated(true); JDialog.setDefaultLookAndFeelDecorated(true); try { UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); } catch (Exception ex) { System.out.println("Failed loading L&F: "); System.out.println(ex); } new login(); }; }

    Read the article

  • File is not Writing using FileOutputStream in java

    - by Krishna
    I have Java Desktop Swing application in which i am trying to write xml file but its not writing data into file here my code is FileOutputStream fileOutputStream = new FileOutputStream(input_file); SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance(); SOAPConnection soapConnection = soapConnectionFactory.createConnection(); SOAPMessage soapResponse = soapConnection.call(soapcall, url); String str = WebServiceDAO.soapMessageToString(soapResponse); System.err.println("String*****" + str); fileOutputStream.write(str.getBytes()); fileOutputStream.close(); here i am getting data but its not writing in file what could be the prob?

    Read the article

  • Progress bar increment by 1 every 100th of second

    - by Matthew De'Loughry
    I'm trying to get a JProgressBar to increment by 1 every 100th of a second, and at the moment I'm using Thread.sleep(100) inside a while statement like so: try { while (i<=100){ doTime(); } } catch (InterruptedException ex) { Logger.getLogger(SplashScreen.class.getName()).log(Level.SEVERE, null, ex); } public void doTime() throws InterruptedException{ jLabel1.setText("sleeping"); Thread.sleep(100); jLabel1.setText("start"); i++; pb.setValue(i); pb.repaint(); } and If I debug by doing a System.out.println it displays in real time but the swing GUI freezes until it drops out of the while loop can anyone help? thanks matt

    Read the article

  • How can I clip strings in Java2D and add ... in the end?

    - by Jonas
    I'm trying to print Invoices in a Java Swing applications. I do that by extending Printable and implement the method public int print(Graphics g, PageFormat pf, int page). I would like to draw strings in columns, and when the string is to long I want to clip it and let it end with "...". How can I measure the string and clip it at the right position? Some of my code: Font headline = new Font("Times New Roman", Font.BOLD, 14); g2d.setFont(headline); FontMetrics metrics = g2d.getFontMetrics(headline); g2d.drawString(myString, 0, 20); I.e How can I limit myString to be max 120px? I could use metrics.stringWidth(myString), but I don't get the position where I have to clip the string. Expected results could be: A longer string that exc... A shorter string. Another long string, but OK

    Read the article

  • Building a Monopoly Board with GridBagLayout

    - by Oetzi
    I have been building a Java version of Monopoly in my spare time and am having some trouble understanding layouts etc for Swing. Each one of my spaces on the board is a essentially a custom JButton and I have been trying to lay them around the edge of a frame (like on the monopoly board itself). I can't seem to find a useful explanation of how the layout system works and so am having trouble do so. Could someone please give me an example of how they would lay the buttons around the edge of the frame? Should I be using a different layout?

    Read the article

  • calling invokeAndWait from the EDT

    - by Aly
    Hi, I have a problem following from my previous problem. I also have the code SwingUtillities.invokeAndWait somewhere else in the code base, but when I remove this the gui does not refresh. If I dont remove it the error I get is: Exception in thread "AWT-EventQueue-0" java.lang.Error: Cannot call invokeAndWait from the event dispatcher thread at java.awt.EventQueue.invokeAndWait(Unknown Source) at javax.swing.SwingUtilities.invokeAndWait(Unknown Source) at game.player.humanplayer.model.HumanPlayer.act(HumanPlayer.java:69) The code in HumanPlayer.act is: public Action act(final Action[] availiableActions) { try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { gui.update(availiableActions); } }); } catch (InterruptedException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } synchronized(performedAction){ while(!hasPerformedAction()){ try { performedAction.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } setPerformedAction(false); } return getActionPerfomed(); }

    Read the article

  • Add a listener inside or outside get method

    - by James P.
    I'm learning Swing and have composed an interface using a series of get methods to add components. Is it a good practise to add a Listener inside a get method as follows? I'd like to make things as decoupled as possible. private JButton getConnectButton() { if (connectButton == null) { connectButton = new JButton(); connectButton.setText("Connect"); connectButton.setSize(new Dimension(81, 16)); connectButton.setLocation(new Point(410, 5)); connectButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // actionPerformed code goes here } }); } return connectButton; }

    Read the article

  • Top tips for designing GUIs?

    - by oxbow_lakes
    A while back I read (before I lost it) a great book called GUI Bloopers which was full of examples of bad GUI design but also full of useful tidbits like Don't call something a Dialog one minute and a Popup the next. What top tips would you give for designing/documenting a GUI? It would be particularly useful to hear about widgets you designed to cram readable information into as little screen real-estate as possible. I'm going to roll this off with one of my own: avoid trees (e.g. Swing's JTree) unless you really can't avoid it, or have a unbounded hierarchy of stuff. I have found that users don't find them intuitive and they are hard to navigate and filter. PS. I think this question differs from this one as I'm asking for generalist tips

    Read the article

  • Need better Java application deployment strategy

    - by Jeff Post
    I have various Java Swing applications that are used by multiple users. My deployment strategy is to locate the .jar file on a network share, and users create shortcuts to that file. When the user launches an application, the file is copied to their machine and executed locally. This method allows for a single copy of the code and easy updating. The problem is that I can't update the file on the network share if any user is using the application at that time. I can't use Web Start because I don't have access to a cert for signing the jar. My current workaround is a separate application that copies the desired app to the user's local machine, launches the application, and then the launcher exits. There is a several second delay from when the launcher app exits and the user's app becomes visible. Can anyone suggest a better deployment method where I can easily update a central copy of the application, one where Windows XP won't maintain a lock on the file?

    Read the article

  • how to put jcheckbox to table cell?

    - by joseph
    Hello, I cannot put jChceckBox to jTable cell. More likely I can put checkBox to table, but when I run module with that table, the cell where should be checkBox shows text "true" or "false". The behaviors of that cell are the same like checkbox, but it shows text value instead of checkbox. Here is the code. DefaultTableModel dm = new DefaultTableModel(); dm.setDataVector(new Object[][]{{"dd", "Edit", "Delete"}, {"dd","Edit", "Delete"}}, new Object[]{"Include","Component", "Ekvi"}); jTable1 = new javax.swing.JTable(); jTable1.setModel(dm); JCheckBox chBox=new JCheckBox(); jTable1.getColumn("Include").setCellEditor(new DefaultCellEditor(chBox)); jScrollPane1.setViewportView(jTable1);

    Read the article

  • File Explorer using Java - how to go about it?

    - by user299988
    Hi, I am set to create a file explorer using Java. The aim is to emulate the behavior of the default explorer as closely as possible, whatever may be the underlying OS. I have done NO GUI programming in Java. I have looked-up Swing, SWT and JFace, and I am beginning my project with this tutorial: http://www.ibm.com/developerworks/opensource/library/os-ecgui1/ I would like to know your opinions about the best approach to tackle this problem. If you could comment on complexity of coding, portability and OS-independence, and efficiency, it would be great. Is there anything else I should know? Do some other ways exist? Thanks a lot!

    Read the article

  • How to adjust a JScrollPane to its contained JTree

    - by spuas
    Hello, here I have a swing size question: I have a JTree which is contained inside a JScrollPane (which is contained in a custom component which extends JXPanel from swingx, but I think that has nothing to do with this question). Doesn't matter how many rows the tree has, the scrollpane is always bigger (the tree is dinamic but not designed to have many rows) but what I would like is the JScrollPane to adjust to the tree initial height and then show the vertical scroll when some of the nodes are expanded. I have tried without setting any size at all, setting tree preferred size to null and setting scrollpane preferred size to null as well but nothing changes. I DO NOT WANT to set the size manually... Is there a way to do this? Thanks

    Read the article

  • JList not showing items or showing selectively.

    - by Avrahamshuk
    I have a Java Swing application using a JList to show some data from a DB. I am using DefaulListModel as the data model for the list in this way: void PopulateSoldiersList() { try { soldiersListModel = new DefaultListModel(); for (Soldier i : myBackEnd.GetAllSoldiers()) { soldiersListModel.addElement(i); } this.listSoldiers.setModel(soldiersListModel); } catch (Exception ex) {// Error Message} } And for some reason, the list just stays empty... I even did make sure at runtime that all the data is set up properly in the data model and even in the "dataModel" property of the JList! In other place at the app i have a similar problem, but there, sometimes the list show few items from the model (but not all of them) I have no idea where to go from here... please help. Thanks!

    Read the article

  • How can I do printing in Java with layouts instead of low level coordinates?

    - by Jonas
    I need to to some printing from my Java Swing application. I have tried to use Java Tutorials, but everything is very low level, and time-consuming. I have to specify the coordinates for every line that I want to print. It it also very lowlevel to use text, because I have to use FontMetrics and calculate what space all text fills up. Is there any easier way to to printing in Java? I would like to design the documents with something like layout managers instead. Any good library or API?

    Read the article

  • assign keys for combo box in java

    - by adesh kumar
    I want to add a JComboBox in Swing that is simple but I want to assign the values for each items in combo. I have the following code JComboBox jc1= new JComboBox(); jc1.addItem("a"); jc1.addItem("b"); jc1.addItem("c"); Now what I want is that when click on combo box it should return 1, 2 and 3 correspondingly instead of a ,b, c. Is there any way to assign the key values for each items in combo box?

    Read the article

  • Nested CheckBox in Java

    - by Shailesh Ahuja
    I want to create a nested checkbox list. If the user checks the main item, all the sub-items under and get checked. If the user checks some of the sub-items, then a blue square appears inside the main items checkbox. It should look something like this. How do I do that in Java 1.6? Can I use swing or any external library? I would like to choose the easiest and the fastest way to achieve this? My aim is to create only 1 level of nesting.

    Read the article

  • Does this game have a solution

    - by Bragboy
    Hi, I am developing a simple game using Java swing. I want to know whether this particular game has a solution in the following scenario. If I am convinced that theoretically a solution cannot be arrived at this point, I will throw a notification to the user. 3x3 4x4 The objective of this game is to fill numbers from 1 to 8 (or 1 to 15) using the one space available to push the numbers to that empty space. Every time I end up with the combination shown above. I just want to convince myself that there is no way to attain the proper solution from the above scenario. Please help. EDIT : Solution has been posted at here and here

    Read the article

< Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >