Search Results

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

Page 50/63 | < Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >

  • can i know how to fix this error? is delete method

    - by user334101
    import javax.swing.*; import java.io.File; public class Third { public static void main(String[] args) throws Exception { String humanName; humanName = JOptionPane.showInputDialog(null, "Enter the file name"); File file = new File(+ humanName".txt"); System.out.println(file.delete()); JOptionPane.showMessageDialog(null, "File deleted" + humanName); } }

    Read the article

  • Javascript UI Toolkit

    - by Louis
    I'm looking for a light-weight UI toolkit written in Javascript (something like Swing) but I'd rather not use ExtJS because I fear that will slow things down tremendously. Are there any small UI toolkits out there that mainly focus on layouts?

    Read the article

  • Painted JPanel won't show up in JFrame

    - by javawarrior
    When I run my code, I expect to see a JPanel in my JFrame, but nothing shows up. I had a button in the frame, and it shows up. But the JPanel doesn't show up, I even colored it in red. Here is the code for my JPanel: import java.awt.*; import javax.swing.JPanel; public class graphic extends JPanel { private static final long serialVersionUID = -3458717449092499931L; public Game game; public graphic(Game game){ this.game = game; this.setPreferredSize(new Dimension(400,400)); this.setBackground(Color.RED); } public void paintComponent(Graphics g){ for (Line l:game.mirrors){ g.setColor(Color.BLACK); g.drawLine(l.start.x, l.start.y, l.end.x, l.end.y); } } } And my JFrame code: import java.awt.Container; import java.awt.event.*; import java.util.Timer; import java.util.TimerTask; import javax.swing.*; public class Viewer implements ActionListener { public JFrame frame; public JButton drawShoot; public boolean draw; public Game game; public graphic graphic; public TimerTask timert; public Timer timer; public Viewer(){ draw = true; game = new Game(); } public static void main(String args[]){ Viewer v = new Viewer(); v.setup(); } public void setup(){ frame = new JFrame("Laser Stimulator"); drawShoot = new JButton("Edit Mode"); graphic = new graphic(game); graphic.repaint(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(300, 300, 600, 600); Container contentPane = frame.getContentPane(); SpringLayout layout = new SpringLayout(); contentPane.setLayout(layout); drawShoot.addActionListener(this); timert = new TimerTask() { @Override public void run() { } }; timer =new Timer(); timer.scheduleAtFixedRate(timert, 0, 1000/30); contentPane.add(graphic); layout.putConstraint(SpringLayout.NORTH, graphic, 0, SpringLayout.NORTH, contentPane); layout.putConstraint(SpringLayout.WEST, graphic, 0, SpringLayout.WEST, contentPane); frame.setVisible(true); } @Override public void actionPerformed(ActionEvent e) { if (e.getSource()==drawShoot){ draw = !draw; drawShoot.setText((draw)?"Edit Mode":"Shoot Mode"); } } }

    Read the article

  • Bind Java program to Cocoa interface

    - by Kevin
    Hi, would it be possible to bind a Java application to a Cocoa graphical interface? I'm working in Eclipse right now, on my mac, and am wondering if Interface Builder could be used to construct a new interface so that I don't have to look at Swing all day. Any ideas/suggestions? Thanks!

    Read the article

  • Why right click is not working on java application?

    - by Nitz
    Hello Guys, I had made one Java Swing based application. On my application,if i click anywhere on the JFrame or anything, then my right click is not working? i had not set anything like that..then why is not working? Basically my key board was not working then i try to copy - paste data using mouse then, i came about to know that...my right click is not working on any area of my application...

    Read the article

  • java timer for game

    - by user261002
    I have created a game in java and now I just need to add a timer that allow the user to play under 60s. I have searched on internet and found the timer for swing and util packages. could you please just give me a method to be able to use it in my game???

    Read the article

  • Select SWT Library depending on OS

    - by phineas
    How do I ensure when I distribute a JAR-file that the proper SWT-library (either the windows, the linux or mac version) is loaded an ready to use? It would be very helpful because then you can do one export and your application can run on any platform like Swing apps usually do. Thanks a lot

    Read the article

  • Drag and Drop and identify locations with java

    - by out_sider
    I'm trying to do something quite simple, but I'm having a hard time finding good examples on the net to what I want specifically. I'd like to somehing very similer to what it's here: Dao It's a simple game called DAO and I just need to have a background image with 16 squares (4x4) and drag and drop the images (pieces) on each square to the others. I'm developing the interface using swing and I simply want to know a good place to find tutorials for such implementations or a simple suggestion on how to do it. Thanks in advance

    Read the article

  • Jframe using multiple classes?

    - by user2945880
    and im trying to make it so it can show multiple classes at once Jframe: import javax.swing.JFrame; import java.awt.BorderLayout; public class Concert { public static void main(String[] args) { JFrame frame = new JFrame(); frame.setSize(1000, 800); frame.setTitle("Concert!"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Concertbackground component = new Concertbackground(); BandComponent component1 = new BandComponent(); frame.add(component, BorderLayout.NORTH); frame.add(component1, BorderLayout.CENTER); frame.setVisible(true); } } These are the two classes mentioned in the Jframe: import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import javax.swing.JComponent; import java.awt.Polygon; /* BandComponent.java Justin Walker 10/27/13 */ public class BandComponent extends JComponent { public void paintComponent(Graphics g) { // Recover Graphics2D Graphics2D g2 = (Graphics2D) g; int xScale = 250; int yScale = 100; int x = 343; int y = 343; //singer Polygon sing = new Polygon(); sing.addPoint(667 ,208 + xScale); sing.addPoint(676,213 + xScale); sing.addPoint(678,217 + xScale); sing.addPoint(682,221 + xScale); sing.addPoint(681,224 + xScale); sing.addPoint(680,231 + xScale); sing.addPoint(676,242 + xScale); sing.addPoint(672,244 + xScale); sing.addPoint(672,250 + xScale); sing.addPoint(682,248 + xScale); sing.addPoint(713,244 + xScale); sing.addPoint(734,247 + xScale); sing.addPoint(750,247 + xScale); sing.addPoint(794,232 + xScale); sing.addPoint(800,231 + xScale); sing.addPoint(801,223 + xScale); sing.addPoint(807,219 + xScale); sing.addPoint(806,221 + xScale); sing.addPoint(806,229 + xScale); sing.addPoint(818,222 + xScale); sing.addPoint(820,223 + xScale); sing.addPoint(825,227 + xScale); sing.addPoint(825,240 + xScale); sing.addPoint(817,243 + xScale); sing.addPoint(807,245 + xScale); sing.addPoint(803,247 + xScale); sing.addPoint(801,252 + xScale); sing.addPoint(781,257 + xScale); sing.addPoint(762,264 + xScale); sing.addPoint(734,271 + xScale); sing.addPoint(701,286 + xScale); sing.addPoint(691,296 + xScale); sing.addPoint(693,311 + xScale); sing.addPoint(690,317 + xScale); sing.addPoint(690,335 + xScale); sing.addPoint(691,339 + xScale); sing.addPoint(689,343 + xScale); sing.addPoint(712,382 + xScale); sing.addPoint(725,400 + xScale); sing.addPoint(731,418 + xScale); sing.addPoint(731,428 + xScale); sing.addPoint(738,454 + xScale); sing.addPoint(741,460 + xScale); sing.addPoint(746,468 + xScale); sing.addPoint(766,468 + xScale); sing.addPoint(771,481 + xScale);// sing.addPoint(723,482 + xScale); sing.addPoint(720,462 + xScale); sing.addPoint(718,454 + xScale); sing.addPoint(709,436 + xScale); sing.addPoint(703,436 + xScale); sing.addPoint(699,417 + xScale); sing.addPoint(686,396 + xScale); sing.addPoint(678,395 + xScale); sing.addPoint(676,437 + xScale); sing.addPoint(673,439 + xScale); sing.addPoint(638,435 + xScale); sing.addPoint(640,398 + xScale); sing.addPoint(634,410 + xScale); sing.addPoint(625,416 + xScale); sing.addPoint(622,436 + xScale); sing.addPoint(622,443 + xScale); sing.addPoint(615,447 + xScale); sing.addPoint(609,456 + xScale); sing.addPoint(606,481 + xScale);// sing.addPoint(557,481 + xScale); sing.addPoint(560,467 + xScale); sing.addPoint(579,467 + xScale); sing.addPoint(587,464 + xScale); sing.addPoint(593,452 + xScale); sing.addPoint(594,441 + xScale); sing.addPoint(592,434 + xScale); sing.addPoint(600,416 + xScale); sing.addPoint(608,405 + xScale); sing.addPoint(609,394 + xScale); sing.addPoint(617,376 + xScale); sing.addPoint(619,363 + xScale); sing.addPoint(632,334 + xScale); sing.addPoint(637,324 + xScale); sing.addPoint(635,314 + xScale); sing.addPoint(639,296 + xScale); sing.addPoint(627,285 + xScale); sing.addPoint(600,279 + xScale); sing.addPoint(582,278 + xScale); sing.addPoint(575,275 + xScale); sing.addPoint(546,256 + xScale); sing.addPoint(536,252 + xScale); sing.addPoint(533,350 + xScale); sing.addPoint(534,361 + xScale); sing.addPoint(532,367 + xScale); sing.addPoint(529,369 + xScale); sing.addPoint(524,363 + xScale); sing.addPoint(525,355 + xScale); sing.addPoint(531,254 + xScale); sing.addPoint(527,249 + xScale); sing.addPoint(527,242 + xScale); sing.addPoint(529,237 + xScale); sing.addPoint(532,237 + xScale); sing.addPoint(536,178 + xScale); sing.addPoint(534,129 + xScale); sing.addPoint(535,123 + xScale); sing.addPoint(541,120 + xScale); sing.addPoint(545,123 + xScale); sing.addPoint(547,131 + xScale); sing.addPoint(545,173 + xScale); sing.addPoint(538,233 + xScale); sing.addPoint(549,239 + xScale); sing.addPoint(558,241 + xScale); sing.addPoint(585,257 + xScale); sing.addPoint(599,257 + xScale); sing.addPoint(627,254 + xScale); sing.addPoint(647,251 + xScale); sing.addPoint(653,248 + xScale); sing.addPoint(652,235 + xScale); sing.addPoint(648,226 + xScale); sing.addPoint(652,218 + xScale); sing.addPoint(661,212 + xScale); g2.setColor(Color.black); g2.fill(sing); g2.draw(sing); //guitar Polygon guitar = new Polygon(); guitar.addPoint(148,28); guitar.addPoint(158,32); guitar.addPoint(164,38); guitar.addPoint(168,46); guitar.addPoint(169,52); guitar.addPoint(167,60); guitar.addPoint(164,65); guitar.addPoint(165,70); guitar.addPoint(161,76); guitar.addPoint(158,92); guitar.addPoint(162,97); guitar.addPoint(161,102); guitar.addPoint(158,106); guitar.addPoint(155,108); guitar.addPoint(151,127); guitar.addPoint(152,133); guitar.addPoint(155,137); guitar.addPoint(151,146); guitar.addPoint(153,147); guitar.addPoint(160,142); guitar.addPoint(162,133); guitar.addPoint(162,123); guitar.addPoint(161,113); guitar.addPoint(162,110); guitar.addPoint(164,117); guitar.addPoint(169,131); guitar.addPoint(171,144); guitar.addPoint(170,159); guitar.addPoint(166,167); guitar.addPoint(166,171); guitar.addPoint(174,174); guitar.addPoint(183,184); guitar.addPoint(191,195); guitar.addPoint(196,198); guitar.addPoint(198,200); guitar.addPoint(199,210); guitar.addPoint(211,225); guitar.addPoint(212,233); guitar.addPoint(220,248); guitar.addPoint(233,260); guitar.addPoint(245,266); guitar.addPoint(248,268); guitar.addPoint(249,277); guitar.addPoint(205,275); guitar.addPoint(204,262); guitar.addPoint(187,238); guitar.addPoint(178,224); guitar.addPoint(177,216); guitar.addPoint(156,201); guitar.addPoint(146,197); guitar.addPoint(134,211); guitar.addPoint(128,229); guitar.addPoint(125,244);// guitar.addPoint(121,246); guitar.addPoint(107,248); guitar.addPoint(100,252); guitar.addPoint(97,258); guitar.addPoint(96,253); guitar.addPoint(89,258); guitar.addPoint(65,267); guitar.addPoint(63,274); guitar.addPoint(64,283); guitar.addPoint(41,282); guitar.addPoint(44,270); guitar.addPoint(47,264); guitar.addPoint(51,255); guitar.addPoint(73,238); guitar.addPoint(79,228); guitar.addPoint(97,222); guitar.addPoint(101,204); guitar.addPoint(102,181); guitar.addPoint(100,170); guitar.addPoint(95,161); guitar.addPoint(97,154); guitar.addPoint(91,152); guitar.addPoint(77,131); guitar.addPoint(65,123); guitar.addPoint(61,105); guitar.addPoint(64,94); guitar.addPoint(72,91); guitar.addPoint(78,82); guitar.addPoint(78,76); guitar.addPoint(70,73); guitar.addPoint(70,67); guitar.addPoint(93,51); guitar.addPoint(101,48); guitar.addPoint(111,52); guitar.addPoint(118,59); guitar.addPoint(119,70); guitar.addPoint(117,78); guitar.addPoint(113,79); guitar.addPoint(112,86); guitar.addPoint(111,88); guitar.addPoint(109,89); guitar.addPoint(109,92); guitar.addPoint(122,99);// guitar.addPoint(124,99); guitar.addPoint(133,96); guitar.addPoint(145,93); //guitar.addPoint(138,124); guitar.addPoint(150,69); guitar.addPoint(150,62); guitar.addPoint(155,58); guitar.addPoint(154,53); guitar.addPoint(149,50); guitar.addPoint(154,46); guitar.addPoint(153,38); guitar.addPoint(147,28); g2.setColor(Color.black); g2.fill(guitar); g2.draw(guitar); Polygon guitar2 = new Polygon (); guitar2.addPoint(141,108); guitar2.addPoint(139,126); guitar2.addPoint(135,122); guitar2.addPoint(128,122); guitar2.addPoint(129,116); guitar2.addPoint(143,108); g2.setColor(Color.white); g2.fill(guitar2); g2.draw(guitar2); //bass guitar Polygon bassgt = new Polygon (); bassgt.addPoint(871,21); bassgt.addPoint(879,24); bassgt.addPoint(885,32); bassgt.addPoint(886,42); bassgt.addPoint(895,47); bassgt.addPoint(904,56); bassgt.addPoint(907,69); bassgt.addPoint(909,83); bassgt.addPoint(910,91); bassgt.addPoint(941,81); bassgt.addPoint(946,75); bassgt.addPoint(945,67); bassgt.addPoint(950,67); bassgt.addPoint(955,75); bassgt.addPoint(960,68); bassgt.addPoint(963,74); bassgt.addPoint(967,72); bassgt.addPoint(971,66); bassgt.addPoint(973,70); bassgt.addPoint(981,67); bassgt.addPoint(984,71); bassgt.addPoint(982,76); bassgt.addPoint(987,80); bassgt.addPoint(986,82); bassgt.addPoint(980,83); bassgt.addPoint(979,90); bassgt.addPoint(974,85); bassgt.addPoint(970,86); bassgt.addPoint(973,91); bassgt.addPoint(965,86); bassgt.addPoint(960,90); bassgt.addPoint(961,100); bassgt.addPoint(955,92); bassgt.addPoint(944,91); bassgt.addPoint(907,103); bassgt.addPoint(906,109); bassgt.addPoint(893,114); bassgt.addPoint(895,123); bassgt.addPoint(900,131); bassgt.addPoint(904,134); bassgt.addPoint(908,145); bassgt.addPoint(911,159); bassgt.addPoint(918,171); bassgt.addPoint(919,190); bassgt.addPoint(923,198); bassgt.addPoint(919,201); bassgt.addPoint(919,210); bassgt.addPoint(927,220); bassgt.addPoint(942,226); bassgt.addPoint(944,234); bassgt.addPoint(909,230); bassgt.addPoint(905,214); bassgt.addPoint(899,204); bassgt.addPoint(893,203); bassgt.addPoint(889,171); bassgt.addPoint(877,151); bassgt.addPoint(861,152); bassgt.addPoint(852,169); bassgt.addPoint(849,203); bassgt.addPoint(841,210); bassgt.addPoint(840,228); bassgt.addPoint(828,233); bassgt.addPoint(806,235); bassgt.addPoint(805,228); bassgt.addPoint(822,219); bassgt.addPoint(824,204); bassgt.addPoint(817,201); bassgt.addPoint(822,196); bassgt.addPoint(822,184); bassgt.addPoint(828,162); bassgt.addPoint(829,152); bassgt.addPoint(820,149); bassgt.addPoint(811,144); bassgt.addPoint(806,134); bassgt.addPoint(805,117); bassgt.addPoint(820,107); bassgt.addPoint(819,89); bassgt.addPoint(811,83); bassgt.addPoint(811,77); bassgt.addPoint(824,66); bassgt.addPoint(825,61); bassgt.addPoint(842,53); bassgt.addPoint(852,43); bassgt.addPoint(853,29); bassgt.addPoint(870,20); g2.setColor(Color.black); g2.fill(bassgt); g2.draw(bassgt); Polygon bassgt2 = new Polygon(); bassgt2.addPoint(845,78); bassgt2.addPoint(845,98); bassgt2.addPoint(843,98); bassgt2.addPoint(842,105); bassgt2.addPoint(839,109); bassgt2.addPoint(834,103); bassgt2.addPoint(832,85); bassgt2.addPoint(845,78); g2.setColor(Color.white); g2.fill(bassgt2); g2.draw(bassgt2); Polygon drums = new Polygon (); drums.addPoint(713,104); drums.addPoint(706,121); drums.addPoint(721,377); drums.addPoint(248,380); drums.addPoint(253,228); drums.addPoint(250,206); drums.addPoint(237,178); drums.addPoint(206,166); drums.addPoint(201,154); drums.addPoint(198,152); drums.addPoint(208,148); drums.addPoint(236,150); drums.addPoint(247,130); drums.addPoint(227,119); drums.addPoint(219,105); drums.addPoint(222,96); drums.addPoint(233,88); drums.addPoint(251,84); drums.addPoint(272,83); drums.addPoint(300,91); drums.addPoint(285,72); drums.addPoint(294,57); drums.addPoint(319,46); drums.addPoint(372,45); drums.addPoint(406,50); drums.addPoint(428,65); drums.addPoint(433,74); drums.addPoint(450,58); drums.addPoint(478,48); drums.addPoint(514,48); drums.addPoint(544,51); drums.addPoint(566,52); drums.addPoint(577,67); drums.addPoint(575,79); drums.addPoint(561,95); drums.addPoint(545,98); drums.addPoint(525,105); drums.addPoint(524,147); drums.addPoint(524,183); drums.addPoint(645,175); drums.addPoint(662,143); drums.addPoint(617,152); drums.addPoint(608,148); drums.addPoint(614,139); drums.addPoint(633,128); drums.addPoint(661,116); drums.addPoint(659,107); drums.addPoint(625,114); drums.addPoint(592,113); drums.addPoint(571,111); drums.addPoint(565,102); drums.addPoint(576,86); drums.addPoint(616,70); drums.addPoint(647,66); drums.addPoint(679,67); drums.addPoint(695,72); drums.addPoint(699,90); drums.addPoint(678,100); drums.addPoint(667,103); drums.addPoint(672,113); drums.addPoint(689,105); drums.addPoint(709,106); g2.setColor(Color.black); g2.fill(drums); g2.draw(drums); } } The second class: import java.awt.Color; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.geom.Ellipse2D; import java.awt.geom.Line2D; import javax.swing.JComponent; import java.awt.GradientPaint; /* component that draws the concert background */ public class Concertbackground extends JComponent { public void paintComponent(Graphics g) { super.paintComponent(g); // Recover Graphics2D Graphics2D g2 = (Graphics2D) g; //Background Top g2.setColor(Color.BLUE); Rectangle backgroundTop = new Rectangle (0, 0, getWidth(), getHeight() / 4); g2.fill(backgroundTop); // Background bottom g2.setColor(Color.GREEN); Rectangle backgroundBottom = new Rectangle (0, getHeight() / 2, getWidth(), getHeight() / 2); g2.fill(backgroundBottom); // Speaker base g2.setColor(Color.BLACK); Rectangle base = new Rectangle (0, 0, 50, 100); g2.fill(base); // Speakers circles gray top g2.setColor(Color.DARK_GRAY); Ellipse2D.Double speakerTop = new Ellipse2D.Double(10, 10, 30, 30); g2.fill(speakerTop); //speakers circles black top g2.setColor(Color.BLACK); Ellipse2D.Double speakerTop1 = new Ellipse2D.Double(15, 15, 20, 20); g2.fill(speakerTop1); // Speakers circles gray bottom g2.setColor(Color.DARK_GRAY); Ellipse2D.Double speakerBottom = new Ellipse2D.Double(10, 50, 30, 30); g2.fill(speakerBottom); //speakers circles black bottom g2.setColor(Color.BLACK); Ellipse2D.Double speakerBottom1 = new Ellipse2D.Double(15, 55, 20, 20); g2.fill(speakerBottom1); } } My main question is how do I change my Jframe so it can use as many classes as I want, It cant be the size of my classes because they were used with the same 1000, 800 Jframe to make the classes. I also need to be able to add more than just these two classes to my Jframe.

    Read the article

  • Superclass Sensitive Actions

    - by Geertjan
    I've created a small piece of functionality that enables you to create actions for Java classes in the IDE. When the user right-clicks on a Java class, they will see one or more actions depending on the superclass of the selected class. To explain this visually, here I have "BlaTopComponent.java". I right-click on its node in the Projects window and I see "This is a TopComponent": Indeed, when you look at the source code of "BlaTopComponent.java", you'll see that it implements the TopComponent class. Next, in the screenshot below, you see that I have right-click a different class. In this case, there's an action available because the selected class implements the ActionListener class. Then, take a look at this one. Here both TopComponent and ActionListener are superclasses of the current class, hence both the actions are available to be invoked: Finally, here's a class that subclasses neither TopComponent nor ActionListener, hence neither of the actions that I created for doing something that relates to TopComponents or ActionListeners is available, since those actions are irrelevant in this context: How does this work? Well, it's a combination of my blog entries "Generic Node Popup Registration Solution" and "Showing an Action on a TopComponent Node". The cool part is that the definition of the two actions that you see above is remarkably trivial: import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JOptionPane; import org.openide.loaders.DataObject; import org.openide.util.Utilities; public class TopComponentSensitiveAction implements ActionListener { private final DataObject context; public TopComponentSensitiveAction() { context = Utilities.actionsGlobalContext().lookup(DataObject.class); } @Override public void actionPerformed(ActionEvent ev) { //Do something with the context: JOptionPane.showMessageDialog(null, "TopComponent: " + context.getNodeDelegate().getDisplayName()); } } The above is the action that will be available if you right-click a Java class that extends TopComponent. This, in turn, is the action that will be available if you right-click a Java class that implements ActionListener: import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JOptionPane; import org.openide.loaders.DataObject; import org.openide.util.Utilities; public class ActionListenerSensitiveAction implements ActionListener { private final DataObject context; public ActionListenerSensitiveAction() { context = Utilities.actionsGlobalContext().lookup(DataObject.class); } @Override public void actionPerformed(ActionEvent ev) { //Do something with the context: JOptionPane.showMessageDialog(null, "ActionListener: " + context.getNodeDelegate().getDisplayName()); } } Indeed, the classes, at this stage are the same. But, depending on what I want to do with TopComponents or ActionListeners, I now have a starting point, which includes access to the DataObject, from where I can get down into the source code, as shown here. This is how the two ActionListeners that you see defined above are registered in the layer, which could ultimately be done via annotations on the ActionListeners, of course: <folder name="Actions"> <folder name="Tools"> <file name="org-netbeans-sbas-impl-TopComponentSensitiveAction.instance"> <attr stringvalue="This is a TopComponent" name="displayName"/> <attr name="instanceCreate" methodvalue="org.netbeans.sbas.SuperclassSensitiveAction.create"/> <attr name="type" stringvalue="org.openide.windows.TopComponent"/> <attr name="delegate" newvalue="org.netbeans.sbas.impl.TopComponentSensitiveAction"/> </file> <file name="org-netbeans-sbas-impl-ActionListenerSensitiveAction.instance"> <attr stringvalue="This is an ActionListener" name="displayName"/> <attr name="instanceCreate" methodvalue="org.netbeans.sbas.SuperclassSensitiveAction.create"/> <attr name="type" stringvalue="java.awt.event.ActionListener"/> <attr name="delegate" newvalue="org.netbeans.sbas.impl.ActionListenerSensitiveAction"/> </file> </folder> </folder> <folder name="Loaders"> <folder name="text"> <folder name="x-java"> <folder name="Actions"> <file name="org-netbeans-sbas-impl-TopComponentSensitiveAction.shadow"> <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-sbas-impl-TopComponentSensitiveAction.instance"/> <attr intvalue="150" name="position"/> </file> <file name="org-netbeans-sbas-impl-ActionListenerSensitiveAction.shadow"> <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-sbas-impl-ActionListenerSensitiveAction.instance"/> <attr intvalue="160" name="position"/> </file> </folder> </folder> </folder> </folder> The most important parts of the layer registration are the lines that are highlighted above. Those lines connect the layer to the generic action that delegates back to the action listeners defined above, as follows: public final class SuperclassSensitiveAction extends AbstractAction implements ContextAwareAction { private final Map map; //This method is called from the layer, via "instanceCreate", //magically receiving a map, which contains all the attributes //that are defined in the layer for the file: static SuperclassSensitiveAction create(Map map) { return new SuperclassSensitiveAction(Utilities.actionsGlobalContext(), map); } public SuperclassSensitiveAction(Lookup context, Map m) { super(m.get("displayName").toString()); this.map = m; String superclass = m.get("type").toString(); //Enable the menu item only if //we're dealing with a class of type superclass: JavaSource javaSource = JavaSource.forFileObject( context.lookup(DataObject.class).getPrimaryFile()); try { javaSource.runUserActionTask(new ScanTask(this, superclass), true); } catch (IOException ex) { Exceptions.printStackTrace(ex); } //Hide the menu item if it isn't enabled: putValue(DynamicMenuContent.HIDE_WHEN_DISABLED, true); } @Override public void actionPerformed(ActionEvent ev) { ActionListener delegatedAction = (ActionListener)map.get("delegate"); delegatedAction.actionPerformed(ev); } @Override public Action createContextAwareInstance(Lookup actionContext) { return new SuperclassSensitiveAction(actionContext, map); } private class ScanTask implements Task<CompilationController> { private SuperclassSensitiveAction action = null; private String superclass; private ScanTask(SuperclassSensitiveAction action, String superclass) { this.action = action; this.superclass = superclass; } @Override public void run(final CompilationController info) throws Exception { info.toPhase(Phase.ELEMENTS_RESOLVED); new EnableIfGivenSuperclassMatches(info, action, superclass).scan( info.getCompilationUnit(), null); } } private static class EnableIfGivenSuperclassMatches extends TreePathScanner<Void, Void> { private CompilationInfo info; private final AbstractAction action; private final String superclassName; public EnableIfGivenSuperclassMatches(CompilationInfo info, AbstractAction action, String superclassName) { this.info = info; this.action = action; this.superclassName = superclassName; } @Override public Void visitClass(ClassTree t, Void v) { Element el = info.getTrees().getElement(getCurrentPath()); if (el != null) { TypeElement te = (TypeElement) el; List<? extends TypeMirror> interfaces = te.getInterfaces(); if (te.getSuperclass().toString().equals(superclassName)) { action.setEnabled(true); } else { action.setEnabled(false); } for (TypeMirror typeMirror : interfaces) { if (typeMirror.toString().equals(superclassName)){ action.setEnabled(true); } } } return null; } } } This is a pretty cool solution and, as you can see, very generic. Create a new ActionListener, register it in the layer so that it maps to the generic class above, and make sure to set the type attribute, which defines the superclass to which the action should be sensitive.

    Read the article

  • Using repaint() method.

    - by owca
    I'm still struggling to create this game : http://stackoverflow.com/questions/2844190/choosing-design-method-for-ladder-like-word-game .I've got it almost working but there is a problem though. When I'm inserting a word and it's correct, the whole window should reload, and JButtons containing letters should be repainted with different style. But somehow repaint() method for the game panel (in Main method) doesn't affect it at all. What am I doing wrong ? Here's my code: Main: import java.util.Scanner; import javax.swing.*; import java.awt.*; public class Main { public static void main(String[] args){ final JFrame f = new JFrame("Ladder Game"); Scanner sc = new Scanner(System.in); System.out.println("Creating game data..."); System.out.println("Height: "); //setting height of the grid while (!sc.hasNextInt()) { System.out.println("int, please!"); sc.next(); } final int height = sc.nextInt(); /* * I'm creating Grid[]game. Each row of game contains Grid of Element[]line. * Each row of line contains Elements, which are single letters in the game. */ Grid[]game = new Grid[height]; for(int L = 0; L < height; L++){ Grid row = null; int i = L+1; String s; do { System.out.println("Length "+i+", please!"); s = sc.next(); } while (s.length() != i); Element[] line = new Element[s.length()]; Element single = null; String[] temp = null; String[] temp2 = new String[s.length()]; temp = s.split(""); for( int j = temp2.length; j>0; j--){ temp2[j-1] = temp[j]; } for (int k = 0 ; k < temp2.length ; k++) { if( k == 0 ){ single = new Element(temp2[k], 2); } else{ single = new Element(temp2[k], 1); } line[k] = single; } row = new Grid(line); game[L] = row; } //############################################ //THE GAME STARTS HERE //############################################ //create new game panel with box layout JPanel panel = new JPanel(); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setBackground(Color.ORANGE); panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); //for each row of the game array add panel containing letters Single panel //is drawn with Grid's paint() method and then returned here to be added for(int i = 0; i < game.length; i++){ panel.add(game[i].paint()); } f.setContentPane(panel); f.pack(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); boolean end = false; boolean word = false; String text; /* * Game continues until solved() returns true. First check if given word matches the length, * and then the value of any row. If yes - change state of each letter from EMPTY * to OTHER_LETTER. Then repaint the window. */ while( !end ){ while( !word ){ text = JOptionPane.showInputDialog("Input word: "); for(int i = 1; i< game.length; i++){ if(game[i].equalLength(text)){ if(game[i].equalValue(text)){ game[i].changeState(3); f.repaint(); //simple debug - I'm checking if letter, and //state values for each Element are proper for(int k=0; k<=i; k++){ System.out.print(game[k].e[k].letter()); } System.out.println(); for(int k=0; k<=i; k++){ System.out.print(game[k].e[k].getState()); } System.out.println(); //set word to true and ask for another word word = true; } } } } word = false; //check if the game has ended for(int i = 0; i < game.length; i++){ if(game[i].solved()){ end = true; } else { end = false; } } } } } Element: import javax.swing.*; import java.awt.*; public class Element { final int INVISIBLE = 0; final int EMPTY = 1; final int FIRST_LETTER = 2; final int OTHER_LETTER = 3; private int state; private String letter; public Element(){ } //empty block public Element(int state){ this("", 0); } //filled block public Element(String s, int state){ this.state = state; this.letter = s; } public JButton paint(){ JButton button = null; if( state == EMPTY ){ button = new JButton(" "); button.setBackground(Color.WHITE); } else if ( state == FIRST_LETTER ){ button = new JButton(letter); button.setBackground(Color.red); } else { button = new JButton(letter); button.setBackground(Color.yellow); } return button; } public void changeState(int s){ state = s; } public void setLetter(String s){ letter = s; } public String letter(){ return letter; } public int getState(){ return state; } } Grid: import javax.swing.*; import java.awt.*; public class Grid extends JPanel{ public Element[]e; private Grid[]g; public Grid(){} public Grid( Element[]elements ){ e = new Element[elements.length]; for(int i=0; i< e.length; i++){ e[i] = elements[i]; } } public Grid(Grid[]grid){ g = new Grid[grid.length]; for(int i=0; i<g.length; i++){ g[i] = grid[i]; } Dimension d = new Dimension(600, 600); setMinimumSize(d); setPreferredSize(new Dimension(d)); setMaximumSize(d); } //for Each element in line - change state to i public void changeState(int i){ for(int j=0; j< e.length; j++){ e[j].changeState(3); } } //create panel which will be single row of the game. Add elements to the panel. // return JPanel to be added to grid. public JPanel paint(){ JPanel panel = new JPanel(); panel.setLayout(new GridLayout(1, e.length)); panel.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); for(int j = 0; j < e.length; j++){ panel.add(e[j].paint()); } return panel; } //check if the length of given string is equal to length of row public boolean equalLength(String s){ int len = s.length(); boolean equal = false; for(int j = 0; j < e.length; j++){ if(e.length == len){ equal = true; } } return equal; } //check if the value of given string is equal to values of elements in row public boolean equalValue(String s){ int len = s.length(); boolean equal = false; String[] temp = null; String[] temp2 = new String[len]; temp = s.split(""); for( int j = len; j>0; j--){ temp2[j-1] = temp[j]; } for(int j = 0; j < e.length; j++){ if( e[j].letter().equals(temp2[j]) ){ equal = true; } else { equal = false; } } if(equal){ for(int i = 0; i < e.length; i++){ e[i].changeState(3); } } return equal; } //check if the game has finished public boolean solved(){ boolean solved = false; for(int j = 0; j < e.length; j++){ if(e[j].getState() == 3){ solved = true; } else { solved = false; } } return solved; } }

    Read the article

  • Conflict between two Javascripts (MailChimp validation etc. scripts & jQuery hSlides.js)

    - by Brian
    I have two scripts running on the same page, one is the jQuery.hSlides.js script http://www.jesuscarrera.info/demos/hslides/ and the other is a custom script that is used for MailChimp list signup integration. The hSlides panel can be seen in effect here: http://theatricalbellydance.com. I've turned off the MailChimp script because it was conflicting with the hSlides script, causing it not to to fail completely (as seen here http://theatricalbellydance.com/home2/). Can someone tell me what could be done to the hSlides script to stop the conflict with the MailChimp script? The MailChimp Script var fnames = new Array(); var ftypes = new Array(); fnames[0] = 'EMAIL'; ftypes[0] = 'email'; fnames[3] = 'MMERGE3'; ftypes[3] = 'text'; fnames[1] = 'FNAME'; ftypes[1] = 'text'; fnames[2] = 'LNAME'; ftypes[2] = 'text'; fnames[4] = 'MMERGE4'; ftypes[4] = 'address'; fnames[6] = 'MMERGE6'; ftypes[6] = 'number'; fnames[9] = 'MMERGE9'; ftypes[9] = 'text'; fnames[5] = 'MMERGE5'; ftypes[5] = 'text'; fnames[7] = 'MMERGE7'; ftypes[7] = 'text'; fnames[8] = 'MMERGE8'; ftypes[8] = 'text'; fnames[10] = 'MMERGE10'; ftypes[10] = 'text'; fnames[11] = 'MMERGE11'; ftypes[11] = 'text'; fnames[12] = 'MMERGE12'; ftypes[12] = 'text'; var err_style = ''; try { err_style = mc_custom_error_style; } catch (e) { err_style = 'margin: 1em 0 0 0; padding: 1em 0.5em 0.5em 0.5em; background: rgb(255, 238, 238) none repeat scroll 0% 0%; font-weight: bold; float: left; z-index: 1; width: 80%; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial; color: rgb(255, 0, 0);'; } var mce_jQuery = jQuery.noConflict(); mce_jQuery(document).ready(function ($) { var options = { errorClass: 'mce_inline_error', errorElement: 'div', errorStyle: err_style, onkeyup: function () {}, onfocusout: function () {}, onblur: function () {} }; var mce_validator = mce_jQuery("#mc-embedded-subscribe-form").validate(options); options = { url: 'http://theatricalbellydance.us1.list-manage.com/subscribe/post-json?u=1d127e7630ced825cb1a8b5a9&id=9f12d2a6bb&c=?', type: 'GET', dataType: 'json', contentType: "application/json; charset=utf-8", beforeSubmit: function () { mce_jQuery('#mce_tmp_error_msg').remove(); mce_jQuery('.datefield', '#mc_embed_signup').each(function () { var txt = 'filled'; var fields = new Array(); var i = 0; mce_jQuery(':text', this).each(function () { fields[i] = this; i++; }); mce_jQuery(':hidden', this).each(function () { if (fields[0].value == 'MM' && fields[1].value == 'DD' && fields[2].value == 'YYYY') { this.value = ''; } else if (fields[0].value == '' && fields[1].value == '' && fields[2].value == '') { this.value = ''; } else { this.value = fields[0].value + '/' + fields[1].value + '/' + fields[2].value; } }); }); return mce_validator.form(); }, success: mce_success_cb }; mce_jQuery('#mc-embedded-subscribe-form').ajaxForm(options); }); function mce_success_cb(resp) { mce_jQuery('#mce-success-response').hide(); mce_jQuery('#mce-error-response').hide(); if (resp.result == "success") { mce_jQuery('#mce-' + resp.result + '-response').show(); mce_jQuery('#mce-' + resp.result + '-response').html(resp.msg); mce_jQuery('#mc-embedded-subscribe-form').each(function () { this.reset(); }); } else { var index = -1; var msg; try { var parts = resp.msg.split(' - ', 2); if (parts[1] == undefined) { msg = resp.msg; } else { i = parseInt(parts[0]); if (i.toString() == parts[0]) { index = parts[0]; msg = parts[1]; } else { index = -1; msg = resp.msg; } } } catch (e) { index = -1; msg = resp.msg; } try { if (index == -1) { mce_jQuery('#mce-' + resp.result + '-response').show(); mce_jQuery('#mce-' + resp.result + '-response').html(msg); } else { err_id = 'mce_tmp_error_msg'; html = '<div id="' + err_id + '" style="' + err_style + '"> ' + msg + '</div>'; var input_id = '#mc_embed_signup'; var f = mce_jQuery(input_id); if (ftypes[index] == 'address') { input_id = '#mce-' + fnames[index] + '-addr1'; f = mce_jQuery(input_id).parent().parent().get(0); } else if (ftypes[index] == 'date') { input_id = '#mce-' + fnames[index] + '-month'; f = mce_jQuery(input_id).parent().parent().get(0); } else { input_id = '#mce-' + fnames[index]; f = mce_jQuery().parent(input_id).get(0); } if (f) { mce_jQuery(f).append(html); mce_jQuery(input_id).focus(); } else { mce_jQuery('#mce-' + resp.result + '-response').show(); mce_jQuery('#mce-' + resp.result + '-response').html(msg); } } } catch (e) { mce_jQuery('#mce-' + resp.result + '-response').show(); mce_jQuery('#mce-' + resp.result + '-response').html(msg); } } } The hslides script: /* * hSlides (1.0) // 2008.02.25 // <http://plugins.jquery.com/project/hslides> * * REQUIRES jQuery 1.2.3+ <http://jquery.com/> * * Copyright (c) 2008 TrafficBroker <http://www.trafficbroker.co.uk> * Licensed under GPL and MIT licenses * * hSlides is an horizontal accordion navigation, sliding the panels around to reveal one of interest. * * Sample Configuration: * // this is the minimum configuration needed * $('#accordion').hSlides({ * totalWidth: 730, * totalHeight: 140, * minPanelWidth: 87, * maxPanelWidth: 425 * }); * * Config Options: * // Required configuration * totalWidth: Total width of the accordion // default: 0 * totalHeight: Total height of the accordion // default: 0 * minPanelWidth: Minimum width of the panel (closed) // default: 0 * maxPanelWidth: Maximum width of the panel (opened) // default: 0 * // Optional configuration * midPanelWidth: Middle width of the panel (centered) // default: 0 * speed: Speed for the animation // default: 500 * easing: Easing effect for the animation. Other than 'swing' or 'linear' must be provided by plugin // default: 'swing' * sensitivity: Sensitivity threshold (must be 1 or higher) // default: 3 * interval: Milliseconds for onMouseOver polling interval // default: 100 * timeout: Milliseconds delay before onMouseOut // default: 300 * eventHandler: Event to open panels: click or hover. For the hover option requires hoverIntent plugin <http://cherne.net/brian/resources/jquery.hoverIntent.html> // default: 'click' * panelSelector: HTML element storing the panels // default: 'li' * activeClass: CSS class for the active panel // default: none * panelPositioning: Accordion panelPositioning: top -> first panel on the bottom and next on the top, other value -> first panel on the top and next to the bottom // default: 'top' * // Callback funtctions. Inside them, we can refer the panel with $(this). * onEnter: Funtion raised when the panel is activated. // default: none * onLeave: Funtion raised when the panel is deactivated. // default: none * * We can override the defaults with: * $.fn.hSlides.defaults.easing = 'easeOutCubic'; * * @param settings An object with configuration options * @author Jesus Carrera <[email protected]> */ (function($) { $.fn.hSlides = function(settings) { // override default configuration settings = $.extend({}, $.fn.hSlides.defaults, settings); // for each accordion return this.each(function(){ var wrapper = this; var panelLeft = 0; var panels = $(settings.panelSelector, wrapper); var panelPositioning = 1; if (settings.panelPositioning != 'top'){ panelLeft = ($(settings.panelSelector, wrapper).length - 1) * settings.minPanelWidth; panels = $(settings.panelSelector, wrapper).reverse(); panelPositioning = -1; } // necessary styles for the wrapper $(this).css('position', 'relative').css('overflow', 'hidden').css('width', settings.totalWidth).css('height', settings.totalHeight); // set the initial position of the panels var zIndex = 0; panels.each(function(){ // necessary styles for the panels $(this).css('position', 'absolute').css('left', panelLeft).css('zIndex', zIndex).css('height', settings.totalHeight).css('width', settings.maxPanelWidth); zIndex ++; // if this panel is the activated by default, set it as active and move the next (to show this one) if ($(this).hasClass(settings.activeClass)){ $.data($(this)[0], 'active', true); if (settings.panelPositioning != 'top'){ panelLeft = ($(settings.panelSelector, wrapper).index(this) + 1) * settings.minPanelWidth - settings.maxPanelWidth; }else{ panelLeft = panelLeft + settings.maxPanelWidth; } }else{ // check if we are centering and some panel is active // this is why we can't add/remove the active class in the callbacks: positioning the panels if we have one active if (settings.midPanelWidth && $(settings.panelSelector, wrapper).hasClass(settings.activeClass) == false){ panelLeft = panelLeft + settings.midPanelWidth * panelPositioning; }else{ panelLeft = panelLeft + settings.minPanelWidth * panelPositioning; } } }); // iterates through the panels setting the active and changing the position var movePanels = function(){ // index of the new active panel var activeIndex = $(settings.panelSelector, wrapper).index(this); // iterate all panels panels.each(function(){ // deactivate if is the active if ( $.data($(this)[0], 'active') == true ){ $.data($(this)[0], 'active', false); $(this).removeClass(settings.activeClass).each(settings.onLeave); } // set position of current panel var currentIndex = $(settings.panelSelector, wrapper).index(this); panelLeft = settings.minPanelWidth * currentIndex; // if the panel is next to the active, we need to add the opened width if ( (currentIndex * panelPositioning) > (activeIndex * panelPositioning)){ panelLeft = panelLeft + (settings.maxPanelWidth - settings.minPanelWidth) * panelPositioning; } // animate $(this).animate({left: panelLeft}, settings.speed, settings.easing); }); // activate the new active panel $.data($(this)[0], 'active', true); $(this).addClass(settings.activeClass).each(settings.onEnter); }; // center the panels if configured var centerPanels = function(){ var panelLeft = 0; if (settings.panelPositioning != 'top'){ panelLeft = ($(settings.panelSelector, wrapper).length - 1) * settings.minPanelWidth; } panels.each(function(){ $(this).removeClass(settings.activeClass).animate({left: panelLeft}, settings.speed, settings.easing); if ($.data($(this)[0], 'active') == true){ $.data($(this)[0], 'active', false); $(this).each(settings.onLeave); } panelLeft = panelLeft + settings.midPanelWidth * panelPositioning ; }); }; // event handling if(settings.eventHandler == 'click'){ $(settings.panelSelector, wrapper).click(movePanels); }else{ var configHoverPanel = { sensitivity: settings.sensitivity, interval: settings.interval, over: movePanels, timeout: settings.timeout, out: function() {} } var configHoverWrapper = { sensitivity: settings.sensitivity, interval: settings.interval, over: function() {}, timeout: settings.timeout, out: centerPanels } $(settings.panelSelector, wrapper).hoverIntent(configHoverPanel); if (settings.midPanelWidth != 0){ $(wrapper).hoverIntent(configHoverWrapper); } } }); }; // invert the order of the jQuery elements $.fn.reverse = function(){ return this.pushStack(this.get().reverse(), arguments); }; // default settings $.fn.hSlides.defaults = { totalWidth: 0, totalHeight: 0, minPanelWidth: 0, maxPanelWidth: 0, midPanelWidth: 0, speed: 500, easing: 'swing', sensitivity: 3, interval: 100, timeout: 300, eventHandler: 'click', panelSelector: 'li', activeClass: false, panelPositioning: 'top', onEnter: function() {}, onLeave: function() {} }; })(jQuery);

    Read the article

  • Java Framework Choice Question.

    - by Sarang
    We do have many frameworks available in Java. Struts, Swing, JSF 2.0, Spring etc are used as per their priority. Actually, I don't know how many they are as well! But, as I am fresher to Java, even learning after their architecture, I cannot decide which framework can be used with what type of Projects ! Also, I am confused with mixed use of framework like Spring + JSF. What is the benefit to it ? Another thing making me confusing is about the UI components available in market. Like, we do have Primefaces, Ice-faces, MyFaces, Rich-faces. They may or may not have been supporting AJAX in-built. They may contains some bugs as well. What is best choice for Framework + UI component that can directly provide a best feet solution for any project ?

    Read the article

  • Unidentified Window OnStartup

    - by CMP
    Every time I start up windows vista lately, I see a random floating window. It is a tiny little window with no title, and only the resize, maximize and restore buttons. I'd post an image, but I don't have reputation here yet. I can close it, and it does indeed go away, but I would love to figure out what it is and stop it from popping up at all. I used Autohotkey's window spy on it and all I learned is that it is a swing window, which doesn't help me out a whole lot. Is there a good way to identify which process it belongs to and figure out how to kill it?

    Read the article

  • How to remove buttons in AnythingSlider and stop the sliding?

    - by user244394
    I'm currently using the anythingSlider it works quite well. But if there is one li, how do i make it stop sliding and remove the buttons displayed below? The *li*s are generated from the database so sometimes there's only one. I want the buttons to show only when there is more then one image. if there is one image all the buttons( back, forward, pause) should not be displayed. Does anybody know of a way of stopping it sliding if there's only one li and removing the buttons when there is only one image. ===================================================================================== Thank You. Currently I have the working version, posted below the old code is working. I tried to replace it with yours it didnt seem to work. Is there something else that needs to be added? function formatText(index, panel) { return index + ""; } $(function () { $('.anythingSlider').anythingSlider({ easing: "easeInOutExpo", // Anything other than "linear" or "swing" requires the easing plugin autoPlay: true, // This turns off the entire FUNCTIONALY, not just if it starts running or not. delay: 7500, // How long between slide transitions in AutoPlay mode startStopped: false, // If autoPlay is on, this can force it to start stopped animationTime: 1250, // How long the slide transition takes hashTags: true, // Should links change the hashtag in the URL? buildNavigation: true, // If true, builds and list of anchor links to link to each slide pauseOnHover: true, // If true, and autoPlay is enabled, the show will pause on hover startText: "", // Start text stopText: "", // Start text navigationFormatter: formatText // Details at the top of the file on this use (advanced use) }); $("#slide-jump").click(function(){ $('.anythingSlider').anythingSlider(6); }); }); UPDATED WITH YOUR CODE : function formatText(index, panel) { return index + ""; } $(function () { var singleSlide = true, options = { autoPlay: false, // This turns off the entire FUNCTIONALY, not just if it starts running or not. buildNavigation: false, // If true, builds and list of anchor links to link to each slide easing: "easeInOutExpo", // Anything other than "linear" or "swing" requires the easing plugin delay: 3000, // How long between slide transitions in AutoPlay mode animationTime: 600, // How long the slide transition takes hashTags: true, // Should links change the hashtag in the URL? pauseOnHover: true, // If true, and autoPlay is enabled, the show will pause on hover navigationFormatter: formatText // Details at the top of the file on this use (advanced use) }; // Add player options if more than one slide exists if ( $('.anythingSlider div ul li').length 1 ) { $.extend(options, { autoPlay: true, startStopped: false, // If autoPlay is on, this can force it to start stopped startText: "", // Start text stopText: "", // Start text buildNavigation: true }); singleSlide = false; } // Initiate anythingSlider $("#slide-jump").click(function(){ $('.anythingSlider').anythingSlider(6); }); // hide anythingSlider navigation arrows if (singleSlide) { $('.anythingSlider a.arrow').hide(); } }); HTML TAGS ========================================================================================= Update May 25 ,2010 When using $('.anythingSlider').anythingSlider(options); instead of $('.anythingSlider').anythingSlider(6); the slider runs but I noticed that I get a Javascript Error :Object required is there anything else I need to pass? Since before anythingSlider was taking 6 instead of options, where do I pass that 6, since its looking for it.

    Read the article

  • How to make jQuery animate upwards

    - by ivannovak
    Hey there, I've got some jquery running fairly well, howeever when I hover over the element in question, the bottom expands downward which is not unexpected but is not the desired effect. I'd like the bottom of the element to remain stationary with the top of the element expanding upwards. If you'd like to see what I currently have, you may navigate to http://demo.ivannovak.com/mobia/ Any help would be greatly appreciated. Here is my code: HTML <div class="button"> <h3>Product Quality</h3> <div>Duis tristique ultricies velit sit amet adipiscing.</div> <img src="<?php bloginfo('template_url'); ?>/assets/img/INgravatar_subernova.png" alt="placeholderImage" height="70" /> <p><a href="#">Learn More &gt;</a></p> <div class="bottom"></div> </div> CSS div#buttons {} div#buttons .button { background: url(assets/img/bg_blue_top.jpg) #206094 no-repeat top left; padding: 5px 10px 0; width: 209px; float: left; margin-right: 5px; position: relative; height: 50px; } div#buttons .button h3 { font-weight: normal; color: #fff; text-transform: uppercase; } div#buttons .button:hover div, div#buttons .button:hover img { /* display: block; */ } div#buttons .button div { width: 120px; padding-right: 20px; float: left; color: #bbb; display: none; } div#buttons .button img { float: right; display: none; } div#buttons .button p { position: absolute; bottom: 10px; left: 10px; z-index: 9; font-weight: bold; text-transform: uppercase; } div#buttons .button p a { color: #7bc143; text-decoration: none; } div#buttons .button p a:hover { text-decoration: underline; } div#buttons .button .bottom { background: url(assets/img/bg_blue_bottom.jpg) no-repeat bottom left; height:26px; position: absolute; display: block; width: 229px; right: 0px; padding:0; bottom: 0; } jQuery $(document).ready(function() { $('.button').mouseenter(function() { $(this).closest('div').animate({ height: "150px", }, 400, "swing"); }); $('.button').mouseleave(function() { $(this).closest('div').animate({ height: "50px", }, 400, "swing"); }); });

    Read the article

  • Need a little help with sound in a JApplet

    - by jacob schuschel
    I am working on a solitaire game in Java, and i need to implement sound when the desk is shuffled, card flipped, etc. I used the following sites as reference to try and get it to work, but i am getting Null Pointer Exceptions or mishandled URL exception (depending on what i tweak). here Also, i am using netbeans 6.7.1 as my IDE. I will try to break down the code and explain: package cardgame; import java.applet.*; import java.util.logging.Level; import java.util.logging.Logger; import javax.swing.JApplet; import javax.swing.*; import java.io.*; import java.net.*; /** * * @author jacob */ public class Sound extends JApplet { private AudioClip song; // Sound player private String URL = null; private URL songPath; // Sound path /* *sound_1 = shuffling cards *sound_2 = to discard *sound_3 = from discard *sound_4 = cardflip 1 *sound_5 = cardflip 2 */ Sound(String filename) { try { songPath = new URL(getCodeBase(),filename); // Get the Sound URL } catch (MalformedURLException ex) { Logger.getLogger(Sound.class.getName()).log(Level.SEVERE, null, ex); } song = getAudioClip(songPath); // Load the Sound } Sound(int i) { URL = "./sounds/sound_" + i + ".wav"; System.out.println(URL); try { songPath = new URL(URL); // Get the Sound URL song = getAudioClip(songPath); } catch (MalformedURLException ex) { Logger.getLogger(Sound.class.getName()).log(Level.SEVERE, null, ex); } } public void playSound() { song.loop(); // Play } public void stopSound() { song.stop(); // Stop } public void playSoundOnce() { song.play(); // Play only once } } The 2 different construcors are for different ways i tried to implement this. The first one creates the filepath, and passes it in. The second one builds the filepath in the constructor, given a sound # (i made a list of what numbers correspond to what sound for reference). I am getting the followig errors out: ./sounds/sound_1.wav Nov 16, 2009 4:14:13 PM cardgame.Sound ./sounds/sound_2.wav SEVERE: null java.net.MalformedURLException: no protocol: ./sounds/sound_1.wav ./sounds/sound_3.wav at java.net.URL.(URL.java:583) at java.net.URL.(URL.java:480) at java.net.URL.(URL.java:429) ./sounds/sound_4.wav ./sounds/sound_5.wav at cardgame.Sound.(Sound.java:46) at cardgame.Game.loadSounds(Game.java:712) at cardgame.Game.(Game.java:62) at cardgame.Main.main(Main.java:25) Nov 16, 2009 4:14:13 PM cardgame.Sound SEVERE: null java.net.MalformedURLException: no protocol: ./sounds/sound_2.wav at java.net.URL.(URL.java:583) at java.net.URL.(URL.java:480) at java.net.URL.(URL.java:429) at cardgame.Sound.(Sound.java:46) at cardgame.Game.loadSounds(Game.java:712) at cardgame.Game.(Game.java:62) at cardgame.Main.main(Main.java:25) Nov 16, 2009 4:14:13 PM cardgame.Sound SEVERE: null java.net.MalformedURLException: no protocol: ./sounds/sound_3.wav at java.net.URL.(URL.java:583) at java.net.URL.(URL.java:480) at java.net.URL.(URL.java:429) at cardgame.Sound.(Sound.java:46) at cardgame.Game.loadSounds(Game.java:712) at cardgame.Game.(Game.java:62) at cardgame.Main.main(Main.java:25) Nov 16, 2009 4:14:13 PM cardgame.Sound SEVERE: null java.net.MalformedURLException: no protocol: ./sounds/sound_4.wav at java.net.URL.(URL.java:583) at java.net.URL.(URL.java:480) at java.net.URL.(URL.java:429) at cardgame.Sound.(Sound.java:46) at cardgame.Game.loadSounds(Game.java:712) at cardgame.Game.(Game.java:62) at cardgame.Main.main(Main.java:25) Nov 16, 2009 4:14:13 PM cardgame.Sound SEVERE: null java.net.MalformedURLException: no protocol: ./sounds/sound_5.wav at java.net.URL.(URL.java:583) at java.net.URL.(URL.java:480) at java.net.URL.(URL.java:429) at cardgame.Sound.(Sound.java:46) at cardgame.Game.loadSounds(Game.java:712) at cardgame.Game.(Game.java:62) at cardgame.Main.main(Main.java:25) Thanks for those who read and more thanks to those who help. I know it is somewhat long, but i would rather get it all out there, than have 50 questions that come back or have people not answer due to lack of initial info. also only lets me post a single link right now, so the links are given below dreamincode.net/forums/showtopic14083.htm stackoverflow.com/questions/512436/java-playing-wav-sounds deitel.com/articles/java_tutorials/20060422/LoadingPlayingAudioClips/index.html

    Read the article

  • Java Fx Data bind not working with File Read

    - by rjha94
    Hi I am using a very simple JavaFx client to upload files. I read the file in chunks of 1 MB (using Byte Buffer) and upload using multi part POST to a PHP script. I want to update the progress bar of my client to show progress after each chunk is uploaded. The calculations for upload progress look correct but the progress bar is not updated. I am using bind keyword. I am no JavaFx expert and I am hoping some one can point out my mistake. I am writing this client to fix the issues posted here (http://stackoverflow.com/questions/2447837/upload-1gb-files-using-chunking-in-php) /* * Main.fx * * Created on Mar 16, 2010, 1:58:32 PM */ package webgloo; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.layout.VBox; import javafx.geometry.VPos; import javafx.scene.control.Button; import javafx.scene.control.Label; import javafx.scene.layout.HBox; import javafx.scene.layout.LayoutInfo; import javafx.scene.text.Font; import javafx.scene.control.ProgressBar; import java.io.FileInputStream; /** * @author rajeev jha */ var totalBytes:Float = 1; var bytesWritten:Float = 0; var progressUpload:Float; var uploadURI = "http://www.test1.com/test/receiver.php"; var postMax = 1024000 ; function uploadFile(inputFile: java.io.File) { totalBytes = inputFile.length(); bytesWritten = 1; println("To-Upload - {totalBytes}"); var is = new FileInputStream(inputFile); var fc = is.getChannel(); //1 MB byte buffer var chunkCount = 0; var bb = java.nio.ByteBuffer.allocate(postMax); while(fc.read(bb) >= 0){ println("loop:start"); bb.flip(); var limit = bb.limit(); var bytes = GigaFileUploader.getBufferBytes(bb.array(), limit); var content = GigaFileUploader.createPostContent(inputFile.getName(), bytes); GigaFileUploader.upload(uploadURI, content); bytesWritten = bytesWritten + limit ; progressUpload = 1.0 * bytesWritten / totalBytes ; println("Progress is - {progressUpload}"); chunkCount++; bb.clear(); println("loop:end"); } } var label = Label { font: Font { size: 12 } text: bind "Uploaded - {bytesWritten * 100 / (totalBytes)}%" layoutInfo: LayoutInfo { vpos: VPos.CENTER maxWidth: 120 minWidth: 120 width: 120 height: 30 } } def jFileChooser = new javax.swing.JFileChooser(); jFileChooser.setApproveButtonText("Upload"); var button = Button { text: "Upload" layoutInfo: LayoutInfo { width: 100 height: 30 } action: function () { var outputFile = jFileChooser.showOpenDialog(null); if (outputFile == javax.swing.JFileChooser.APPROVE_OPTION) { uploadFile(jFileChooser.getSelectedFile()); } } } var hBox = HBox { spacing: 10 content: [label, button] } var progressBar = ProgressBar { progress: bind progressUpload layoutInfo: LayoutInfo { width: 240 height: 30 } } var vBox = VBox { spacing: 10 content: [hBox, progressBar] layoutX: 10 layoutY: 10 } Stage { title: "Upload File" width: 270 height: 120 scene: Scene { content: [vBox] } resizable: false }

    Read the article

  • [Java] Cannot draw pixels

    - by Wilhelm
    Hello everyone. I want to print each digit of pi number as a colored pixel, so, I get na input, with the pi number, then parse it into a list, each node containing a digit (I know, I'll use an array later), but I never get this painted to screen... Can someone help me to see where I'm wrong? package edu.pi.view; import java.awt.Graphics; import java.awt.Image; import java.awt.image.MemoryImageSource; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.ArrayList; import java.util.List; import javax.swing.JFrame; import javax.swing.JPanel; public class Main extends JPanel { private static final long serialVersionUID = 6416932054834995251L; private static int pixels[]; private static List<Integer> pi; public static void readFile(String name) { File file = new File(name); BufferedReader reader = null; pi = new ArrayList<Integer>(); char[] digits; try { reader = new BufferedReader(new FileReader(file)); String text = null; while((text = reader.readLine()) != null) { digits = text.toCharArray(); for(char el : digits) if(el != ' ') pi.add(Character.getNumericValue(el)); } } catch (Exception e) { e.printStackTrace(); } } public void paint(Graphics gg) { readFile("c:\\pi.txt"); int h = 5; int w = 2; int color = 0xffffff; int digit; int i = 0; pixels = new int[w * h]; for (int y = 0; y < h; y++) { for (int x = 0; x < h; x++) { digit = pi.get(i); if(digit == 0) color = 0x000000; else if(digit == 1) color = 0x787878; else if(digit == 2) color = 0x008B00; else if(digit == 3) color = 0x00008B; else if(digit == 4) color = 0x008B8B; else if(digit == 5) color = 0x008B00; else if(digit == 6) color = 0xCDCD00; else if(digit == 7) color = 0xFF4500; else if(digit == 8) color = 0x8B0000; else if(digit == 9) color = 0xFF0000; pixels[i] = color; i++; } } Image art = createImage(new MemoryImageSource(w, h, pixels, 0, w)); gg.drawImage(art, 0, 0, this); } public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().add(new Main()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setSize(300,300); frame.setVisible(true); } }

    Read the article

  • Ho to make Histogram Normalize and Equalize in java using JAI library?

    - by Jay
    I m making App in java using Swing component and JAI library. I make histogram of black and white or gray scale image.Is this method of making histogram correct? iif it is correct then how can i do normalization and Equalization of histogram in my App in java using JAI library?my code is below. in my code i make BufferedImage object and then make and plot histogram of that image . enter code here import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedImage; import java.io.IOException; import javax.media.jai.JAI; import javax.media.jai.PlanarImage; import javax.swing.*; public class FinalHistogram extends JPanel { static int[] bins = new int[256]; static int[] newBins = new int[256]; static int x1 = 0, y1 = 0; static PlanarImage image = JAI.create("fileload", "alp_finger.tiff"); static BufferedImage bi = image.getAsBufferedImage(); FinalHistogram(int[] pbins) { for (int i = 0; i < 256; i++) { bins[i] = pbins[i]; newBins[i] = 0; } repaint(); } @Override protected void paintComponent(Graphics g) { for (int i = 0; i < 256; i++) { g.drawLine(150 + i, 300, 150 + i, 300 - (bins[i] / 300)); if (i == 0 || i == 255) { String sr = new Integer((i)).toString(); g.drawString(sr, 150 + i, 305); } System.out.println("bin[" + i + "]===" + bins[i]); } } public static void main(String[] args) throws IOException { int[] sbins = new int[256]; int pixel = 0; int k = 0; for (int x = 0; x < bi.getWidth(); x++) { for (int y = 0; y < bi.getHeight(); y++) { pixel = bi.getRaster().getSample(x, y, 0); k = (int) (pixel / 256); sbins[k]++; //pixel = bi.getRGB(x, y) & 0x000000ff; //k=pixel; //int[] pixels = m_image.getRGB(0, 0, m_image.getWidth(), m_image.getHeight(), null, 0, m_image.getWidth()); //short currentValue = 0; //int red,green,blue; //for(int i = 0; i<pixels.length; i++){ //red = (pixels[i] >> 16) & 0x000000FF; //green = (pixels[i] >>8 ) & 0x000000FF; //blue = pixels[i] & 0x000000FF; //currentValue = (short)((red + green + blue) / 3); //Current value gives the average //Disregard the alpha //assert(currentValue >= 0 && currentValue <= 255); //Something is awfully wrong if this goes off... //m_histogramArray[currentValue] += 1; //Increment the specific value of the array //} } } JTabbedPane jtp = new JTabbedPane(); jtp.addTab("Histogram", new JScrollPane(new FinalHistogram(sbins))); JFrame frame = new JFrame(); frame.setSize(500, 500); frame.add(new JScrollPane(jtp)); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }

    Read the article

  • Problem with sending out variable to serial port using api JAVA

    - by sjaakensjon
    We are developing a java program for school. But we are experiencing problems with sending out a variable created by 3 sliders. The idea is that we have 3 sliders. One slider for every color. Red green and blue. The variable has to have a value between 0 and 255. Everytime the value of the slider changes is has to send a variable for the channel, that value is 1, 2 ,3. And after that it has to send the value of the slider through the serial port. Could you please help us out by creating an example program? Below is our code so far. Thanks in advance. Sjaak package main; import javax.swing.*; import javax.swing.event.*; import java.awt.*; import app.Com; import app.Parameters; public class menu{ JSlider sliderblauw; JLabel hoeveelblauw; JLabel blauw; JLabel rood; JSlider sliderrood; JLabel hoeveelrood; JLabel groen; JLabel hoeveelgroen; JSlider slidergroen; public menu(){ Frame venster = new JFrame("Color control"); JPanel blauwinstel = new JPanel(); ((JFrame) venster).setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); venster.setSize(500, 500); venster.setVisible(true); sliderblauw = new JSlider(JSlider.VERTICAL, 0, 255, 0); sliderblauw.addChangeListener(new veranderingblauw()); hoeveelblauw = new JLabel ("0"); blauwinstel.add(sliderblauw); blauwinstel.add(hoeveelblauw); venster.add(blauwinstel, BorderLayout.WEST); sliderblauw.setMajorTickSpacing(10); sliderblauw.setPaintTicks(true); JPanel roodinstel = new JPanel(); sliderrood = new JSlider(JSlider.VERTICAL, 0, 255, 0); sliderrood.addChangeListener(new veranderingrood()); hoeveelrood = new JLabel ("0"); roodinstel.add(sliderrood); roodinstel.add(hoeveelrood); venster.add(roodinstel, BorderLayout.EAST); sliderrood.setMajorTickSpacing(10); sliderrood.setPaintTicks(true); JPanel groeninstel = new JPanel(); slidergroen = new JSlider(JSlider.VERTICAL, 0, 255, 0); slidergroen.addChangeListener(new veranderinggroen()); hoeveelgroen = new JLabel ("0"); groeninstel.add(slidergroen); groeninstel.add(hoeveelgroen); venster.add(groeninstel, BorderLayout.CENTER); slidergroen.setMajorTickSpacing(10); slidergroen.setPaintTicks(true); } public class veranderingblauw implements ChangeListener{ public void stateChanged(ChangeEvent ce){ int value = sliderblauw.getValue(); String waarde_blauw = Integer.toString(value); hoeveelblauw.setText(waarde_blauw); }} public class veranderingrood implements ChangeListener{ public void stateChanged(ChangeEvent ce){ int value = sliderrood.getValue(); String waarde_rood = Integer.toString(value); hoeveelrood.setText(waarde_rood); }} public class veranderinggroen implements ChangeListener{ public void stateChanged(ChangeEvent ce){ int value = slidergroen.getValue(); String waarde_groen = Integer.toString(value); hoeveelgroen.setText(waarde_groen); }} public static void main( String[] args) { new menu(); } }

    Read the article

  • Arduino IDE not connecting to microcontroller

    - by JDD
    I get this error when trying to connect to an Arduino through a USB serial connection. I'm using the Arduino IDE 1.0.1 and the 64bit version of Ubuntu 12.04. This has been a reoccurring problem since 10.04 and happens to a few other programs that use a serial connection too. I have no problem getting serial data from the Arduino using Python or Screen. The Arduino IDE seems to work just fine otherwise. processing.app.SerialException: Error opening serial port '/dev/ttyACM0'. at processing.app.Serial.<init>(Serial.java:178) at processing.app.Serial.<init>(Serial.java:92) at processing.app.SerialMonitor.openSerialPort(SerialMonitor.java:207) at processing.app.Editor.handleSerial(Editor.java:2447) at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:353) at java.awt.Component.processMouseEvent(Component.java:6386) at javax.swing.JComponent.processMouseEvent(JComponent.java:3268) at java.awt.Component.processEvent(Component.java:6154) at java.awt.Container.processEvent(Container.java:2045) at java.awt.Component.dispatchEventImpl(Component.java:4750) at java.awt.Container.dispatchEventImpl(Container.java:2103) at java.awt.Component.dispatchEvent(Component.java:4576) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4294) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227) at java.awt.Container.dispatchEventImpl(Container.java:2089) at java.awt.Window.dispatchEventImpl(Window.java:2518) at java.awt.Component.dispatchEvent(Component.java:4576) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672) at java.awt.EventQueue.access$400(EventQueue.java:96) at java.awt.EventQueue$2.run(EventQueue.java:631) at java.awt.EventQueue$2.run(EventQueue.java:629) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116) at java.awt.EventQueue$3.run(EventQueue.java:645) at java.awt.EventQueue$3.run(EventQueue.java:643) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105) at java.awt.EventQueue.dispatchEvent(EventQueue.java:642) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177) at java.awt.EventDispatchThread.run(EventDispatchThread.java:138) Caused by: gnu.io.UnsupportedCommOperationException: Invalid Parameter at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:171) at processing.app.Serial.<init>(Serial.java:163) ... 35 more

    Read the article

  • Oracle Cloud Solutions at Cloud Expo West

    - by Gene Eun
    Oracle is proud to be the Platinum Sponsor at next week's Cloud Expo West in Santa Clara (Nov 4-7).  This is the third consecutive year that Oracle has been sponsoring Cloud Expo and each year our involvement and presence at the conference has grown. This year, we have a great lineup of sessions which I've listed below. If you’re attending Cloud Expo West, we'd love to have you attend our sessions that will show our thought leadership and leading solutions in the cloud. You should also swing by Booth #130 to see some of our latest cloud offerings firsthand. Date  Time  Session Title  Track  Room  Monday, Nov 4  3:00 pm - 3:45 pm Ten Myths of Cloud Computing - General Session All Tracks Ballroom A-H  Monday, Nov 4  5:10 pm - 5:55 pm Driving Recurring Revenue Streams Through Cloud Billing Cloud Computing and Big Data M1  Monday, Nov 4  5:10 pm - 5:55 pm An Introduction to Oracle's Cloud Application Marketplace Cloud Bootcamp Great America Room J  Tuesday, Nov 5  6:25 pm - 7:05 pm Delivering Database as a Service with Oracle Database 12c Deploying the Cloud Great America Room 2  Wednesday, Nov 6  5:35 pm - 6:20 pm Accelerating Your Journey to Self-Service IT Enterprise Cloud Computing B2  Thursday, Nov 7  1:35 pm - 2:20 pm Oracle's Strategy for Public Cloud Platform and Infrastructure Services Infrastructure Management | Virtualization M2 At Cloud Expo West, you'll get to learn about and experience the latest in Cloud and Big Data. If you're in Silicon Valley or the Bay Area and don't have a pass to Cloud Expo, no problem. Oracle is giving away FREE VIP Gold Passes! We would love to have you be our VIP guest. Just go to Oracle's Cloud Expo 2013 event registration page and follow the instructions to get your complimentary pass. Stay tuned to this blog and follow us on Twitter (@OracleCloudZone) during and after Cloud Expo for more of our insight and observations about this year's conference.

    Read the article

< Previous Page | 46 47 48 49 50 51 52 53 54 55 56 57  | Next Page >