Search Results

Search found 3339 results on 134 pages for 'swing magic'.

Page 4/134 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • weird swing heavyweight object lightweight objects problem

    - by Yoav Schwartz
    Hello, We have a problem in our swing based application since we've upgraded our java version from 6u5 to 6u18 (The application runs over WinXP). Our application contains a Canvas object which resides in a JFrame. The application draws things on the canvas. Every time we drag a lightweight swing object (popup or another frame) over the canvas, it has a refresh problem. It blinks - becomes black. The problem only resolves after we move the swing component away from the canvas and click on it again. We think this problem is related to the fact the the canvas is a heavyweight object. And we know there were changes done in the new versions of java on the mixing of heavyweight and lightweight objects issue. Some more details: 1) Our problem reproduces in java 6u14 and 6u16. 2) Everything works fine in java 6u5. Another strange thing: We have 2 types of stations running our application. The first type has a ATI FireGL7100 PCI-E graphics card. The second type has a Matrox G450 PCI graphic card. The problem does not reproduce on the Matrox based station in any java version. One more thing: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6829858 - looks similar to our problem. Is our problem familiar? Do you have any suggestions (workarounds, ideas how the difference in graphics cards is connected to this problem) Hope I was clear enough, Yoav

    Read the article

  • Java swing hold buttons

    - by Simon Charette
    Hi, I'm trying to create a subclass of JButton or AbstractButton that would call specified .actionPerformed as long as the mouse is held down on the button. So far I was thinking of extending JButton, adding a mouse listener on creation (inside constructor) and calling actionPerformed while the mouse is down. So far i came up with that but I was wondwering if I was on the right track and if so, how to correctly implement the "held down" logic. package components; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import javax.swing.Action; import javax.swing.Icon; import javax.swing.JButton; public class HoldButton extends JButton { private class HeldDownMouseListener implements MouseListener { private boolean mouseIsHeldDown; private HoldButton button; private long millis; public HeldDownMouseListener(HoldButton button, long millis) { this.button = button; this.millis = millis; } @Override public void mouseClicked(MouseEvent arg0) { } @Override public void mouseEntered(MouseEvent arg0) { } @Override public void mouseExited(MouseEvent arg0) { } @Override public void mousePressed(MouseEvent arg0) { mouseIsHeldDown = true; // This should be run in a sub thread? // while (mouseIsHeldDown) { // button.fireActionPerformed(new ActionEvent(button, ActionEvent.ACTION_PERFORMED, "heldDown")); // try { // Thread.sleep(millis); // } catch (InterruptedException e) { // e.printStackTrace(); // continue; // } // } } @Override public void mouseReleased(MouseEvent arg0) { mouseIsHeldDown = false; } } public HoldButton() { addHeldDownMouseListener(); } public HoldButton(Icon icon) { super(icon); addHeldDownMouseListener(); } public HoldButton(String text) { super(text); addHeldDownMouseListener(); } public HoldButton(Action a) { super(a); addHeldDownMouseListener(); } private void addHeldDownMouseListener() { addMouseListener(new HeldDownMouseListener(this, 300)); } } Thanks a lot for your time.

    Read the article

  • Apple Magic Mouse on Windows XP SP3

    - by index
    Using generic Windows bluetooth drivers + Apple Wireless Mouse drivers as Bluetooth HID service. The mouse is connected. It just does not do anything. It does not show up under mice in hardware manager, just as Bluetooth HID. Not using the Apple drivers does not work either. I'm using a logilink BT0007

    Read the article

  • Apple Magic Trackpad 3-Finger Drop Lag

    - by activestylus
    After enabling three-finger dragging for my Trackpad, I notice that it drags well, but when I release there is about 1-2 seconds of lag before it actually drops. I understand this is supposed to be a feature so when you run out of space to drag, you have time to move your hand. But, for those of us powerusers, who move really fast, this is a BUG, not a feature. There should be some way to turn it off! For some perspective, I personally own a Fingerworks trackpad as well (the company Apple bought to make the Trackpad) and it does not suffer this problem. Drops are instantaneous no matter what program I am in. This is hugely frustrating for me, because I thought I was upgrading here and Apple's version does not perform as well as the Fingerworks model (which I purchased in 2004) I actually made a short video illustrating the problem, and why it is so frustrating for anyone who uses the pad as an artistic tool. Anyone here face this problem? If not, how would you recommend that I address Apple directly about this? PS - Already looked at this thread and the conclusion does not help me. I do not have one-finger drag enabled. PPS - I understand that for most people this is not an issue because they use the 'click' feature of the Trackpad. However, after years of using Fingerworks and not having to click ever, I find that it slows me down.

    Read the article

  • Java - AWT / Swing - handling the Event Descriptor Thread

    - by waitinforatrain
    Hi, I have a question about the 'Event Descriptor Thread'. I have a Main class that is also a JFrame. It initialises the rest of the components in the code, some of them do not involve Swing and some of them do. Is it enough to simply initialise the Main class using the EDT like this?... public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { new Main(); } }); } This way everything would run on the Event Dispatcher thread.

    Read the article

  • java, swing, Gridlayout problem

    - by josh
    I have a panel with GridLayout But when I'm trying to run the program, only the first button out of 100 is shown. Futhermore, the rest appear only when I move the cursor over them. What's wrong with it? Here's the whole class(Life.CELLS=10 and CellButton is a class which extends JButton) public class MainLayout extends JFrame { public MainLayout() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setSize(650, 750); setLayout(new FlowLayout()); //setResizable(false); final JPanel gridPanel = new JPanel(new GridLayout(Life.CELLS, Life.CELLS)); for (int i=0; i<Life.CELLS; i++) { for (int j=0; j<Life.CELLS; j++) { CellButton jb = new CellButton(i, j); jb.setPreferredSize(new Dimension(jb.getIcon().getIconHeight(), jb.getIcon().getIconWidth())); buttons[i][j] = jb; grid[i][j] = false; gridPanel.add(jb); } } add(gridPanel); } } This is code of CellButton package classes; import javax.swing.JButton; import javax.swing.ImageIcon; import javax.swing.JFrame; public class CellButton extends JButton { private int x; private int y; boolean alive; ImageIcon icon; boolean next; // icons for grids final ImageIcon dead = new ImageIcon(JFrame.class.getResource("/images/image1.gif")); final ImageIcon live = new ImageIcon(JFrame.class.getResource("/images/image2.gif")); public CellButton(int X, int Y) { super(); x = X; y = Y; alive = false; icon = dead; setIcon(icon); } public int getX() { return x; } public int getY() { return y; } public boolean isAlive() { return alive; } public void relive() { alive = true; icon = live; setIcon(icon); } public void die() { alive = false; icon = dead; setIcon(icon); } public void setNext(boolean n) { next = n; } public boolean getNext() { return next; } public ImageIcon getIcon() { return icon; } }

    Read the article

  • Jawa Swing: Dialog with expanding / progressive disclosure?

    - by Electrons_Ahoy
    I've got a dialog in a desktop Java Swing app. What I want is a classic Windows-style Progressive Disclosure dialog, where pressing a "More Options" button opens up a whole extra batch of options on the dialog. (Which can then be hidden again by clicking that same button, which now says something like "Hide".) What's the right way to do this in Swing? I can't seem to google-up anything directly relating to this, and what I have found boils down to "reset the preferred dimensions to 0 and revalidate" which can't possibly be the right way to do this and also causes all kinds of wacky things to happen.

    Read the article

  • Swing code in sockets

    - by asb
    I am learning swings for making GUI. I was thinking which is the best possible way in case of socket with swings. 1. The whole swing code goes in the server file. All the handlers and logic in on server side. Client only create socket. 2. The server have logic part. The code for the swing to display interface goes on client side. Client Creates stream to send / rec. data from server. Whch is the good way out of 2 ?

    Read the article

  • Real life Java Swing Project

    - by santiagobasulto
    Hi everybody! I've been working with swing for the last 2 years, but i'm still not satisfy with my own work. The apps are "fast" enough, but the development isn't enough "clean". Can you recommend me any real world project, book, or something similar that shows me how a real world swing app work. May be a framework, something structured, etc. For example, i'm thinking i may code a "window manager" that has all the window of the app in an unified resource, may be cached, etc. I think all those good ideas must be implemented already. Thanks!

    Read the article

  • Java Swing UI Changing Method

    - by vigilant
    I would like to use Swing to program a simple learning game. I am wondering what would be best way to switch between UI screens. For example, I would have a screen for the Main Menu, and then when the user presses a button on that screen, I would swap out the whole screen for a completely different one. Then, arbitrary screens can be swapped in at any moment, and all of their event handlers would be reactivated while the inactive screen's event handlers will be deactivated. What type of Swing component/control would I use for each of the 'screens'. Is this even doable?

    Read the article

  • tiled images in swing

    - by sasquatch90
    I have task to prepare two windows with swing. One contains grid of squares, with random numbers in them. In second I need to load pieces of tiled image and then show them in the correct order, forming tiled image. Windows should look like this : http://img535.imageshack.us/img535/3129/lab8a.jpg Okay so how to bite this ? I've used swing only few times to draw some 2d polylines, so basically I just theoretically now what to do. Ok, so window number 1: I start with creating Jframe for the window. Then I do for loop and in it create 16 JLabels with random numbers in them ? How to set margins between each tile and the whole window ? Window number 2 : So I start the same, but instead of loading numbers I add images ? Now, how can I load image from file and then set it as background ?

    Read the article

  • How to unicode Myanmar texts on Java? [closed]

    - by Spacez Ly Wang
    I'm just beginner of Java. I'm trying to unicode (display) correctly Myanmar texts on Java GUI ( Swing/Awt ). I have four TrueType fonts which support Myanmar unicode texts. There are Myanmar3, Padauk, Tharlon, Myanmar Text ( Window 8 built-in ). You may need the fonts before the code. Google the fonts, please. Each of the fonts display on Java GUI differently and incorrectly. Here is the code for GUI Label displaying myanmar texts: ++++++++++++++++++++++++ package javaapplication1; import javax.swing.JFrame; import javax.swing.JTextField; public class CusFrom { private static void createAndShowGUI() { JFrame frame = new JFrame("Hello World Swing"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); String s = "\u1015\u102F \u103C\u1015\u102F"; JLabel label = new JLabel(s); label.setFont(new java.awt.Font("Myanmar3", 0, 20));// font insert here, Myanmar Text, Padauk, Myanmar3, Tharlon frame.getContentPane().add(label); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } } ++++++++++++++++++++++++ Outputs vary. See the pictures: Myanmar3 IMG Padauk IMG Tharlon IMG Myanmar Text IMG What is the correct form? (on notepad) Well, next is the code for GUI Textfield inputting Myanmar texts: ++++++++++++++++++++++++ package javaapplication1; import javax.swing.JFrame; import javax.swing.JTextField; public class XusForm { private static void createAndShowGUI() { JFrame frame = new JFrame("Frame Title"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTextField textfield = new JTextField(); textfield.setFont(new java.awt.Font("Myanmar3", 0, 20)); frame.getContentPane().add(textfield); frame.pack(); frame.setVisible(true); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { createAndShowGUI(); } }); } } ++++++++++++++++++++++++ Outputs vary when I input keys( unicode text ) on keyboards. Myanmar Text Output IMG Padauk Output IMG Myanmar3 Output IMG Tharlon Output IMG Those fonts work well on Linux when opening text files with Text Editor application. My Question is how to unicode Myanmar texts on Java GUI. Do I need additional codes left to display well? Or Does Java still have errors? The fonts display well on Web Application (HTML, CSS) but I'm not sure about displaying on Java Web Application.

    Read the article

  • How do I get a JComponent to resize after calling `setVisible(true)`?

    - by iWerner
    Our application displays a 2D view of our data (mainly maps) and then allows the user to change to a 3D view. The 2D and 3D views are generated by custom C++ code that is SWIG'ed into our Swing GUI and wrapped within a JComponent. These JComponents are then displayed within another parent JComponent. Our problem is that when we change from the 2D to the 3D view and then back to the 2D view, when we resize the window the 2D view does not get resized. The resize events don't get sent to the 2D view. Our application runs under Linux (Fedora 11). We're running Java version 1.6.0_12. Here is some sample code in which I've replaced the 2D view and 3D view with two 2 JButtons, that produces the same behaviour. Once you go to 3D and then back to 2D, resizing the window does not cause the 2D view to be resized. /* TestFrame.java * Compile with: $ javac TestFrame.java * Run with: $ java TestFrame */ import java.awt.BorderLayout; import java.awt.Container; import java.awt.event.ComponentEvent; import java.awt.event.ComponentListener; import javax.swing.JButton; public class TestFrame extends javax.swing.JFrame { private boolean mode2D = true; private JButton view2D = null; private JButton view3D = null; private Container parent = null; public TestFrame() { initComponents(); containerPanel.setLayout(new BorderLayout()); view2D = new JButton("2D View"); view2D.addComponentListener(new MyListener("2D VIEW")); containerPanel.add(view2D); } private void changerButtonActionPerformed(java.awt.event.ActionEvent evt) { if (parent == null) { parent = view2D.getParent(); } if (mode2D) { System.out.println("Going from 2D to 3D"); view2D.setVisible(false); if (view3D != null) { view3D.setVisible(true); } else { view3D = new JButton("3D View"); view3D.addComponentListener(new MyListener("3D VIEW")); parent.add(view3D); } ((JButton) evt.getSource()).setText("Change to 2D"); mode2D = false; } else { System.out.println("Going from 3D to 2D"); view3D.setVisible(false); view2D.setVisible(true); ((JButton) evt.getSource()).setText("Change to 3D"); mode2D = true; } } public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new TestFrame().setVisible(true); } }); } private javax.swing.JPanel containerPanel; private javax.swing.JButton changerButton; private class MyListener implements ComponentListener { private String name; public MyListener(String name) { this.name = name; } @Override public void componentHidden(ComponentEvent event) { System.out.println("@@@ [" + name + "] component Hidden"); } @Override public void componentResized(ComponentEvent event) { System.out.println("@@@ [" + name + "] component Resized"); } @Override public void componentShown(ComponentEvent event) { System.out.println("@@@ [" + name + "] component Shown"); } @Override public void componentMoved(ComponentEvent event) { System.out.println("@@@ [" + name + "] component Moved"); } }; @SuppressWarnings("unchecked") private void initComponents() { containerPanel = new javax.swing.JPanel(); changerButton = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); containerPanel.setBorder(new javax.swing.border.MatteBorder(null)); javax.swing.GroupLayout containerPanelLayout = new javax.swing.GroupLayout(containerPanel); containerPanel.setLayout(containerPanelLayout); containerPanelLayout.setHorizontalGroup( containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 374, Short.MAX_VALUE) ); containerPanelLayout.setVerticalGroup( containerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 239, Short.MAX_VALUE) ); changerButton.setText("Change to 3D"); changerButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { changerButtonActionPerformed(evt); } }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(containerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(changerButton)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(containerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(changerButton) .addContainerGap()) ); pack(); } } (My apologies for the Netbeans generated GUI code) I should mention that when we call parent.remove(view2D) and parent.add(view3D) to change the views the X Windows ID of our 3D view changes and we're unable to get our 3D view back. Therefore parent.remove(view2D) and parent.add(view3D) is not really a solution and we have to call setVisible(false) and setVisible(true) on the JComponents that contain our 2D and 3D views in order to hide and show them. Any help will be greatly appreciated.

    Read the article

  • Custom Java Swing Meter Control

    - by Tyler
    I'm trying to make a custom swing control that is a meter. The arrow will move up and down. Here is my current code, but I feel I've done it wrong. import java.awt.BasicStroke; import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.LinearGradientPaint; import java.awt.Polygon; import java.awt.Stroke; import java.awt.geom.Point2D; import java.awt.geom.Rectangle2D; import javax.swing.JFrame; import javax.swing.JPanel; public class meter extends JFrame { Stroke drawingStroke = new BasicStroke(2); Rectangle2D rect = new Rectangle2D.Double(105, 50, 40, 200); Double meterPercent = new Double(0.57); public meter() { setTitle("Meter"); setLayout(null); setSize(300, 300); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setLocationRelativeTo(null); setVisible(true); } public void paint(Graphics g) { // Paint Meter Graphics2D g1 = (Graphics2D) g; g1.setStroke(drawingStroke); g1.draw(rect); // Set Meter Colors Point2D start = new Point2D.Float(0, 0); Point2D end = new Point2D.Float(0, this.getHeight()); float[] dist = { 0.1f, 0.5f, 0.9f }; Color[] colors = { Color.green, Color.yellow, Color.red }; LinearGradientPaint p = new LinearGradientPaint(start, end, dist, colors); g1.setPaint(p); g1.fill(rect); // Make a triangle - Arrow on Meter int[] x = new int[3]; int[] y = new int[3]; int n; // count of points // Set Points for Arrow Integer meterArrowHypotenuse = (int) rect.getX(); Integer meterArrowTip = (int) rect.getY() + (int) (rect.getHeight() * (1 - meterPercent)); x[0] = meterArrowHypotenuse - 25; x[1] = meterArrowHypotenuse - 25; x[2] = meterArrowHypotenuse - 5; y[0] = meterArrowTip - 20; // Top Left y[1] = meterArrowTip + 20; // Bottom Left y[2] = meterArrowTip; // Tip of Arrow n = 3; // Number of points, 3 because its a triangle // Draw Arrow Border Polygon myTriShadow = new Polygon(x, y, n); // a triangle g1.setPaint(Color.black); g1.fill(myTriShadow); // Set Points for Arrow Board x[0] = x[0] + 1; x[1] = x[1] + 1; x[2] = x[2] - 2; y[0] = y[0] + 3; y[1] = y[1] - 3; y[2] = y[2]; Robot robot = new Robot(); Color colorMeter = robot.getPixelColor(x[2]+10, y[2]); // Draw Arrow Polygon myTri = new Polygon(x, y, n); // a triangle Color colr = new Color(colorMeter.getRed(), colorMeter.getGreen(), colorMeter.getBlue()); g1.setPaint(colr); g1.fill(myTri); } public static void main(String[] args) { new meter(); } } Thanks for looking.

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >