Search Results

Search found 1156 results on 47 pages for 'roman'.

Page 16/47 | < Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >

  • How to exit an if clause

    - by Roman Stolper
    What sorts of methods exist for prematurely exiting an if clause? There are times when I'm writing code and want to put a break statement inside of an if clause, only to remember that those can only be used for loops. Lets take the following code as an example: if some_condition: ... if condition_a: # do something # and then exit the outer if block ... if condition_b: # do something # and then exit the outer if block # more code here I can think of one way to do this: assuming the exit cases happen within nested if statements, wrap the remaining code in a big else block. Example: if some_condition: ... if condition_a: # do something # and then exit the outer if block else: ... if condition_b: # do something # and then exit the outer if block else: # more code here The problem with this is that more exit locations mean more nesting/indented code. Alternatively, I could write my code to have the if clauses be as small as possible and not require any exits. Does anyone know of a good/better way to exit an if clause? If there are any associated else-if and else clauses, I figure that exiting would skip over them.

    Read the article

  • When should I use Dependency Injection and when utility methods?

    - by Roman
    I have a Java EE project with Spring IoC container. I've just found in Utils class static method sendMail(long list of params). I don't know why but I feel that it would look better if we had separate class (Spring bean with singleton scope) which will be responsible for sending email. But I can't find any arguments which can prove my position. So, are there any pros (or cons) in using DI in this (rather general) situation?

    Read the article

  • How should I read from a buffered reader?

    - by Roman
    I have the following example of reading from a buffered reader: while ((inputLine = input.readLine()) != null) { System.out.println("I got a message from a client: " + inputLine); } The code in the loop println will be executed whenever something appears in the buffered reader (input in this case). In my case, if a client-application writes something to the socket, the code in the loop (in the server-application) will be executed. But I do not understand how it works. inputLine = input.readLine() waits until something appears in the buffered reader and when something appears there it returns true and the code in the loop is executed. But when null can be returned. There is another question. The above code was taken from a method which throws Exception and I use this code in the run method of the Thread. And when I try to put throws Exception before the run the compiler complains: overridden method does not throw exception. Without the throws exception I have another complain from the compiler: unreported exception. So, what can I do?

    Read the article

  • Can I fix the width of JRadioButton?

    - by Roman
    I have sever JPanels which have to be ordered vertically. For that I want to fix the width of the JPanels. Because if they are too short in comparison with the windows width, they will go horizontally (one after another) and I do not want it. At the moment the width of the JPanel is not constant because the width of the JRadioButton (included into JPabel) is not constant. How can I make the width of the JRadioButton constant? At the moment it is not constant because of the label (which can be different).

    Read the article

  • Why does this break statement break not work?

    - by Roman
    I have the following code: public void post(String message) { final String mess = message; (new Thread() { public void run() { while (true) { try { if (status.equals("serviceResolved")) { output.println(mess); Game.log.fine("The following message was successfully sent: " + mess); break; } else { try {Thread.sleep(1000);} catch (InterruptedException ie) {} } } catch (NullPointerException e) { try {Thread.sleep(1000);} catch (InterruptedException ie) {} } } } }).start(); } In my log file I find a lot of lines like this: The following message was successfully sent: blablabla The following message was successfully sent: blablabla The following message was successfully sent: blablabla The following message was successfully sent: blablabla And my program is not responding. It seems to me that the break command does not work. What can be a possible reason for that. The interesting thing is that it happens not all the time. Sometimes my program works fine, sometimes the above described problem happens.

    Read the article

  • Why setPreferredSize does not change the size of the button?

    - by Roman
    Here is the code: import javax.swing.*; import java.awt.event.*; import java.awt.*; public class TestGrid { public static void main(String[] args) { JFrame frame = new JFrame("Colored Trails"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel mainPanel = new JPanel(); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS)); JPanel panel = new JPanel(); panel.setLayout(new GridLayout(4, 9)); panel.setMaximumSize(new Dimension(9*30-20,4*30)); JButton btn; for (int i=1; i<=4; i++) { for (int j=1; j<=4; j++) { btn = new JButton(); btn.setPreferredSize(new Dimension(30, 30)); panel.add(btn); } btn = new JButton(); btn.setPreferredSize(new Dimension(30, 10)); panel.add(btn); for (int j=1; j<=4; j++) { btn = new JButton(); btn.setPreferredSize(new Dimension(30, 30)); panel.add(btn); } } mainPanel.add(panel); frame.add(mainPanel); frame.setSize(450,950); frame.setVisible(true); } } I suppose to have a table of buttons with 4 rows and 9 columns. And the middle column should be narrower that other columns. I tried Dimension(30, 10) and Dimension(30, 10) both have no effect on the width of the middle column. Why?

    Read the article

  • Why does my JButton look differently of different computers?

    - by Roman
    I use JButtons in my application. They need to have different colors. First I used that btn.setBackground(col);. It works on my computer and on another computer my button just gray (not red, as it's supposed to be). Trying to solve this problem I decided to use images. I do it in the following way: tmp = new JButton(newIcon); Again, it works fine on my computer and on another computer I see just gray buttons. Does anybody have any ideas what can be the reason of the problem and how it can be solved? I heard it can be related to "look-and-feel of the native system". But I do not know what it means and what should I do if it is the case? Can anybody pleas, help me with that?

    Read the article

  • Why encodeXxx methods in UIComponent accept FacesContext parameter?

    - by Roman
    I haven't ever before created custom component in jsf so I've noticed it only now that methods like encodeBegin(), encodeEnd() etc accept FacesContext parameter. FacesContext instance can usually be received with FacesContext.getCurrentInstance(). So, I wonder whether these methods have FacesContext parameter just for convenience or some different objects can be passed there (maybe from external resources..). If the latter is possible then could you give an example pls.

    Read the article

  • How to find an available port?

    - by Roman
    I want to start a server which listen to a port. I can specify port explicitly and it works. But I would like to find a port in an automatic way. In this respect I have two questions. In which range of port numbers should I search for? (I used ports 12345, 12346, and 12347 and it was fine). How can I find out if a given port is not occupied by another software?

    Read the article

  • executing a script from maven inside a multi module project

    - by Roman
    Hi everyone. I have this multi-module project. In the beginning of each build I would like to run some bat file. So i did the following: <profile> <id>deploy-db</id> <build> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1.1</version> </plugin> </plugins> <pluginManagement> <plugins> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.1.1</version> <executions> <execution> <phase>validate</phase> <goals> <goal>exec</goal> </goals> <inherited>false</inherited> </execution> </executions> <configuration> <executable>../database/schemas/import_databases.bat</executable> </configuration> </plugin> </plugins> </pluginManagement> </build> </profile> when i run the mvn verify -Pdeploy-db from the root I get this script executed over and over again in each of my modules. I want it to be executed only once, in the root module. What is there that I am missing ? Thanks

    Read the article

  • Which language should I use to program a GUI application?

    - by Roman
    I would like to write a GUI application for management of information (text documents). In more details, it should be similar to the TiddlyWiki. I would like to have there some good visual effects (like nice representation for three structures, which you can rotate, some sound). I also would like to include some communication via Internet (for sharing and collaboration). In should include some features of such applications as a web browser, word processor, Skype. Which programming language should I use? I like the idea of usage of JavaScripts (like TddlyWiki). The good thing about that, is that user should not install anything. They open a file in a browser and it works! The bad thing is that JavaScript cannot communicate via internet with other applications. I think the choice of the programming language, in my case, id conditioned by 2 things: What can be done with this programming language (which restrictions are there). How easy to program. I would like to have "block" which can do a lot of things (rather than to program then and, in this way, to "rediscover a bicycle") ADDED: I would like to make it platform independent.

    Read the article

  • Suppressing "extra ';'" error in GCC when -pedantic is on

    - by Roman D
    Hi all, I'm building my program with -pedantic flag, which causes an extra ';' error (because of a third-party header using a few macros inconsistently; the error is not shown when -pedantic is off). I don't really feel like turning -pedantic off, and neither do I want to edit the header. Is there any way to suppress this exact error? Like a -Wno-annoying-semicolon-error compiler switch or something?

    Read the article

  • Fun with Lambdas

    - by Roman A. Taycher
    Not having them used them all that much I'm not quite sure all that lambdas/blocks can be used for (other than map/collect/do/lightweight local function syntax). If some people could post some interesting but somewhat understandable examples (with explanation). preferred languages for examples: python, smalltalk, haskell

    Read the article

  • How do you use kate? Tips/Tricks/Workflow

    - by Roman A. Taycher
    We all seen a bunch of these? Mostly for IDE's but also for vim and emacs. Kate is (only) a text editor (an awesome one) but it has a ton of options plus a number of plugins, so its hard to know all of it well. How do use the Kate text editor? Please share your workflow and help me and others learn some of the cool tricks you use. I'll start I use the built in terminal a lot opening files quickly, and using it as an enhanced haskell repl with ghci (since ghci doesn't allow you all to just put in all kinds of haskell code). Also use split views to quickly compare files (especially different versions of the same file). Also the auto-complete maybe simple(more use for saving typing time then remembering functions) but it works really well for that. Also if You highlight something and hit a start [/{/( it puts it in between brackets rather then replacing it with a bracket(why the hell do a lot of IDEs not have this feature).

    Read the article

  • Why facelets ignore href-attribute of a link when I use <a href="url" jsfc="h:outputLink"> ?

    - by Roman
    I have next facelet composition: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"> <body> <ui:composition> <ul id="navigation"> <li> <a href="http://google.com" id="google1" jsfc="h:outputLink">google.com</a> </li> <li> <h:outputLink id="google2" value="http://google.com"> <h:outputText id="outputtext" value="google.com"/> </h:outputLink> </li> </ul> </ui:composition> </body> </html> There must be a mistake because what I expected to see is almost the same final html-markup. But actually here is what facelets generated: <ul id="navigation"> <li><a id="google1" name="google1" href="">google.com</a></li> <li><a id="google2" name="google2" href="http://google.com"><span id="outputtext">google.com</span></a> </li> </ul> Why it ignored href attribute of the first link? What is the correct way to do what I'm trying to do? One more additional question: if I'm using jsfc everywhere I can then what should I do with components from f: namespace? Where should be <f:view> placed? Maybe in the template.xhtml? Or I should simply ignore it?

    Read the article

  • Why I do not see a static variable in a loop?

    - by Roman
    I have a static method which sets a variable: static String[] playersNames; public static void setParameters(String[] players) { playersNames = players; } Then I have a static block: static { JRadioButton option; ButtonGroup group = new ButtonGroup(); // Wright a short explanation of what the user should do. partnerSelectionPanel.add(new JLabel("Pleas select a partner:")); // Generate radio-buttons corresponding to the options available to the player. // Bellow is the problematic line causing the null pointer exception: for (String playerName: playersNames) { final String pn = playerName; option = new JRadioButton(playerName, false); option.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent evt) { partner = pn; } }); partnerSelectionPanel.add(option); group.add(option); } partnerSelectionPanel.add(label); // Add the "Submit" button to the end of the "form". JButton submitButton = new JButton("Submit"); submitButton.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent evt) { partnerSelected(); } }); partnerSelectionPanel.add(submitButton); } Compiler does not complain about anything but when I try to execute the code I get problems. In this place SelectPartnerGUI.setParameters(players); I have: Exception in thread "main" java.lang.ExceptionInitializerError. and it is cause by java.lang.NullpointerException at this place for (String playerName: playersNames). Does my program do not see the palyersNames?

    Read the article

  • Is it considered a good/bad practice to configure tomcat for deploying certain apps?

    - by Roman
    Disclaimer: I've never used technique which is described below. That's why there may occur some mistakes or misunderstandings in its description. I heard that some teams (developers) use 'pre-configured' tomcat. As I understand they add different jars to tomcat \lib folder and do something else. Once I've read something about recompilation (or reassembly?) of tomcat for certain needs. Just yesterday I heard a dialog where one developer sayd that his team-mates were not able to deploy the project until he would give them configured tomcat version. So, I wonder, what is it all about and why do they do it? What benefits can they gain from that?

    Read the article

  • Why do I get error "prefix [..] is not defined" when I try to use my jsf custom tag?

    - by Roman
    I created a jsf custom tag (I'm not sure that it's correct, I could miss something easily, so I attached code below). Now I'm trying to use this tag but I get an error: error on line 28 at column 49: Namespace prefix gc on ganttchart is not defined So, here is the xhtml-page: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:gc="http://myganttchart.org"> <body> <ui:composition template="/masterpage.xhtml"> <ui:define name="title">Gantt chart test</ui:define> <ui:define name="content"> <f:view> <gc:ganttchart width="300" height="100" rendered="true"/> ... </f:view> </ui:define> </ui:composition> </body> </html> And here is tld-file (it's placed in WEB-INF/): <taglib xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-jsptaglibrary_2_1.xsd" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.1"> <tlib-version> 1.0 </tlib-version> <short-name> oext </short-name> <uri> http://myganttchart.org </uri> <tag> <name>ganttchart</name> <tag-class>usermanagement.support.ganttchart.GanttChartTag</tag-class> <body-content>empty</body-content> <attribute> <name>binding</name> <deferred-value> <type>javax.faces.component.UIComponent</type> </deferred-value> </attribute> ... </tag> </tablib> Here is a part of tag-class code: public class GanttChartTag extends UIComponentELTag { private ValueExpression width; private ValueExpression height; private ValueExpression styleClass; public String getComponentType () { return "org.myganttchart"; } public String getRendererType () { return null; } ... } Correspondent block from faces-config: <component> <component-type>org.myganttchart</component-type> <component-class>usermanagement.support.ganttchart.UIGanttChart</component-class> </component> And the last part if UIGanttChart: public class UIGanttChart extends UIOutput { public UIGanttChart() { setRendererType (null); } //some test code public void encodeBegin(FacesContext context) throws IOException { ResponseWriter writer = context.getResponseWriter (); writer.startElement("img", this); writer.writeAttribute("src", "no-img", "source"); writer.writeAttribute("width", getAttributes ().get ("width"), "width"); writer.writeAttribute("height", getAttributes ().get ("height"), "height"); writer.writeAttribute("class", ".someclass", "styleClass"); writer.endElement("img"); } } So, what did I miss?

    Read the article

  • Does HashMap provide a one to one correspondence?

    - by Roman
    I found the following statement: Map is an object that stores key/volume pairs. Given a key, you can find its value. Keys must be unique, but values may be duplicated. For example I have just one key/value pair (3,4). And now I put a new pair (3,5). It will remove the old pair. Right? But if I put (2,4) instead of (3,4) I will add a new pair of key/value to the HashMap. Right?

    Read the article

  • What is the easiest way to read wav-files using Python [summary]?

    - by Roman
    I want to use Python to access a wav-file and write its content in a form which allows me to analyze it (let's say arrays). I heard that "audiolab" is a suitable tool for that (it transforms numpy arrays into wav and vica versa). I have installed the "audiolab" but I had a problem with the version of numpy (I could not "from numpy.testing import Tester"). I had 1.1.1. version of numpy. I have installed a newer version on numpy (1.4.0). But then I got a new set of errors: Traceback (most recent call last): File "test.py", line 7, in import scikits.audiolab File "/usr/lib/python2.5/site-packages/scikits/audiolab/init.py", line 25, in from pysndfile import formatinfo, sndfile File "/usr/lib/python2.5/site-packages/scikits/audiolab/pysndfile/init.py", line 1, in from _sndfile import Sndfile, Format, available_file_formats, available_encodings File "numpy.pxd", line 30, in scikits.audiolab.pysndfile._sndfile (scikits/audiolab/pysndfile/_sndfile.c:9632) ValueError: numpy.dtype does not appear to be the correct type object I gave up to use audiolab and thought that I can use "wave" package to read in a wav-file. I asked a question about that but people recommended to use scipy instead. OK, I decided to focus on scipy (I have 0.6.0. version). But when I tried to do the following: from scipy.io import wavfile x = wavfile.read('/usr/share/sounds/purple/receive.wav') I get the following: Traceback (most recent call last): File "test3.py", line 4, in <module> from scipy.io import wavfile File "/usr/lib/python2.5/site-packages/scipy/io/__init__.py", line 23, in <module> from numpy.testing import NumpyTest ImportError: cannot import name NumpyTest So, I gave up to use scipy. Can I use just wave package? I do not need much. I just need to have content of wav-file in human readable format and than I will figure out what to do with that.

    Read the article

  • How can I give a variable to an action listener?

    - by Roman
    I have a static variable partner in the class. And I want to set a value of these variable whenever a radio button is pressed. This is the code I tried to use: for (String playerName: players) { option = new JRadioButton(playerName, false); option.addActionListener(new ActionListener(){ @Override public void actionPerformed(ActionEvent evt) { partner = playerName; } }); partnerSelectionPanel.add(option); group.add(option); } The problem here is that the actionPerformed does not see the variable playerName created in the loop. How can I pass this variable to the actionListener?

    Read the article

  • How can I stop my application?

    - by Roman
    I have the main thread from which I start a window using invokeLater. I run my application from command line. So, when application is running I see the window and my command line is "blocked" by the application. I can stop the application either by closing the window (as a result the command line is unblocked) or by typing Ctrl-C in the command line (as a result the window disappear). I wanted to be able to stop the application by clicking on a button in the window of the application. I used setVisible(false) for that. But in this way I can achieve the goal only partially. My window really disappear but the command line is still blocked. So, the software is still running. Well, I assume it's because some other threads are still running. But how can I easily close all these threads (like I do by closing the window of the application manually).

    Read the article

< Previous Page | 12 13 14 15 16 17 18 19 20 21 22 23  | Next Page >