在我的程序中,我希望在我的JFrame上有一个半透明的白色到透明渐变,以覆盖黄色背景.这工作正常,它需要是白色到透明,因为我的程序设置如何为用户工作.然而,当我把程序带入大学(JRE7到我的JRE6)时,渐变变成白色到黑色然后透明......直到你开始增加白色的不透明度就没那么糟了...无论如何我能解决这个问题?
这是我的JFrame代码顶部的相关代码.
public class DictionaryGUI extends JFrame
{
protected JPanel pGradientPane;
//Interface gradient specification
private Color pInterfaceColour = new Color(255, 245, 62);
protected int iDegreeWhite = 180
protected int iDegreeBlack = 0
DictionaryGUI(int iWidth, int iHeight)
{
/*General definitions*/
super(String.format("French Verb Conjugator - Version %s", MainLauncher.version));
setSize(iWidth, iHeight);
new Menu(this);
this.iWidth = iWidth;
this.iHeight = iHeight;
getContentPane().setBackground(pInterfaceColour);
pGradientPane = new JPanel(new GridBagLayout())
{
private static final long serialVersionUID = 1L;
protected void paintComponent(Graphics pGraphics)
{
Graphics2D pGraphicsGradientRender = (Graphics2D) pGraphics; …Run Code Online (Sandbox Code Playgroud) 我今天一直在学习Bitwise操作,我学会了Not(〜)反转所有位,例如:
01010
to
10101
Run Code Online (Sandbox Code Playgroud)
这意味着~10应该是-5但是我已经看到它是-11(根据python命令行)
01010
to
11011
Run Code Online (Sandbox Code Playgroud)
只有两个位被反转.谁能解释为什么它不是10101?
编辑:看了我的计算器后,我理解它好一点,但我自己的确定二进制和整数的代码仍然混淆.进入(在字节模式下)11110101给我-11,但在我的代码中输入的相同内容给出-117:
def binaryToInt(biNum, bUnsigned = False):
iNum = 0
bSign = int(biNum[0]) if not (bUnsigned or biNum[-1] == "u") else 0
biNum = biNum[(1 if not (bUnsigned or biNum[-1] == "u") else 0):(len(biNum) if biNum[-1] != "u" else -1)]
for i in xrange(len(biNum)):
iNum += int(biNum[i]) * 2**(len(biNum) - 1 - i)
return (iNum if not bSign else -iNum)
def intToBinary(iNum, bUnsigned = False):
bSign = "1" if iNum < 0 …Run Code Online (Sandbox Code Playgroud) 我需要在我的应用程序中使用专为API级别8设计的操作栏.所以我着手让ActionBarSherlock进入我的应用程序.
我按照说明为操作栏创建了一个新项目,然后将其添加到我项目的Android选项卡中的库中.
然而,当我尝试清理项目时,我丢失了我的R.Java文件并弹出了一堆错误:
[2013-02-02 19:50:36 - FrenchVerbApp] C:\Users\Jamie\Downloads\JakeWharton-ActionBarSherlock-4.2.0-0-g90939dc\JakeWharton-ActionBarSherlock-e5c2d1c\library\res\values-v14\abs__styles.xml:6: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.ActionBar.Solid'.
[2013-02-02 19:50:36 - FrenchVerbApp] C:\Users\Jamie\Downloads\JakeWharton-ActionBarSherlock-4.2.0-0-g90939dc\JakeWharton-ActionBarSherlock-e5c2d1c\library\res\values-v14\abs__styles.xml:10: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionBar.Solid'.
[2013-02-02 19:50:36 - FrenchVerbApp] C:\Users\Jamie\Downloads\JakeWharton-ActionBarSherlock-4.2.0-0-g90939dc\JakeWharton-ActionBarSherlock-e5c2d1c\library\res\values-v14\abs__styles.xml:12: error: Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Holo.Light.ActionBar.Solid.Inverse'.
[2013-02-02 19:50:36 - FrenchVerbApp] C:\Users\Jamie\Downloads\JakeWharton-ActionBarSherlock-4.2.0-0-g90939dc\JakeWharton-ActionBarSherlock-e5c2d1c\library\res\values-v14\abs__styles.xml:15: error: Error retrieving parent for item: No resource found that matches the …Run Code Online (Sandbox Code Playgroud) 我JButton在界面上遇到问题,当按下按钮时触发此事件监听器:
if (event.getSource() == goButton)
{
MainLauncher.doProgram(assetsField.getText(), FileFinder.completePath(String.format("%s\\%s", modDirectoryPath, modList.getSelectedValue())), databaseField.getText());
}
Run Code Online (Sandbox Code Playgroud)
它运行以下代码:
public static void doProgram(final String baseGamePath, final String modPath, final String databasePath)
{
new Thread()
{
public void run()
{
System.out.println("Running: " + modPath + "\n");
reader = new MetaDataReader(databasePath);
reader.formConnection();
long start = System.currentTimeMillis();
long temp;
File cache = new File("RegisterCache.SC");
if (!cache.exists())
{
temp = System.currentTimeMillis();
start += System.currentTimeMillis() - temp;
System.out.println("Calculating number of files");
FileFinder baseGame = new FileFinder();
baseGame.calculateNumFiles(baseGamePath);
System.out.println(String.format("Loading %s …Run Code Online (Sandbox Code Playgroud) 我命令确保在套接字关闭时停止从套接字读取数据的线程(由于事实socket.isClosed()不能按预期工作)我写了一个"心跳"来检查套接字是否仍然打开.startHeartbeat()在BufferedReader开始读取套接字之前调用该方法,并且只在isClosed()false 时才开始读取.
这里有一些同步方法,但与其他类似问题不同,wait()调用不在其中一种方法中.这是基本代码:
synchronized boolean isClosed()
{
return closed;
}
synchronized void setClosed(boolean b)
{
closed = b;
}
//We need to make sure that the socket is still online, to ensure the reading stops when the connection closes.
void startHeartbeat()
{
Thread heartbeat = new Thread()
{
public void run()
{
while (true)
{
try
{
post(THUMP_THUMP);
setClosed(false);
}
catch (IOException e)
{
setClosed(true);
}
finally
{
try
{
this.wait(PULSE); //Exception …Run Code Online (Sandbox Code Playgroud)