Search Results

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

Page 19/63 | < Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >

  • How to rectify this program?

    - by user1430719
    This is a program to display a pie chart. I also have a button. But the program I have written, creates two separate frames and one frame is for the pie chart and the other is for the button. How do I put both button and pie chart on the same frame?? Can you please rectify my program. import java.awt.*; import org.jfree.chart.*; import org.jfree.chart.title.*; import org.jfree.data.general.DefaultPieDataset; import org.jfree.ui.*; import java.io.*; import javax.swing.*; import java.awt.event.*; import javax.swing.filechooser.*; public class Pie{ public static void getFile(File f) { System.out.println("File is: "+f.getName()); } public static void main(String[] args) { JPanel panel=new JPanel(); panel.setLayout(null); JButton b=new JButton("Open File"); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JFileChooser chooser=new JFileChooser(); int ret = chooser.showDialog(null, "Open file"); if (ret == JFileChooser.APPROVE_OPTION) { File file = chooser.getSelectedFile(); getFile(file); } } } ); b.setBounds(50,40,100,35); panel.add(b); DefaultPieDataset pieDataset = new DefaultPieDataset(); pieDataset.setValue("A", new Integer(10)); pieDataset.setValue("B", new Integer(20)); pieDataset.setValue("C", new Integer(30)); pieDataset.setValue("D", new Integer(10)); pieDataset.setValue("E", new Integer(20)); pieDataset.setValue("F", new Integer(10)); JFreeChart chart = ChartFactory.createPieChart("Pie Chart using JFreeChart", pieDataset, true,true,true); ChartFrame frame1=new ChartFrame("Pie Chart",chart); frame1.add(panel); frame1.setVisible(true); frame1.setSize(600,600); } }

    Read the article

  • Customizing jTable

    - by gmile
    I need to customize my jTable. All I need, is to put a custom Swing object (like jButon, jPanel, etc.) into the table cell. Is it possible? I'm trying: jTable.getModel.setValueAt(jPanel1,0,0) and jTable.getModel.setValueAt(jPanel1.getUI(),0,0) But the result is only a some kind of string, representing the object... Any ideas?

    Read the article

  • how set vertical marquee in java application?

    - by Arivu2020
    Hi, I am creating one application in java using swing.In that i have an array of String, I try to use html marquee tag to scroll all the strings one by one from top to bottom.But the marquee tag doesn't support in the panel. How can i acheive it.Can any one suggest me? Thanks in advance

    Read the article

  • Disable JPanel with visual effect

    - by Ryan
    I'm looking for a good way to disable a JPanel. I'm using a MVC design for a Java Swing GUI. I want the JPanel to be disabled while the model is processing stuff. I've tried setEnabled(false). That disables user input on the JPanel, but I'd like it to be grayed out to add a more visual effect. Thanks in advance!

    Read the article

  • Remember the values entered on standalone app on the client side

    - by kshtjsnghl
    We have a standalone java swing app, in which the user can print something that he drew, on a printer by giving its IP. Now the requirement is that the app needs to remember the ip that was given the last time by this user. What I could think of till now is (a brute one though) - keep a log file kind of storage on the client machine, and that everytime the app comes up it reads the last submitted one. Any suggestions would be helpful. Thanks in advance.

    Read the article

  • Using a model to represent the overall state of a view

    - by James P.
    Is there a standard practise for representing the state of a user interface that is not linked to a single Component? For example, a Swing interface could have a series of tabs with a constraint that a single tab should only be displayed once per a given entity type (this could be represented as a HashSet). Or a message could give the result of the last operation carried out. Or a JPanel could be linked to a single entity instance for editing purposes.

    Read the article

  • java:I am trying to create Shotcut of any abc.exe through java program.

    - by Sanjeev
    I am making an installer in java swing it almost completed only one thing is left to do that is to create desktop shortcut of our software.I do not want to copy software on desktop but I want to create instance of that software like other MS software. How it can be done please help me. I am already copied my software in c:/Program files by using copy directory and I want to create shortcut on desktop .

    Read the article

  • how to adjust JFrame and JInternal frames with any screen size?

    - by Zakaria Marrah
    I am working on a swing application that starts with JFrame, but all the other frames are included as JInternalFrames, and i am facing some serious screen size problems when i instaled it in different computers, i used the following methode to set the JFrame in full screen Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); setBounds(0, 0, screenSize.width, screenSize.height); JFrame.setExtendedState(JFrame.MAXIMIZED_BOTH); but thre is no no difference, i want also to adjust the JInternalFrames with the screen size too. if you have any suggestions, solution please help :D

    Read the article

  • How do I make the main window to react to a table click

    - by Ayelet
    I am a new user of Java swing. I need to be able to create a popup with row info when the user clicks on that row. I managed to incorporate the mouseClick event reaction in my table class, and I have the row info available. But I don't know how to notify the main window about the event so it can display the dialog box/popup box. Can you help me?

    Read the article

  • Why is Java layout system so complicated to work with?

    - by Tom Brito
    Some points that make java swing layout system a nightmare: There's thousands of properties; Even if you learn all the properties, each layout manager ignores some properties; The only existing good RAD tool (NetBeans) does not work well; Layout managers behave different with components and containers inside it.

    Read the article

  • How to create a database binding using Windows Builder Pro?

    - by Tiago
    For the first time, I'm creating a Java Swing application. I'm using Windows Builder Pro in Eclipse, and a MySQL database (already setup up). Let's say I have a combo box, and I want (for instance) all 'name' fields from a 'certain' table appear. How can I setup that binding? I know how to programatically handle the connection and query code, what I would like to know is how to make that binding in Eclipse.

    Read the article

  • change all the label icon in a panel

    - by Josh
    I have a panel with several JLabel, I would like to change all their Icon, String path = System.getProperty("user.dir"); for (int x=0;x< 21;x++) { javax.swing.JLabel lab = boardPanel.getComponent(x).; lab.setIcon(new ImageIcon(path + "\\image\\blank.jpg")); } it gives me an error of incompatible type, all inside the boardPanel are JLabel, im using netbeans 6.8.

    Read the article

  • Open new panel with button clicked.

    - by bat
    Java Swing GUI: I am using ActionListener to preform the action when a button is clicked. What i want to do is when a button is clicked, open a new panel, but load/get the new panel from a different file. This is what i have so far but i rather just link to another file. THANKS! =] public void actionPerformed(java.awt.event.ActionEvent e) { //something like this... loadFile(newPlane.java); }

    Read the article

  • Generic solution to deselect buttons in java

    - by Hectoret
    In a set of radio buttons of the same group, only one can be selected at the same time. I would like to have the same behaviour with a normal button. Imagine there's a row of 3 buttons. When a button is selected it changes: but.setSelected(true) and the other two buttons should be NOT selected: but.setSelected(false) Now, is there a generic, simple and clean solution to accomplish that in Java (Swing) ?

    Read the article

  • Poor performance using RMI-proxies with Swing components

    - by Patrick
    I'm having huge performance issues when I add RMI proxy references to a Java Swing JList-component. I'm retrieving a list of user Profiles with RMI from a server. The retrieval itself takes just a second or so, so that's acceptable under the circumstances. However, when I try to add these proxies to a JList, with the help of a custom ListModel and a CellRenderer, it takes between 30-60 seconds to add about 180 objects. Since it is a list of users' names, it's preferrable to present them alphabetically. The biggest performance hit is when I sort the elements as they get added to the ListModel. Since the list will always be sorted, I opted to use the built-in Collections.binarySearch() to find the correct position for the next element to be added, and the comparator uses two methods that are defined by the Profile interface, namely getFirstName() and getLastName(). Is there any way to speed this process up, or am I simply implementing it the wrong way? Or is this a "feature" of RMI? I'd really love to be able to cache some of the data of the remote objects locally, to minimize the remote method calls.

    Read the article

  • JPanel paint method is not being called, why?

    - by swift
    When i run this code the paintComponent method is not being called It may be very simple error but i dont know why this, plz. package test; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.image.BufferedImage; import javax.swing.BorderFactory; import javax.swing.JPanel; class Userboard extends JPanel { static BufferedImage image; String shape; Point start; Point end; Point mp; String selected; int ex,ey;//eraser int w,h; public Userboard() { setOpaque(false); System.out.println("paper"); setBackground(Color.white); setBorder(BorderFactory.createLineBorder(Color.black)); } public void paintComponent(Graphics g) { System.out.println("userboard-paint"); try { //g.drawImage(image, 0, 0, this); Graphics2D g2 = (Graphics2D)g; g2.setPaint(Color.black); if(start!=null && end!=null) { if(selected==("elipse")) { System.out.println("userboard-elipse"); g2.drawOval(start.x, start.y,(end.x-start.x),(end.y-start.y)); System.out.println("userboard-elipse drawn"); } else if(selected==("rect")) g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); else if(selected==("line")) g2.drawLine(start.x,start.y,end.x,end.y); } } catch(Exception e) {} } //Function to draw the shape on image public void draw() { System.out.println("Userboard-draw"); System.out.println(selected); System.out.println(start); System.out.println(end); Graphics2D g2 = image.createGraphics(); g2.setPaint(Color.black); if(start!=null && end!=null) { if(selected=="line") g2.drawLine(start.x, start.y, end.x, end.y); else if(selected=="elipse") { System.out.println("userboard-elipse"); g2.drawOval(start.x, start.y, (end.x-start.x),(end.y-start.y)); System.out.println("userboard-elipse drawn"); } else if(selected=="rect") g2.drawRect(start.x, start.y, (end.x-start.x),(end.y-start.y)); } start=null; repaint(); g2.dispose(); } //To add the point to the board which is broadcasted by the server public void addPoint(Point ps,String varname,String shape,String event) { try { if(end==null) end = new Point(); if(start==null) start = new Point(); if(shape.equals("elipse")) this.selected="elipse"; else if(shape.equals("line")) this.selected="line"; else if(shape.equals("rect")) this.selected="rect"; else if(shape.equals("erase")) erase(); if(end!=null && start!=null) { if(varname.equals("end")) end=ps; else if(varname.equals("mp")) mp=ps; else if(varname.equals("start")) start=ps; if(event.equals("drag")) repaint(); else if(event.equals("release")) draw(); } repaint(); } catch(Exception e) { e.printStackTrace(); } } //Function which provides the erase functionality public void erase() { Graphics2D pic=(Graphics2D) image.getGraphics(); pic.setPaint(Color.white); if(start!=null) pic.fillRect(start.x, start.y, 10, 10); } //To set the size of the image public void setWidth(int x,int y) { System.out.println("("+x+","+y+")"); w=x; h=y; image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB); } //Function to add buttons into the panel, calling this function returns a panel }

    Read the article

  • Window's content disappears when minimized

    - by Carmen Cojocaru
    I have a simple class that draws a line when mouse dragging or a dot when mouse pressing(releasing). When I minimize the application and then restore it, the content of the window disappears except the last dot (pixel). I understand that the method super.paint(g) repaints the background every time the window changes, but the result seems to be the same whether I use it or not. The difference between the two of them is that when I don't use it there's more than a pixel painted on the window, but not all my painting. How can I fix this? Here is the class. package painting; import java.awt.*; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseMotionAdapter; import javax.swing.JFrame; import javax.swing.JPanel; class CustomCanvas extends Canvas{ Point oldLocation= new Point(10, 10); Point location= new Point(10, 10); Dimension dimension = new Dimension(2, 2); CustomCanvas(Dimension dimension){ this.dimension = dimension; this.init(); addListeners(); } private void init(){ oldLocation= new Point(0, 0); location= new Point(0, 0); } public void paintLine(){ if ((location.x!=oldLocation.x) || (location.y!=oldLocation.y)) { repaint(location.x,location.y,1,1); } } private void addListeners(){ addMouseListener(new MouseAdapter(){ @Override public void mousePressed(MouseEvent me){ oldLocation = location; location = new Point(me.getX(), me.getY()); paintLine(); } @Override public void mouseReleased(MouseEvent me){ oldLocation = location; location = new Point(me.getX(), me.getY()); paintLine(); } }); addMouseMotionListener(new MouseMotionAdapter() { @Override public void mouseDragged(MouseEvent me){ oldLocation = location; location = new Point(me.getX(), me.getY()); paintLine(); } }); } @Override public void paint(Graphics g){ super.paint(g); g.setColor(Color.red); g.drawLine(location.x, location.y, oldLocation.x, oldLocation.y); } @Override public Dimension getMinimumSize() { return dimension; } @Override public Dimension getPreferredSize() { return dimension; } } class CustomFrame extends JPanel { JPanel displayPanel = new JPanel(new BorderLayout()); CustomCanvas canvas = new CustomCanvas(new Dimension(200, 200)); public CustomFrame(String titlu) { canvas.setBackground(Color.white); displayPanel.add(canvas, BorderLayout.CENTER); this.add(displayPanel); } } public class CustomCanvasFrame { public static void main(String args[]) { CustomFrame panel = new CustomFrame("Test Paint"); JFrame f = new JFrame(); f.add(panel); f.pack(); SwingConsole.run(f, 700, 700); } }

    Read the article

< Previous Page | 15 16 17 18 19 20 21 22 23 24 25 26  | Next Page >