我正在尝试获得一个进度条以准确反映我的SwingWorker.但我真的无法弄清楚该怎么做.我得到了一个静态动画,直到操作完成,但我想要一个真正的活动栏.
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package frglauncher;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.channels.Channels;
import java.nio.channels.ReadableByteChannel;
import java.util.Enumeration;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JLabel;
import javax.swing.JProgressBar;
import javax.swing.SwingWorker;
/**
*
* @author KYLE-LAPTOP
*/
class DownloadWorker extends SwingWorker<String, Object> {
private String game;
private JProgressBar bar;
private JLabel label;
public …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用此库进行 telnet 连接。我已经正确调用了该函数,它执行了下面的代码,但未能给出以下错误:
System.Net.Sockets.SocketException was unhandled
HResult=-2147467259
Message=No such host is known
Source=System
ErrorCode=11001
NativeErrorCode=11001
StackTrace:
at System.Net.Sockets.TcpClient..ctor(String hostname, Int32 port)
at MinimalisticTelnet.TelnetConnection..ctor(String Hostname, Int32 Port) in c:\users\kylec\documents\visual studio 2010\Projects\Mail Server Capture\Mail Server Capture\TelnetInterface.cs:line 36
at Mail_Server_Capture.Form1.btn_MailGet_Click(Object sender, EventArgs e) in c:\users\kylec\documents\visual studio 2010\Projects\Mail Server Capture\Mail Server Capture\Form1.cs:line 55
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) …Run Code Online (Sandbox Code Playgroud) 所以我一直在尝试为我的应用程序开发这个安装程序.我决定将我的GUI更改为<UIRef Id="WixUI_InstallDir" />.根据我正在阅读的教程,我还需要包括<Property Id="WIXUI_INSTALLDIR" Value="TOP_LEVEL_DIR" />如果我使用该GUI.但是,由于我更改了GUI并添加了这一行,我收到了一个错误(2343).我也在下面发布了MSI日志,它抱怨一个位置?
错误: MSI(c)(CC:84)[13:27:33:140]:注意:1:2343 DEBUG:错误2343:指定的路径为空.安装程序在安装此程序包时遇到意外错误.这可能表明此包装存在问题.错误代码是2343.参数是:,, MSI(c)(CC:84)[13:27:34:663]:产品:Viewer 1.0 - 安装程序在安装此软件包时遇到意外错误.这可能表明此包装存在问题.错误代码是2343.参数是:,,,
Action ended 13:27:34: WelcomeDlg. Return value 3.
MSI (c) (CC:DC) [13:27:34:672]: Doing action: FatalError
Action 13:27:34: FatalError.
Action start 13:27:34: FatalError.
Action 13:27:34: FatalError. Dialog created
Action ended 13:27:36: FatalError. Return value 2.
Action ended 13:27:36: INSTALL. Return value 3.
Run Code Online (Sandbox Code Playgroud)
码:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product Name='Viewer 1.0' Id='*' UpgradeCode='PUT-GUID-HERE'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Direct'>
<Package Id='*' Keywords='Installer' Description="Viewer Installer"
Comments='Installer is a …Run Code Online (Sandbox Code Playgroud) 我在这里尝试做的是将图像添加到我拥有的按钮,然后基于点击或悬停更改图像.我所遵循的所有示例都使用该.config()方法.
对于我的生活,我无法弄清楚为什么它不知道按钮对象是什么.有趣的是,如果我修改Button定义行以包含图像选项,一切都很好.但是,有了它,似乎我不能使用它来修改它.config()
PlayUp = PhotoImage(file=currentdir+'\Up_image.gif')
PlayDown = PhotoImage(file=currentdir+'\Down_image.gif')
#Functions
def playButton():
pButton.config(image=PlayDown)
pButton = Button(root, text="Play", command="playButton").grid(row=1)
pButton.config(image=PlayUp)
Run Code Online (Sandbox Code Playgroud) 我正在尝试从此目录下载所有文件.但是,我只能将它作为一个文件下载.我能做什么?我试图搜索这个问题,这让人感到困惑,人们开始建议使用httpclients.感谢您的帮助,这是我的代码到目前为止.有人建议我使用输入流来获取目录中的所有文件.那么那会进入阵列吗?我在http://docs.oracle.com/javase/tutorial/networking/urls/尝试了这个教程,但它没有帮助我理解.
//ProgressBar/Install
String URL_LOCATION = "http://www.futureretrogaming.tk/gamefiles/ProfessorPhys/";
String LOCAL_FILE = filelocation.getText() + "\\ProfessorPhys\\";
try {
java.net.URL url = new URL(URL_LOCATION);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.addRequestProperty("User-Agent", "Mozilla/4.76");
//URLConnection connection = url.openConnection();
BufferedInputStream stream = new BufferedInputStream(connection.getInputStream());
int available = stream.available();
byte b[]= new byte[available];
stream.read(b);
File file = new File(LOCAL_FILE);
OutputStream out = new FileOutputStream(file);
out.write(b);
} catch (Exception e) {
System.err.println(e);
}
Run Code Online (Sandbox Code Playgroud)
我还发现这个代码将返回要下载的文件列表.有人可以帮我合并这两个代码吗?
public class GetAllFilesInDirectory {
public static void main(String[] args) throws IOException {
File dir = …Run Code Online (Sandbox Code Playgroud) 所以我试图通过检查mainfest文件中的一些值来查看.jar是否有效.使用java读取和解析文件的最佳方法是什么?我想过用这个命令来解压缩文件
jar -xvf anyjar.jar META-INF/MANIFEST.MF
Run Code Online (Sandbox Code Playgroud)
但我可以这样做:
File manifest = Command.exec("jar -xvf anyjar.jar META-INF/MAINFEST.MF");
Run Code Online (Sandbox Code Playgroud)
然后使用一些缓冲的读者或其他东西来解析文件的行?
谢谢你的帮助...
我在这里寻找答案但是因为每个案例似乎都是独一无二的,到目前为止没有答案帮助我,我决定发布我自己的答案.由于某种原因,我收到以下有关以下代码的错误.我似乎无法找到任何错误.据我所知,它没有非法字符.我试过有没有"并没有什么区别.错误中具体引用的行是动词行.
错误:
C:\Users\kylec\Desktop\SampleFirst\SampleFirst.wxs(25) : error LGHT0094 :
Unresolved reference to symbol 'File:Viewer.exe' in section
'Product:{00000000-0000-0000-0000000000000000}'.
Run Code Online (Sandbox Code Playgroud)
码:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
<Product Name='Viewer 1.0' Id='PUT-GUID-HERE' UpgradeCode='PUT-GUID-HERE'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Direct'>
<Package Id='*' Keywords='Installer' Description="Installer"
Comments='Installer is a registered trademark of Direct'
Manufacturer='Direct' InstallerVersion='100' Languages='1033'
Compressed='yes' SummaryCodepage='1252' />
<Media Id='1' Cabinet='Sample.cab' EmbedCab='yes' DiskPrompt="CD-ROM #1" />
<Property Id='DiskPrompt' Value="Installation [1]" />
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='DataMotionDirect' Name='DMD'>
<Directory Id='INSTALLDIR' Name='Viewer'>
<Component Id='MainExecutable' Guid='*'>
<Shortcut Id="startmenuViewer" Directory="ProgramMenuDir"
Name="Viewer" WorkingDirectory='INSTALLDIR'
Icon="Viewer.exe" …Run Code Online (Sandbox Code Playgroud) 所以我试图简单地将一个数据字段从表单发送到php文件.下面是我在表格中的表格.我还发布了我的PHP代码.它一直返回$ username为null.我试过post/get,这似乎并不重要.
HTML:
<form action='http://k9minecraft.tk/scripts/adduser.php' method='POST'>
<table>
<tr>
<td>First Name:</td>
<td><input type='text' id='first'></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input type='text' id='last'></td>
</tr>
<tr>
<td>Email:</td>
<td><input type='text' id='email'></td>
</tr>
<tr>
<td>Minecraft Name:</td>
<td><input type='text' name='user'></td>
</tr>
<tr>
<td><input type='submit' value='Send'></td>
<td><input type='reset' value='Reset'></td>
</tr>
</table>
</form>
Run Code Online (Sandbox Code Playgroud)
PHP:
<?php
print_r($_POST);
if(isset($_POST['user'])){
$username = $_POST['user'];
echo $username;
echo 'username is not null';
}
?>
Run Code Online (Sandbox Code Playgroud) 好吧所以这很难解释.
场景:
我有一个DataGrid定义如下:
<DataGrid Height="100" Name="test" IsReadOnly="False">
<DataGrid.Columns>
<DataGridTextColumn Header="URL"></DataGridTextColumn>
<DataGridTextColumn Header="PORT"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)

它有两个标题,我需要添加数据,我做了很多研究,建议使用ObservableCollection,因为这将触发DataChanged事件.
我可以使用可能不相关的长期无聊代码来制定这些数据(您将在下面看到原因).
问题:
添加了200行,但文本本身不在表中

故障排除:
我打开调试并使用屏幕截图帮助,您可以看到有实际数据但它不会将其插入行中,但它会添加行.

相关守则:
ObservableCollection<Proxy> collection = new ObservableCollection<Proxy>();
collection = GetData(ips,ports);
test.CanUserAddRows = true;
test.ItemsSource = null;
test.ItemsSource = collection;
MessageBox.Show("Done");
Run Code Online (Sandbox Code Playgroud)
我正试图弄清楚我的头撞墙.
注意:我添加了.ItemSource = null; 然后将其设置为等于集合,因为它使行显示.我尝试过使用建议:test.DataContext = collection; 但是,根本没有添加任何行,是的,就像这个测试一样,数据在调试模式下可见,因为它是context/itemsource的一部分.
更新:
我尝试使用相同的结果实现以下XAML
<DataGrid Height="100" Name="test" IsReadOnly="False" ItemsSource="{Binding collection}">
<DataGrid.Columns>
<DataGridTextColumn Header="URL" Binding="{Binding ip}"></DataGridTextColumn>
<DataGridTextColumn Header="PORT" Binding="{Binding port}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)
代理类:
public class Proxy
{
public string ip;
public string port;
}
Run Code Online (Sandbox Code Playgroud)
更新2: …
我正在尝试创建一个 WiX 安装程序,以确保用户使用的是 Windows 7 并且尚未安装 .NET Framework 4.5。下面是错误代码和捆绑包中的 XML/WXS 代码。我不知道为什么它不理解这一点,除非它是所有的括号。但是,没有它们,它就无法理解“NOT”是什么。
代码:
<Chain>
<ExePackage Id="PrePackage" SourceFile="dotNetFx45_Full_Setup.exe" InstallCondition="(VersionNT >= v6.1) AND NOT (Net4FullVersion >= 4.5)" />
<MsiPackage Id="MainPackage" SourceFile="SampleFirst.msi" InstallCondition="VersionNT >= v6.1" />
</Chain>
Run Code Online (Sandbox Code Playgroud)
错误:
[0A20:0954][2014-06-23T12:07:14]e000: Error 0x8007000d: Failed to parse condition "(VersionNT >= v6.1) AND NOT (Net4FullVersion >= 4.5)". Unexpected character at position 49.
Run Code Online (Sandbox Code Playgroud) 我正在制作一个皮肤很厚的应用程序.我试图在WPF中实现一个选项卡控件.我已经开始研究这些tabitems及其各自的背景.但是,我注意到选项卡控件上只有两个tabitems,只用白色填充剩余空间.我有什么属性来改变这个空白区?任何帮助表示赞赏,下面是参考图片以及我的xaml.
图片:

XAML:
<TabControl Margin="0,35,0,0" Background="#1F1F1F">
<TabControl.Resources>
<Style TargetType="TabItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="TabItem">
<Grid Name="Panel">
<Border Name="Border" BorderThickness="1,1,1,0" BorderBrush="Gainsboro" CornerRadius="4,4,0,0" Margin="2,0">
<ContentPresenter x:Name="ContentSite"
VerticalAlignment="Center"
HorizontalAlignment="Center"
ContentSource="Header"
Margin="10,2"/>
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="False">
<Setter TargetName="Panel" Property="Background" Value="LightGray" />
<Setter TargetName="Panel" Property="TextBlock.Foreground" Value="Black"></Setter>
</Trigger>
<Trigger Property="IsSelected" Value="True">
<Setter TargetName="Panel" Property="Background" Value="#4d4d4d" />
<Setter TargetName="Panel" Property="TextBlock.Foreground" Value="White"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.Resources>
<TabItem Header="Settings">
</TabItem>
<TabItem Header="Results">
</TabItem>
</TabControl>
Run Code Online (Sandbox Code Playgroud) 我有一个长字符串,其中包含许多\ n转义序列,这些转义序列应该是换行符。为了正确地编写要读取的字符串,我认为最好根据\ n字符分割字符串,然后将每个字符串分别写入结果列表中,以实现所需的效果。但是,这行不通,只是没有正确地拆分它们。以下是我的代码,为了清楚起见,我尝试将\ n和\ n都作为拆分,因为我试图在字符串中的文字\ n处拆分。谢谢你的帮助。
shellreturn = subprocess.check_output(["C:\Python34\python",root.wgetdir + "\html2text.py", keyworddir + "\\" + item])
print(shellreturn)
shelllist = (str(shellreturn).split("\\n"))
Run Code Online (Sandbox Code Playgroud) 所以我试图读取一个文件,并在顶部添加两行代码.到目前为止,还没有工作,所以我试着读取线条并将它们写回来.这是一次重大失败.它只会写入目录中的一个文件,并且只是一直填写xmlopentag,即使它被一遍又一遍地注释掉了.如果有人有任何想法,将不胜感激.
ArrayList<String> lines = new ArrayList();
BufferedReader reader = null;
String xmlstylesheet = "<?xml-stylesheet type=\"text/xsl\" href=\""+stylefilename+"\"?>";
String xmlopentag = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
for(int i=0;i<files.length;i++) {
lines.clear();
try {
reader = new BufferedReader(new FileReader(files[i]));
String text = null;
while ((text = reader.readLine()) != null) {
lines.add(text);
}
} catch (FileNotFoundException ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex);
}
//lines.add(1, xmlstylesheet);
//lines.add(0, xmlopentag);
try {
PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(files[i])));
for(int j=0;j<lines.size();j++) {
writer.write(lines.get(i)); …Run Code Online (Sandbox Code Playgroud) java ×4
c# ×3
wix ×3
file ×2
python ×2
swing ×2
wpf ×2
xml ×2
button ×1
datagridview ×1
directory ×1
download ×1
exception ×1
file-io ×1
forms ×1
html5 ×1
image ×1
installer ×1
jar ×1
jprogressbar ×1
list ×1
manifest ×1
newline ×1
nonetype ×1
parsing ×1
php ×1
post ×1
rows ×1
sockets ×1
split ×1
swingworker ×1
tabcontrol ×1
telnet ×1
xaml ×1