Search Results

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

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

  • Why my inner class DO see a NON static variable?

    - by Roman
    Earlier I had a problem when an inner anonymous class did not see a field of the "outer" class. I needed to make a final variable to make it visible to the inner class. Now I have an opposite situation. In the "outer" class "ClientListener" I use an inner class "Thread" and the "Thread" class I have the "run" method and does see the "earPort" from the "outer" class! Why? import java.io.IOException; import java.net.*; import java.io.BufferedReader; import java.io.InputStreamReader; public class ClientsListener { private int earPort; // Constructor. public ClientsListener(int earPort) { this.earPort = earPort; } public void starListening() { Thread inputStreamsGenerator = new Thread() { public void run() { System.out.println(earPort); try { System.out.println(earPort); ServerSocket listeningSocket = new ServerSocket(earPort); Socket serverSideSocket = listeningSocket.accept(); BufferedReader in = new BufferedReader(new InputStreamReader(serverSideSocket.getInputStream())); } catch (IOException e) { System.out.println(""); } } }; inputStreamsGenerator.start(); } }

    Read the article

  • Why SetMinimumSize sets the minimal heights but not width?

    - by Roman
    Here is my code: import javax.swing.*; import java.awt.*; public class PanelModel { 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 firstPanel = new JPanel(); firstPanel.setLayout(new GridLayout(4, 4)); firstPanel.setMaximumSize(new Dimension(4*100, 4*100)); firstPanel.setMinimumSize(new Dimension(4*100, 4*100)); JButton btn; for (int i=1; i<=4; i++) { for (int j=1; j<=4; j++) { btn = new JButton(); btn.setPreferredSize(new Dimension(100, 100)); firstPanel.add(btn); } } mainPanel.add(firstPanel); frame.add(mainPanel); frame.setSize(520,600); //frame.setMinimumSize(new Dimension(520,600)); frame.setVisible(true); } } When I increase the size of the window (by mouse) I see that my panel does not increase its size. It is the expected behavior (because I set the maximal size of the panel). However, when I decrease the size of the window, I see that width of the panel is decreased too (while the height is constant). So, the setMinimumSize works only partially. Why is that?

    Read the article

  • What is the relation between ContentPane and JPanel?

    - by Roman
    I found one example in which buttons are added to panels (instances of JPanel) then panels are added to the the containers (instances generated by getContentPane) and then containers are, by the construction, included into the JFrame (the windows). I tried two things: I got rid of the containers. In more details, I added buttons to a panel (instance of JPanel) and then I added the panel to the windows (instance of JFrame). It worked fine. I got rid of the panels. In more details, I added buttons directly to the container and then I added the container to the window (instance of JFrame). So, I do not understand two things. Why do we have two competing mechanism to do the same things. What is the reason to use containers in combination with the panels (JPanel)? (For example, what for we include buttons in JPanels and then we include JPanels in the Containers). Can we include JPanel in JPanel? Can we include a container in container?

    Read the article

  • What is "src" directory created by Eclipse?

    - by Roman
    I just installed Eclipse. The Eclipse created the "workspace" folder. In this folder I created a "game" sub-folder (for my class called "game"). I have already .java files for that project (I wrote them in a text editor before I started to use Eclipse). I put all my .java file into the "game" directory. In Eclipse I created a "New Java Project" from existing code. What wanders me is that the Eclipse create a "src" sub-folder into my "game" folder. As far as I understand "src" stands for "source". But my source (.java files) is in the "game" (by the construction). Am I doing something wrong?

    Read the article

  • Using ClrProfiler

    - by Roman Dorevich
    Hello, I am trying to use CLRProfiler. I need to enter some parameters, so I used the the File-set parameters option and added both parameters and the working directory. When the application starts it takes some parameters from a inifile but the clr fails to find parameters from the inifile cause it concrat it with the working directory. thanks

    Read the article

  • How a thread should close itself in Java?

    - by Roman
    This is a short question. At some point my thread understand that it should suicide. What is the best way to do it: Thread.currentThread().interrupt(); return; By the way, why in the first case we need to use currentThread? Is Thread does not refer to the current thread?

    Read the article

  • How to add an element to an array without a modification of the old array or creation a new one?

    - by Roman
    I have the following construction: for (String playerName: players). I would like to make a loop over all players plus one more special player. But I do not want to modify the players array by adding a new element to it. So, what can I do? Can I replace players in the for (String playerName: players) by something containing all elements of the players plus one more element?

    Read the article

  • Huge amount of time sending data with suds and proxy

    - by Roman
    Hi everyone, I have the following code to send data through a proxy using suds: import suds t = suds.transport.http.HttpTransport() proxy = urllib2.ProxyHandler({'http': 'http://192.168.3.217:3128'}) opener = urllib2.build_opener(proxy) t.urlopener = opener ws = suds.client.Client('http://xxxxxxx/web.asmx?WSDL', transport=t) req = ws.factory.create('ActionRequest.request') req.SerialNumber = 'asdf' req.HostName = 'hola' res = ws.service.ActionRequest(req) I don't know why, but it can be sending data above 2 or 3 minutes, or even more and it raises a "Gateway timeout" exception sometimes. If I don't use the proxy, the amount of time used is above 2 seconds or less. Here is the SOAP reply: (ActionResponse){ Id = None Action = "Action.None" Objects = "" } The proxy is running right with other requests through urllib2, or using normal web browsers like firefox. Does anyone have any idea what's happening here with suds? Thanks a lot in advance!!!

    Read the article

  • Are there any reasons to make all fields and variables final?

    - by Roman
    In my current project I noticed that all class fields and variable inside methods are declared with final modifier whenever it's possible. Just like here: private final XMLStreamWriter _xmlStreamWriter; private final Marshaller _marshaller; private final OutputStream _documentStream; private final OutputStream _stylesStream; private final XMLStreamWriter _stylesStreamWriter; private final StyleMerger _styleMerger; public DocumentWriter(PhysicalPackage physicalPackage) throws IOException { final Package pkg = new Package(physicalPackage); final Part wordDocumentPart = pkg.createPart( "/word/document.xml", "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"); // styles.xml final Pair<Part, String> wordStylesPart = wordDocumentPart.createRelatedPart(...); ... } Are there any reasons to do so? p.s. As I know project is not supposed to be multithreaded (at least I've heard nothing about it).

    Read the article

  • Samples of Scala and Java code where Scala code looks simpler/has fewer lines?

    - by Roman
    I need some code samples (and I also really curious about them) of Scala and Java code which show that Scala code is more simple and concise then code written in Java (of course both samples should solve the same problem). If there is only Scala sample with comment like "this is abstract factory in Scala, in Java it will look much more cumbersome" then this is also acceptable. Thanks!

    Read the article

  • What should I do if a IOException is thrown?

    - by Roman
    I have the following 3 lines of the code: ServerSocket listeningSocket = new ServerSocket(earPort); Socket serverSideSocket = listeningSocket.accept(); BufferedReader in = new BufferedReader(new InputStreamReader(serverSideSocket.getInputStream())); The compiler complains about all of these 3 lines and its complain is the same for all 3 lines: unreported exception java.io.IOException; In more details, these exception are thrown by new ServerSocket, accept() and getInputStream(). I know I need to use try ... catch .... But for that I need to know what this exceptions mean in every particular case (how should I interpret them). When they happen? I mean, not in general, but in these 3 particular cases.

    Read the article

  • Why my object sees variables which were not given to it in the constructor?

    - by Roman
    I have the following code. Which is "correct" and which I do not understand: private static void updateGUI(final int i, final JLabel label) { SwingUtilities.invokeLater( new Runnable() { public void run() { label.setText("You have " + i + " seconds."); } } ); } I create a new instance of the Runnable class and then in the run method of this instance I use variables label and i. It works, but I do not understand why it work. Why the considered object sees values of these variables. According to my understanding the code should look like that (and its wrong): private static void updateGUI(final int i, final JLabel label) { SwingUtilities.invokeLater(new Runnable(i,label) { public Runnable(int i, JLabel label) { this.i = i; this.label = label; } public void run() { label.setText("You have " + i + " seconds."); } }); } So, I would give the i and label variables to the constructor so the object can access them... By the way, in the updateGUI I use final before the i and label. I think I used final because compiler wanted that. But I do not understand why.

    Read the article

  • Are there any guarantees in JLS about order of execution static initialization blocks?

    - by Roman
    I wonder if it's reliable to use a construction like: private static final Map<String, String> engMessages; private static final Map<String, String> rusMessages; static { engMessages = new HashMap<String, String> () {{ put ("msgname", "value"); }}; rusMessages = new HashMap<String, String> () {{ put ("msgname", "????????"); }}; } private static Map<String, String> msgSource; static { msgSource = engMessages; } public static String msg (String msgName) { return msgSource.get (msgName); } Is there a possibility that I'll get NullPointerException because msgSource initialization block will be executed before the block which initializes engMessages? (about why don't I do msgSource initialization at the end of upper init. block: just the matter of taste; I'll do so if the described construction is unreliable)

    Read the article

  • How to use OpenCV in Python?

    - by Roman
    I have just installed OpenCV on my Windows 7 machine. As a result I get a new directory: C:\OpenCV2.2\Python2.7\Lib\site-packages In this directory I have two files: cv.lib and cv.pyd. Then I try to use the opencv from Python. I do the following: import sys sys.path.append('C:\OpenCV2.2\Python2.7\Lib\site-packages') import cv As a result I get the following error message: File "<stdin>", line 1, in <module> ImportError: DLL load failed: The specified module could not be found. What am I doing wrong? ADDED As it was recommended here, I have copied content of C:\OpenCV2.0\Python2.6\Lib\site-packages to the C:\Python26\Lib\site-packages. It did not help.

    Read the article

  • How does the event dispatch thread work?

    - by Roman
    With the help of people on stackoverflow I was able to get the following working code of the simples GUI countdown (it just displays a window counting down seconds). My main problem with this code is the invokeLater stuff. As far as I understand the invokeLater send a task to the event dispatching thread (EDT) and then the EDT execute this task whenever it "can" (whatever it means). Is it right? To my understanding the code works like that: In the main method we use invokeLater to show the window (showGUI method). In other words, the code displaying the window will be executed in the EDT. In the main method we also start the counter and the counter (by construction) is executed in another thread (so it is not in the event dispatching thread). Right? The counter is executed in a separate thread and periodically it calls updateGUI. The updateGUI is supposed to update GUI. And GUI is working in the EDT. So, updateGUI should also be executed in the EDT. It is why the code for the updateGUI is inclosed in the invokeLater. Is it right? What is not clear to me is why we call the counter from the EDT. Anyway it is not executed in the EDT. It starts immediately a new thread and the counter is executed there. So, why we cannot call the counter in the main method after the invokeLater block? import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; public class CountdownNew { static JLabel label; // Method which defines the appearance of the window. public static void showGUI() { JFrame frame = new JFrame("Simple Countdown"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); label = new JLabel("Some Text"); frame.add(label); frame.pack(); frame.setVisible(true); } // Define a new thread in which the countdown is counting down. public static Thread counter = new Thread() { public void run() { for (int i=10; i>0; i=i-1) { updateGUI(i,label); try {Thread.sleep(1000);} catch(InterruptedException e) {}; } } }; // A method which updates GUI (sets a new value of JLabel). private static void updateGUI(final int i, final JLabel label) { SwingUtilities.invokeLater( new Runnable() { public void run() { label.setText("You have " + i + " seconds."); } } ); } public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { showGUI(); counter.start(); } }); } }

    Read the article

  • How can I put a horizontal line between vertically ordered elements?

    - by Roman
    I have a set of vertically ordered elements. They are displayed with the following code: JPanel myPanel = new JPanel(); myPanel.setLayout(new BoxLayout(myPanel, BoxLayout.Y_AXIS)); JButton button = new JButton("My Button"); JLabel label = new JLabel("My label!!!!!!!!!!!"); myPanel.add(button); myPanel.add(label); I would like to put a horizontal line between my elements (something like <hr> in html). Does anybody know how it can be done?

    Read the article

  • What is Get-Command -CommandType Script?

    - by Roman Kuzmin
    What is Get-Command -CommandType Script? What kind of commands does it cover? Help about Script tells “-- Script: Script blocks in the current session.” but I am not sure what kind of script blocks it means. Are there cases when Get-Command -CommandType Script actually returns anything?

    Read the article

  • How to create select SQL statement that would produce "merged" dataset from two tables(Oracle DBMS)?

    - by Roman Kagan
    Here's my original question: merging two data sets Unfortunately I omitted some intircacies, that I'd like to elaborate here. So I have two tables events_source_1 and events_source_2 tables. I have to produce the data set from those tables into resultant dataset (that I'd be able to insert into third table, but that's irrelevant). events_source_1 contain historic event data and I have to do get the most recent event (for such I'm doing the following: select event_type,b,c,max(event_date),null next_event_date from events_source_1 group by event_type,b,c,event_date,null events_source_2 contain the future event data and I have to do the following: select event_type,b,c,null event_date, next_event_date from events_source_2 where b>sysdate; How to put outer join statement to fill the void (i.e. when same event_type,b,c found from event_source_2 then next_event_date will be filled with the first date found GREATLY APPRECIATE FOR YOUR HELP IN ADVANCE.

    Read the article

  • Why a variable is seen in the loop and is not seen outside the loop?

    - by Roman
    I have the following code: String serviceType; ServiceBrowser tmpBrowser; for (String playerName: players) { serviceType = "_" + playerName + "._tcp"; tmpBrowser = BrowsersGenerator.getBrowser(serviceType); tmpBrowser.browse(); System.out.println(tmpBrowser.getStatus()); } System.out.println(tmpBrowser.getStatus()); The compiler complains about the last line. It writes "variable tmpBrowser might not been initialized". If I comment the last line the compile does not complain.

    Read the article

  • Wordpress custom post_type templates

    - by roman
    We are currently working on a Wordpress page that reuses data from another Application. To keep things clean, but still use most wordpress features, we decided to use custom post_type settings (register_post_type) for this data. Now the Problem is, that while accessing these Posts is no problem, the Permalink's to them fail with 404's. We currently work around this issue by adding an action to the "template_redirect" hook that essentially performs a query_posts for the name and our custom types. If query_posts found something we load our custom post templates with locate_template. Although this is working, it does not look like a clean solution - can anyone here propose a better way to tackle our problems?

    Read the article

  • What are "Location" and "Repositories" in the VisualSVN?

    - by Roman
    I am trying to install VisualSVN to manage my code with other users. In the middle of the installation I have a window saying "Change if necessary installation path and initial VisualSVN Server setting". And after that (in the same window) I have two fields: "Location" and "Repositories". What these two parameters mean? I know URL where the common code is stored. Should I specify this URL in the "repositories" field?

    Read the article

  • Can Bonjour browse a service with a particular name?

    - by Roman
    Bonjour provides "DNSSD.browse(serviceType,callBackObject)" method which browses for services of a particular type. If a service of the given type is found, Bonjour call "callBackObject.serviceFound". If the service is lost, Bonjour calls "callBackObject.serviceLost". I alway considered "DNSSD.browse" as a method for monitoring a particular service. Bonjour monitors a particular service and calls necessary method if the service is found (available) or lost (not available). But than I realized that "DNSSD.browse" receives (as argument) a type of service (for example "http.tcp") and there can be several services of this type. So, its probably calls "serviceFound" and "serviceLost" if any service of the specified type is found or lost, respectively. But in my application I would like to browse just for one particular service. What is the best way to do it? I have two potential solutions: When I register a service, I give it a unique type. For example: "server1.http.tcp". I register services with unique names (not types) and ask Bonjour to browse for services with particular names. But I am not sure that Bonjour provide such possibility. Can it browse for services with specific names?

    Read the article

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